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

Registration metrics do not exclude bad frames #1144

Closed
samupicard opened this issue Sep 5, 2024 · 2 comments
Closed

Registration metrics do not exclude bad frames #1144

samupicard opened this issue Sep 5, 2024 · 2 comments
Assignees

Comments

@samupicard
Copy link

samupicard commented Sep 5, 2024

As far as I understand, the registration metrics do not exclude any of the 'bad frames' at the moment: the PCA is performed on an equally subsampled set of frames from the registered movie. This leads to really high metrics on sessions where there were artefacts e.g. the signal dropping suddenly (I've attached a screenshot from the GUI as an example). This approach makes sense for the automatically computed bad frames as you would otherwise underestimate potential registration errors, but surely it would be good to at least take into account the user-defined bad_frames.npy array for these metrics?

It seems that this would be relatively easy fix in this part of the main pipeline code...

suite2p/suite2p/run_s2p.py

Lines 148 to 163 in c88e1ba

# compute metrics for registration
if ops.get("do_regmetrics", True) and n_frames >= 1500:
t0 = time.time()
# n frames to pick from full movie
nsamp = min(2000 if n_frames < 5000 or Ly > 700 or Lx > 700 else 5000,
n_frames)
inds = np.linspace(0, n_frames - 1, nsamp).astype("int")
mov = f_reg[inds]
mov = mov[:, ops["yrange"][0]:ops["yrange"][-1],
ops["xrange"][0]:ops["xrange"][-1]]
ops = registration.get_pc_metrics(mov, ops)
plane_times["registration_metrics"] = time.time() - t0
print("Registration metrics, %0.2f sec." %
plane_times["registration_metrics"])
if ops.get("ops_path"):
np.save(ops["ops_path"], ops)

@samupicard
Copy link
Author

reg_metrics_suite2p

carsen-stringer pushed a commit that referenced this issue Dec 25, 2024
@chriski777 chriski777 self-assigned this Dec 25, 2024
@chriski777
Copy link
Collaborator

chriski777 commented Dec 25, 2024

Thanks for raising this issue, @samupicard! That's a great point you make and we've added a functionality to only remove any user-specified bad_frames before computing the registration metrics. This change should be integrated soon to the main branch but if you'd like to try it out now, feel free to pull the latest changes from the dev branch.

I'll close this issue for now but feel free to reopen if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants