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

motion correction breaks when tif file carries channel data #1393

Open
ashwin-miriyala opened this issue Aug 21, 2024 · 2 comments
Open

motion correction breaks when tif file carries channel data #1393

ashwin-miriyala opened this issue Aug 21, 2024 · 2 comments

Comments

@ashwin-miriyala
Copy link

ashwin-miriyala commented Aug 21, 2024

Please fill in the following for any issues

Your setup:

  1. Operating System (Linux, MacOS, Windows): Windows
  2. Hardware type (x86, ARM..) and RAM: x86
  3. Python Version (e.g. 3.9): 3.10.8
  4. Caiman version (e.g. 1.9.12): 1.9.14
  5. Which demo exhibits the problem (if applicable):
  6. How you installed Caiman (pure conda, conda + compile, colab, ..): conda
  7. Details:

Using scanimage, I have recorded a tif file that carries frames from 2 channels. These frames are interleaved, i.e. channel 1 is on odd frames and channel 2 is on even frames in the tif file.
I thought I would run motion correction on the entire tif file and then worry about de-interleaving afterwards. However, while running motion correction, there is a step where the shape of the tiff file is read, and it doesn't account for the extra dimention that mentions the number of channels. I've found an example of where this occurs (in utilities.py):

dims, T = cm.source_extraction.cnmf.utilities.get_file_size(fname, var_name_hdf5=var_name_hdf5)

within this definition 'get_file_size'...
...
if extension in ['.tif', '.tiff', '.btf']:
tffl = tifffile.TiffFile(file_name)
siz = tffl.series[0].shape
# tiff files written in append mode
if len(siz) < 3:
dims = siz
T = len(tffl.pages)
else:
T, dims = siz[0], siz[1:]

Here, my tif file returns dimensions (2056,2,256,256). If there was only one channel during acquisition, the size would be (2056,256,256). I'm not sure if this problem stems from the tifffile class or the scanimage software that saves the tif file.

While a workaround would be simple for this particular definition, I'm not sure how many other definitions I'd need to update. Do you think this is a valid problem? Or should I deinterleave and make sure of only 1 channel per tif file and appropriate dimensions before running motion correction?

Thanks!

@pgunn
Copy link
Member

pgunn commented Aug 31, 2024

Hello,
Right now I think the easiest route would be for you to preprocess the data to remove the extra dimension; I don't think we've ever run into someone doing things they way you describe before, and adding code to support too many data layout variations would make things hard to maintain.

@kushalkolar
Copy link
Collaborator

Yea scanimage does bizarre things, IIRC it does that if the acquisition was stopped midway, if all frames that were set to be recorded were not recorded it just leave the tiff file like that there.
Anyways, as Pat said you have to save them to two separate files.

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

3 participants