diff --git a/facemap/gui/gui.py b/facemap/gui/gui.py index 2dce18e..34d4059 100644 --- a/facemap/gui/gui.py +++ b/facemap/gui/gui.py @@ -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;") @@ -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) @@ -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])) ) @@ -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) diff --git a/facemap/gui/ops_user.npy b/facemap/gui/ops_user.npy index fb89223..635607e 100755 Binary files a/facemap/gui/ops_user.npy and b/facemap/gui/ops_user.npy differ diff --git a/facemap/process.py b/facemap/process.py index af8a850..ff4bef9 100644 --- a/facemap/process.py +++ b/facemap/process.py @@ -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)] @@ -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) @@ -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 = [], [], [], []