Skip to content

Commit

Permalink
Merge pull request #133 from MouseLand/dev
Browse files Browse the repository at this point in the history
Fix issue #127
  • Loading branch information
Atika-Syeda authored Nov 20, 2023
2 parents 8396935 + 5bf1529 commit 1c10731
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
16 changes: 10 additions & 6 deletions facemap/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ def make_buttons(self):
# Check boxes
self.motSVD_checkbox = QCheckBox("motSVD")
self.motSVD_checkbox.setStyleSheet("color: gray;")
self.motSVD_checkbox.setChecked(True)
self.process_groupbox.layout().addWidget(self.motSVD_checkbox, 0, 0)
self.movSVD_checkbox = QCheckBox("movSVD")
self.movSVD_checkbox.setStyleSheet("color: gray;")
self.movSVD_checkbox.setChecked(True)
self.process_groupbox.layout().addWidget(self.movSVD_checkbox, 0, 1)
self.keypoints_checkbox = QCheckBox("Keypoints")
self.keypoints_checkbox.setStyleSheet("color: gray;")
Expand Down Expand Up @@ -1167,7 +1169,6 @@ def update_buttons(self):
self.pauseButton.setChecked(True)
self.process.setEnabled(True)
self.saverois.setEnabled(True)
self.multivideo_svd_checkbox.setChecked(True)
self.save_mat.setChecked(True)
#self.load_trace2_button.setEnabled(True)

Expand Down Expand Up @@ -1528,7 +1529,6 @@ def load_keypoints(self):
self.pose_likelihood = np.array(
[self.pose_likelihood]
) # size: keypoints x frames
# TODO: Choose colors for each label: provide option for palette that is color-blind friendly
colors = cm.get_cmap("jet")(
np.linspace(0, 1.0, len(self.keypoints_labels[video_id]))
)
Expand Down Expand Up @@ -1894,15 +1894,19 @@ def plot_trace(self, wplot, proctype, wroi, color, keypoints_group_selected=None
else:
ir = wroi + 1
cmap = cm.get_cmap("hsv")
nc = min(10, self.motSVDs[ir].shape[1])
if self.motSVDs == []:
svd_trace = self.movSVDs
else:
svd_trace = self.motSVDs
nc = min(10, svd_trace[ir].shape[1])
cmap = (255 * cmap(np.linspace(0, 0.2, nc))).astype(int)
norm = (self.motSVDs[ir][:, 0]).std()
tr = (self.motSVDs[ir][:, :10] ** 2).sum(axis=1) ** 0.5 / norm
norm = (svd_trace[ir][:, 0]).std()
tr = (svd_trace[ir][:, :10] ** 2).sum(axis=1) ** 0.5 / norm
for c in np.arange(0, nc, 1, int)[::-1]:
pen = pg.mkPen(
tuple(cmap[c, :]), width=1
) # , style=QtCore.Qt.DashLine)
tr2 = self.motSVDs[ir][:, c] / norm
tr2 = svd_trace[ir][:, c] / norm
tr2 *= np.sign(skew(tr2))
selected_plot.plot(tr2, pen=pen)
pen = pg.mkPen(color)
Expand Down
Binary file modified facemap/gui/ops_user.npy
Binary file not shown.
37 changes: 22 additions & 15 deletions facemap/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ def process_ROIs(
nroi = 0 # number of motion ROIs

if fullSVD:
ncomps_mot = U_mot[0].shape[-1]
ncomps_mov = U_mov[0].shape[-1]
if motSVD:
ncomps_mot = U_mot[0].shape[-1]
if movSVD:
ncomps_mov = U_mov[0].shape[-1]
V_mot = [np.zeros((nframes, ncomps_mot), np.float32)] if motSVD else []
V_mov = [np.zeros((nframes, ncomps_mov), np.float32)] if movSVD else []
M = [np.zeros((nframes), np.float32)]
Expand Down Expand Up @@ -454,10 +456,11 @@ def process_ROIs(
if movSVD: # use raw frames for movSVD
imbin_mov = imbin[1:, :]
if fullSVD:
M[0][t : t + imbin_mot.shape[0]] += imbin_mot.sum(axis=-1)
if motSVD:
M[0][t : t + imbin_mot.shape[0]] += imbin_mot.sum(axis=-1)
imall_mot[:, ir[ii]] = imbin_mot - avgmotion[ii].flatten()
if movSVD:
M = []
imall_mov[:, ir[ii]] = imbin_mov - avgframe[ii].flatten()
if nroi > 0 and wmot.size > 0:
wmot = np.array(wmot).astype(int)
Expand Down Expand Up @@ -787,24 +790,28 @@ def run(
U_mot_reshape = U_mot.copy()
U_mov_reshape = U_mov.copy()
if fullSVD:
U_mot_reshape[0] = utils.multivideo_reshape(
U_mot_reshape[0], LYbin, LXbin, sybin, sxbin, Lybin, Lxbin, iinds
)
U_mov_reshape[0] = utils.multivideo_reshape(
U_mov_reshape[0], LYbin, LXbin, sybin, sxbin, Lybin, Lxbin, iinds
)
if motSVD:
U_mot_reshape[0] = utils.multivideo_reshape(
U_mot_reshape[0], LYbin, LXbin, sybin, sxbin, Lybin, Lxbin, iinds
)
if movSVD:
U_mov_reshape[0] = utils.multivideo_reshape(
U_mov_reshape[0], LYbin, LXbin, sybin, sxbin, Lybin, Lxbin, iinds
)
if nroi > 0:
k = 1
for r in rois:
if r["rind"] == 1:
ly = r["yrange_bin"].size
lx = r["xrange_bin"].size
U_mot_reshape[k] = np.reshape(
U_mot[k].copy(), (ly, lx, U_mot[k].shape[-1])
)
U_mov_reshape[k] = np.reshape(
U_mov[k].copy(), (ly, lx, U_mov[k].shape[-1])
)
if motSVD:
U_mot_reshape[k] = np.reshape(
U_mot[k].copy(), (ly, lx, U_mot[k].shape[-1])
)
if movSVD:
U_mov_reshape[k] = np.reshape(
U_mov[k].copy(), (ly, lx, U_mov[k].shape[-1])
)
k += 1
else:
U_mot, U_mov, S_mot, S_mov = [], [], [], []
Expand Down

0 comments on commit 1c10731

Please sign in to comment.