Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate singular values all ROIs in compute_SVD() #128

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
18 changes: 10 additions & 8 deletions facemap/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def compute_SVD(
ni_mov[0] += ncb
ns += 1

S_mot = np.zeros(500, "float32")
S_mov = np.zeros(500, "float32")
S_mot = []
S_mov = []
# take SVD of concatenated spatial PCs
if ns > 1:
for nr in range(len(U_mot)):
Expand All @@ -270,29 +270,29 @@ def compute_SVD(
U_mot[nr], k=min(ncomps, U_mot[nr].shape[0] - 1)
)
U_mot[nr] = usv[0]
S_mot = usv[1]
S_mot.append(usv[1])
if movSVD:
U_mov[nr] = U_mov[nr][:, : ni_mov[0]]
usv = utils.svdecon(
U_mov[nr], k=min(ncomps, U_mov[nr].shape[0] - 1)
)
U_mov[nr] = usv[0]
S_mov = usv[1]
S_mov.append(usv[1])
elif nr > 0:
if motSVD:
U_mot[nr] = U_mot[nr][:, : ni_mot[nr]]
usv = utils.svdecon(
U_mot[nr], k=min(ncomps, U_mot[nr].shape[0] - 1)
)
U_mot[nr] = usv[0]
S_mot = usv[1]
S_mot.append(usv[1])
if movSVD:
U_mov[nr] = U_mov[nr][:, : ni_mov[nr]]
usv = utils.svdecon(
U_mov[nr], k=min(ncomps, U_mov[nr].shape[0] - 1)
)
U_mov[nr] = usv[0]
S_mov = usv[1]
S_mov.append(usv[1])

utils.update_mainwindow_message(MainWindow, GUIobject, "Finished computing svd")

Expand Down Expand Up @@ -705,7 +705,7 @@ def run(
rois = proc["rois"]
sy = proc["sy"]
sx = proc["sx"]
savepath = proc["savepath"] if savepath is None else savepath #proc["savepath"] if savepath is not None else savepath
savepath = proc["savepath"] if savepath is None else savepath

Lybin, Lxbin, iinds = binned_inds(Ly, Lx, sbin)
LYbin, LXbin, sybin, sxbin = utils.video_placement(Lybin, Lxbin)
Expand Down Expand Up @@ -788,6 +788,8 @@ def run(

U_mot_reshape = U_mot.copy()
U_mov_reshape = U_mov.copy()
S_mot_reshape = S_mot.copy()
S_mov_reshape = S_mov.copy()
if fullSVD:
if motSVD:
U_mot_reshape[0] = utils.multivideo_reshape(
Expand All @@ -814,7 +816,7 @@ def run(
k += 1
else:
U_mot, U_mov, S_mot, S_mov = [], [], [], []
U_mot_reshape, U_mov_reshape = [], []
U_mot_reshape, U_mov_reshape, S_mot_reshape, S_mov_reshape = [], [], [], []

# Add V_mot and/or V_mov calculation: project U onto all movie frames ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# and compute pupil (if selected)
Expand Down