MouseLand / suite2p

cell detection in calcium imaging recordings
http://www.suite2p.org
GNU General Public License v3.0
348 stars 240 forks source link

Tiff ValueError: the total number of frames should be at least 50. RAW to TIFF conversion in Fiji #1095

Closed rsymzk closed 7 months ago

rsymzk commented 7 months ago

Hi,

I am still in the middle of learning curve of suite2p and 2P. I'm using suite2p GUI version that I downloaded from Github in 2023.

I've read some silimar issue threads below but couldn't make my own problem work. https://github.com/MouseLand/suite2p/issues/135 https://github.com/MouseLand/suite2p/issues/210 https://github.com/MouseLand/suite2p/issues/891

I use ThorImage for recording and I used to save as TIFF (which ThorImage record originally as RAW and converts into TIFF at the end of the experiment), but due to unknown reason, this doesn't work for recordings that exceeds 65536 (2^16). I talked to ThorLab and they suggested to save as RAW and convert it manually into TIFF afterwards.

On Fiji, I open the RAW file by Import > RAW > 16bit-Unsigned, with little-endian byte order (which was explained in ThorImage's manual) then I saved this as TIFF. At least on FIJI, I can see TIFF with everything looks same as RAW (frame number is the same as well).

But when I run it with Suite2p, I keep getting this error below:

Found 1 tifs - converting to binary time 0.13 sec. Wrote 1 frames per binary for 1 planes PLANE 0 <<<<<<<<<<<<<<<<<<<<<< ERROR<<< Traceback (most recent call last): File "/home/user/anaconda3/envs/suite2p/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/user/anaconda3/envs/suite2p/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/user/anaconda3/envs/suite2p/lib/python3.9/site-packages/suite2p/main.py", line 84, in main() File "/home/user/anaconda3/envs/suite2p/lib/python3.9/site-packages/suite2p/main.py", line 77, in main run_s2p(ops, db) File "/home/user/anaconda3/envs/suite2p/lib/python3.9/site-packages/suite2p/run_s2p.py", line 521, in run_s2p op = run_plane(op, ops_path=ops_path) File "/home/user/anaconda3/envs/suite2p/lib/python3.9/site-packages/suite2p/run_s2p.py", line 284, in run_plane raise ValueError("the total number of frames should be at least 50.") ValueError: the total number of frames should be at least 50. Interrupted by error (not finished)

This TIFF file has a stack of 65000 images(frames). Only one Z plane for now. There's no compression tag so I think it's uncompressed TIFF. I compared the shape of file between this (RAW to TIFF manual conversion) and one that worked in suite2p (originally saved as TIFF in ThorImage) but there's no difference.

It's highly likely that the problem emerged during the conversion in FIJI...but no luck on other ways so far.

Question to anyone: Does anybody know how to successfully convert RAW to TIFF that suite2p can read ? Question to developpers: Would it be possible to add RAW file as an input file format ? --- If it can be done, it will be the best since my frame numbers are pretty big (up to 120000) and it will make it way easier if I don't need to convert it to another big file...

Thank you.

sstaszko commented 5 months ago

Hi @rsymzk were you able to resolve this? I am getting the same error after converting files in FIJI.

rsymzk commented 5 months ago

Hi,

As someone mentioned in one of the threads above, it is apprently due to the file size. i.e. when the file size is bigger than 4GB, for some reason Fiji only saves first frame and do something strange (?) to the rest, that's why suite2p gets confused. I think. (I think when I checked the shape of the file in Python, it returned "correct" values, so I'm not totally sure what's going on)

I believe there is a page explaining about the 4GB rule (?) in Fiji - just can't remember now, but I just googled it.

Long story short, recently I chop the original file (mine is RAW file) into pieces, each is less than 4GB, then convert to TIFF in FIJI, (just "save as"), then feed them into suite2p. I do the chopping in Python. I'm thinking to automate this file conversion step since it's tidious but so far that's how I hundle.

Wish RAW file is one of the formats suite2p can take...

Hope it helps !