MouseLand / suite2p

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

Multi channel ome.tif files as input - data shuffled between channels #1049

Open bdudok opened 9 months ago

bdudok commented 9 months ago

Describe the issue:

I have a movie with single plane, dual channel, multi-page tif files from Bruker. My goal is to register both channels in the movie using one of the channels as reference. Bruker chops up the output into files with no more than 5000 frames. The file names are: movie_000-000_Cycle00001_Ch1_000001.ome.tif (Ch1, first chunk) movie_000-000_Cycle00001_Ch1_000002.ome.tif (Ch1, second chunk) movie_000-000_Cycle00001_Ch2_000001.ome.tif (Ch2, first chunk) movie_000-000_Cycle00001_Ch2_000002.ome.tif (Ch2, second chunk)

I can not find a way to correctly read this dataset for registration. I have tried setting ops['input_format'] = 'bruker', this results in errors as I believe this expects single-page tifs.

With the ops below, the registration runs without errors, however, the output files contain chunks of data from both channels (CH1), or zeros (Ch2). Oddly, the previews in output_ops are identical and look like Ch2 (output_ops['meanImg'], output_ops['meanImg_chan2']).

Is there a way to specify correct reading of this type of input?

Attached are images of what's seen in each output binary. projection of raw movies by ImageJ

chunks in data_chan2 bin chunks in data_chan2_raw bin chunks in data_raw bin First 100 frames of each file chunks in data bin

Reproduce the code example:

I cannot provide a self contained example without the input data. These are my ops.

ops['batch_size'] = 5000
ops['do_bidiphase'] = True #whether or not to compute bidirectional phase offset
ops['bidi_corrected'] = True #Specifies whether to do bidi correction
ops['nonrigid'] = True
ops['block_size']  = [512, 16] #power of 2 and/or 3 (e.g. 128, 256, 384, etc)
ops['keep_movie_raw'] = True
ops['two_step_registration'] = True #run registration twice
ops['reg_tif'] = True #write the registered binary to tiff files
ops['reg_tif_chan2'] = True #write the registered binary to tiff files
ops['delete_bin'] = False

ops['nchannels'] = 2
ops['align_by_chan'] = 1

ops['data_path']: [dpath, ]
ops['tiff_list']: filelist #with list of all 4 tifs

ops['roidetect'] = False
ops['neuropil_extract'] = False
ops['spikedetect'] = False

Error message:

This is the full console log. The warnings are likely because one of the output movies consists of zeros.
{'fs': 19.999998400000127, 'data_path': ['D:\\Shares\\Data\\_RawData\\Bruker\\SncgTot\\SncgTot4_2023-10-23_movie_000-000/'], 'tiff_list': ['SncgTot4_2023-10-23_movie_000-000_Cycle00001_Ch1_000001.ome.tif', 'SncgTot4_2023-10-23_movie_000-000_Cycle00001_Ch1_000002.ome.tif', 'SncgTot4_2023-10-23_movie_000-000_Cycle00001_Ch2_000001.ome.tif', 'SncgTot4_2023-10-23_movie_000-000_Cycle00001_Ch2_000002.ome.tif'], 'save_path0': 'D:\\Shares\\Data\\_Processed/2P/SncgTot/SncgTot4_2023-10-23_movie_000/'}
tif
** Found 4 tifs - converting to binary **
time 56.91 sec. Wrote 6509 frames per binary for 1 planes
 PLANE 0 <<<<<<<<<<<<<<<<<<<<<<
NOTE: not registered / registration forced with ops['do_registration']>1
      (no previous offsets to delete)
NOTE: applying default C:\Users\u247640\.suite2p\classifiers\classifier_user.npy
----------- REGISTRATION
Reference frame, 12.79 sec.
Registered 5000/6507 in 97.64s
Registered 6507/6507 in 124.75s
bad frames file path: D:\Shares\Data\_RawData\Bruker\SncgTot\SncgTot4_2023-10-23_movie_000-000\bad_frames.npy
number of badframes: 150
----------- Total 149.44 sec
----------- REGISTRATION STEP 2
(making mean image (excluding bad frames)
registering two channels
Registered 5000/10000 in 86.57s
Registered 10000/10000 in 177.25s
Second channel, Registered 5000/10000 in 32.14s
Second channel, Registered 10000/10000 in 65.19s
bad frames file path: D:\Shares\Data\_RawData\Bruker\SncgTot\SncgTot4_2023-10-23_movie_000-000\bad_frames.npy
number of badframes: 150
----------- Total 393.37 sec
C:\Users\u247640\AppData\Local\anaconda3\envs\suite2p\lib\site-packages\sklearn\decomposition\_pca.py:640: RuntimeWarning: divide by zero encountered in divide
  self.explained_variance_ratio_ = self.explained_variance_ / total_var
C:\Users\u247640\AppData\Local\anaconda3\envs\suite2p\lib\site-packages\sklearn\decomposition\_pca.py:640: RuntimeWarning: invalid value encountered in divide
  self.explained_variance_ratio_ = self.explained_variance_ / total_var
Registration metrics, 28.04 sec.
WARNING: skipping cell detection (ops['roidetect']=False)
Plane 0 processed in 421.50 sec (can open in GUI).
total = 479.78 sec.
TOTAL RUNTIME 479.78 sec

Version information:

suite2p v0.14.2

Context for the issue:

No response