Zimmer-lab / imutils

Fork of Ulises' imutils repository. This is the main one the lab should use
0 stars 5 forks source link

Can this read 4d data? (t, z, x, y) #5

Closed Charles-Fieseler-Vienna closed 4 months ago

Charles-Fieseler-Vienna commented 5 months ago

https://github.com/Zimmer-lab/imutils/blob/9447babe0039f8080c50bce771f3ba75d7682820/scopereader/microscope_data_reader.py#L179

Charles-Fieseler-Vienna commented 5 months ago

I tried it with an old bigtiff file, but for this one it fails... message below

Charles-Fieseler-Vienna commented 5 months ago

2024-04-22 15:00:36.712 | INFO | scopereader.microscope_data_reader:_read_raw_tifffile:171 - Reading data from /lisc/scratch/neurobiology/zimmer/wbfm/example_data/ZIM2165_Gcamp7b_worm1/2022-11-27_15-14_ZIM2165_worm1_GC7b_Ch0 with tifffile 2024-04-22 15:00:36.776 | ERROR | scopereader.microscope_data_reader:_read_raw_tifffile:179 - Expected 3D data [t,y,x], got 4D data


ValueError Traceback (most recent call last) Cell In [21], line 1 ----> 1 dat2 = MicroscopeDataReader(fname, as_raw_tiff=True, raw_tiff_num_slices=22)

File ~/Current_work/repos/imutils/scopereader/microscope_data_reader.py:48, in MicroscopeDataReader.init(self, path, force_tifffile, as_raw_tiff, raw_tiff_num_slices) 46 self._data_store = None 47 if as_raw_tiff: ---> 48 self._read_raw_tifffile() 49 else: 50 self._open_dataset()

File ~/Current_work/repos/imutils/scopereader/microscope_data_reader.py:180, in MicroscopeDataReader._read_raw_tifffile(self) 178 if not len(dask_array.shape) == 3: 179 self.logger.error(f"Expected 3D data [t,y,x], got {len(dask_array.shape)}D data") --> 180 raise ValueError(f"Expected 3D data [t,y,x], got {len(dask_array.shape)}D data") 181 if self._raw_tiff_num_slices is None: 182 self.logger.warning(f"Number of slices in raw tiff file is not specified")

ValueError: Expected 3D data [t,y,x], got 4D data

Charles-Fieseler-Vienna commented 5 months ago

Specific file: /lisc/scratch/neurobiology/zimmer/wbfm/example_data/ZIM2165_Gcamp7b_worm1/2022-11-27_15-14_ZIM2165_worm1_GC7b_Ch0/raw_Ch0bigtiff.btf

Charles-Fieseler-Vienna commented 5 months ago

Other options don't work, because the shape as loaded from disk is 4d, not 5d or 3d... so reshaping fails Raw shape: Shape (15, 22, 650, 900)

Charles-Fieseler-Vienna commented 5 months ago

I think the cause is that this is a small bigtiff, so I guess the shape metadata was properly saved, but is not the same as the original size somehow.

Charles-Fieseler-Vienna commented 4 months ago

Closed by ignoring shaped metadata