-
Notifications
You must be signed in to change notification settings - Fork 369
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
Fix subidx
to enable computing the NoRMCorre template frame from subset of movie frames
#1133
base: dev
Are you sure you want to change the base?
Conversation
fix subidx to compute motion correction template from a movie slice
fix broken path to logo
Update README.md logo path
Great thanks a lot for the contribution. I am about to go out of town for Scipy next week, so not sure when I will get a chance to review, but I look forward to checking this out! |
Hi I'm back from Scipy, and will set aside some time this week to look this over. Thanks again for the contribution! |
Hi Eric, sounds good, thank you for the update! Please don't hesitate if you have any questions. |
This is a really helpful contribution, and relates to #1106, which is something I've been wanting to do since before I opened that issue. I'm not sure how closely it implements the functionality in that issue, so I will want to test it out, and see if it works as intended in multiple use cases. It will probably take me a little while to run through this and stress test it, and I'm going on vacation next week (sorry! 😄), but I will start with it today, and probably tweak it in a few places, and may have some questions. |
I have just had a little time to look it over, but a few things that hit me on first view. On the usage of this param: I've always considered it to be the temporal analog of Also, it looks like currently this PR has integrated only into rigid motion correction, but not nonrigid? Nonrigid also has the same param. We should add documentation to the args docs in This should become part of I will be out for a week+, but properly describing and exposing |
Hi Eric, you are absolutely right, I can see two ways for enabling both use cases:
What do you think? Happy to help either way! |
Thanks for these thoughts they help clarify the path forward: it seems Option 1 is the the right way to go. I think I'm thinking maybe the right path forward is to implement This would have the unfortunate consequence of slowing things down a bit, but I do think in the long run would be a very cool double feature. This sounds like two separate PRs to me: first just Does this sound like a reasonable path forward to you? |
Note @ludovicbellier we've done quite a bit of work in the past week or so on getting subindices to work in a couple of out-of-the-way methods ( |
Hi @EricThomson, sorry for the late reply, I took a vacation in France for the first time in 5 years! =) |
Hi @ludovicbellier, we are currently patching up a few things in dev and a couple of us are traveling. When we are all back in a couple of weeks we should hopefully merge. I'll report back once this is done. |
Perfect, thanks @EricThomson for this update and looking forward to hearing back from you soon! |
This reverts commit 88d1b48.
@ludovicbellier We've pushed the new version with subindexing fixed so I now have a better sense for how it is supposed to work 😄 Will now be able to loop around to this (probably after SFN unfortunately I have tons of things to prepare for the SFN workshop sorry this is taking so long!!). |
Description
Hi team CaImAn! I'm Ludovic Bellier, a Senior Computational Research Scientist at Inscopix, a Bruker company. First, thank you so much for making available to the community such an amazing and powerful toolbox!
In several projects we process concatenated movies, and we've noticed that in some instances motion correction wasn't working well. Upon further investigation, it happened when there was a big shift in Field Of View (FOV) between two concatenated movies, and we tracked down the issue to the reference frame that is computed from a subset of frames uniformly sampled throughout the concatenated movies: with a big shift between movies, it ends up averaging frames at two FOVs relatively shifted from one another, and yields a "dual state", "echo" template frame. Here's an ASCII, 1D example, hoping it makes it clearer 😁
Movie 1 FOV: ". . | . . ." (let's say | is a blood vessel, represented on pixel 3)
Movie 2 FOV: ". . . | . ." (leftward shift, now | is on pixel 4)
Template frame: ". . | | . ." (averaging an equal number of frames from Movie 1 and 2 results in a blurry template frame, with the blood vessel both on pixel 3 and 4)
Then, during the motion correction iterations, frames from movie 1 will match the template frame well enough, as will frames from movie 2. In other words, there is no incentive for frames of each movie to be shifted to match the template, when the template has "echoed", duplicated landmarks.
After a few unsuccessful attempts at providing a single frame as template frame, we dug into the code and noticed there was an argument,
subidx
, meant to index a slice of movie frames. Only, it was not functioning properly.In this present PR, we fixed this bug and restore the ability to compute the motion-correction template frame by uniformly sampling frames from a slice of the Tiff stack only. Using this code successfully fixed motion correction in all instances where we had substantial shifts between concatenated movies.
Type of change
Has your PR been tested?
All motion correction tests in
python caimanmanager.py test
ran successfully.Task list
params.motion
MotionCorrect