Closed jchutrue closed 3 years ago
@jchutrue are you sure there is not a dramatic change in the appearance in the field of view between the first and last movie? This might cause an issue similar to what you describe.
@agiovann There is a noticeable rotation between the FOVs of the first and last movie.
You can try to motion correct each file separately, calculate the shifts between the templates of each file, and align the files with each other. The latter can be done by either calculating total_shifts=in_session_shifts+between_session_shifts
and applying the total_shifts
to the raw data, or by applying between_session_shifts
to the separately motion corrected data.
See issue #871 and this notebook. While it didn't seem to help in the notebook, it might help with your data.
Because you observe a noticeable rotation you'd need to use non-rigid (i.e. piece-wise rigid) instead of the simple rigid registration i used in the notebook.
Tell us a bit about your setup:
Operating system (Linux/macOS/Windows): Ubuntu Linux 19.04
Python version (3.x): 3.7
Working environment (Python IDE/Jupyter Notebook/other): Jupyter Notebook
Which of the demo scripts you're using for your analysis (if applicable): N/A
CaImAn version*: 1.8.5 (
dev
branch commit f92f96296b325fecf182f0a5d571a59a52868252)CaImAn installation process (
pip install .
/pip install -e .
/conda):pip install -e .
*You can get the CaImAn version by creating a
params
object and then typingparams.data['caiman_version']
. If the field doesn't exist, type N/A and consider upgrading)I have 40+ video files that when concatenated together would form a continuous dataset (total of 16.6 GB). When I
cm.save_memmap()
, thencm.save_memmap_join()
and run motion correction on the single concatenated file, the motion correction fails, with some very large shifts/jumps between consecutive frames. When I motion correct each of the files individually, using exactly the same parameters, I do not observe this problem. This effect was observed with both rigid and piecewise rigid motion correction.The reason I do motion correction on the large concatenated file is because I want to run CNMF-E afterwards. If I run CNMF-E for each file, some neurons are merged when they shouldn't be. This is because those neurons are spatially close and sometimes fire at similar times during synchronous events. However with more data, it becomes clear that those neurons are indeed separate.
Finally, even for one video file the motion correction does not seem to correct slight rotations in the FOV well, so the subsequent CNMF-E thinks there are two overlapping neurons rather than one.