-
Notifications
You must be signed in to change notification settings - Fork 16
Analyzing TIFF files with time frames < 500 #323
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
Comments
I could be wrong but I don't think this is intentional... I think the best way to work around is to use min(1000, T) for the window size @kushalkolar? This footgun should really also be fixed upstream though. |
I don't know if this will be fixed, easiest way for you to move forward is to use your own fork and change the hardcoded values here: https://github.com/nel-lab/mesmerize-core/blob/master/mesmerize_core%2Falgorithms%2Fmcorr.py#L95-L96
What specifically are you unsure about? |
Hey @ethanbb and @kushalkolar, thank you for the quick response. Some follow up questions:
I tried to do this by changing my image. Currently, it is 1000 px by 1000 px [I assume the X and Y are the window size??] with 103-time frames. However, similar error persists (see attached screenshot).
I am unsure why the window size has to be fixed to be 1000. What does the "window size" represent? The X and Y dimension of pixels during image acquisition of microscope?
I changed the values to fit my images (see image below). However, the exact same error is still raised. The only change was that when "Computing correlation image" was running, it ran for longer before giving the error. |
It's the time dimension. Where did you make the change, if you have a local fork you have to pip install it in place. From the traceback it shows it's using the mescore in the environment. |
Yeah to add to this, sorry it was unclear, the "window" has nothing to do with X and Y so you don't have to truncate your movie or do anything else to it. It's just the length of the window in time that the local correlation algorithm uses, which can't be longer than the number of frames in your data. |
I installed mescore with mamba by creating a mescore env. I changed the code within the python script where it was installed in the mescore environment "C:\Users\name\miniconda3\envs\mescore\Lib\site-packages\mesmerize_core\algorithms" Wouldn't pip install create a new script with the original values? |
You want to do an inplace install with a local fork where you maek your changes git clone https://github.com/nel-lab/mesmerize-core.git
# make your changes
cd mesmerize-core
pip install -e . |
Update: I have successfully changed the mcorr.py and processed my data. Follow-up: My actual data is 3D +time and the demo only have 2D data. Do you have any recommendations for the analysis of 3D data and options to tinker with? |
mesmerize-viz only supports 2D visualizations, you'll have to use the fastplotlib I've never done 3D motion correction but I think @ethanbb has experience with this |
Yes mesmerize-core (but not -viz) should support 3D motion correction and CNMF, as long as you are using CaImAn version 1.11.2 or later. Note that there are a few parameters that must be changed from their defaults in order for 3D motion correction to work. These can either be specified directly under 'is3D': True
'indices': (slice(None), slice(None), slice(None)) # or other slices if you want, in Y, X, Z order
'max_shifts': (max_y, max_x, max_z) # (tuple of 3 ints, the default is (6, 6) for Y and X but you have to provide a value for Z)
# if you want to do piecewise motion correction...
'pw_rigid': True
'strides': (stride_y, stride_x, stride_z) # again because default is a 2-element tuple
'overlaps': (overlap_y, overlap_x, overlap_z) # ditto You should check the main CaImAn demo for more information about what the piecewise stride/overlap parameters do. Give it a try and let me know if you run into any problems. |
I've never run into that error, unfortunately. I looked through the code a bit and it seems like with border_nan = 'copy', it would be unlikely for the template to end up containing NaNs unless the input image had NaNs, but I could be missing something. You could either try to step through carefully with a debugger and see where you start getting NaNs, or ask on the main CaImAn discussion board (https://github.com/flatironinstitute/CaImAn/discussions) |
After installing mesmerize-core and mesmerize-vis I was able to run "mcorr_cnmf.ipynb" with the "Sue_2x_3000_40_-46.tif" example. However, when loading my own TIFF files, running caiman gives error at the step of "Computing correlation image". After playing around with the number of frames (t) in the "Sue_2x_3000_40_-46.tif" example, I discovered that the same type of error is encountered whenever there is frame < 500. (Note, changing "num_frames_split" in the mcorr_params1 based on what I can find online does not help with this issue)
Below is the error from caiman.run()

ring caiman.run()
Below is the traceback error for "Sue_2x_3000_40_-46.tif" with 499 frames:

This is my first time trying to analyze calcium imaging data and although the user guides and API have much technical information, I am unsure how to link them to biological data/interpretation. Is there any reason why the input images/movies must be >= 500 frames?
The text was updated successfully, but these errors were encountered: