denisecailab / minian

miniscope analysis pipeline with interactive visualizations
GNU General Public License v3.0
91 stars 35 forks source link

error loading new video #241

Open leodiej opened 1 year ago

leodiej commented 1 year ago

Hello, I am trying to perform the code with a tiff video. The file's name is "video conversion .tiff". Here is the code I ran and the error I get.

Set up Initial Basic Parameters

minian_path = "." dpath = "./inscopix_video/" minian_ds_path = os.path.join(dpath, "minian") intpath = "./fichier_intermediaire" subset = dict(frame=slice(0, None)) subset_mc = None interactive = True output_size = 100 n_workers = int(os.getenv("MINIAN_NWORKERS", 4)) param_save_minian = { "dpath": minian_ds_path, "meta_dict": dict(session=-1, animal=-2), "overwrite": True, }

Pre-processing Parameters

param_load_videos = { "pattern": "video conversion[0].tiff", "dtype": np.uint8, "downsample": dict(frame=1, height=1, width=1), "downsample_strategy": "subset", } param_denoise = {"method": "median", "ksize": 7} param_background_removal = {"method": "tophat", "wnd": 15}

Motion Correction Parameters

subset_mc = None param_estimate_motion = {"dim": "frame"}

Initialization Parameters

param_seeds_init = { "wnd_size": 1000, "method": "rolling", "stp_size": 500, "max_wnd": 15, "diff_thres": 3, } param_pnr_refine = {"noise_freq": 0.06, "thres": 1} param_ks_refine = {"sig": 0.05} param_seeds_merge = {"thres_dist": 10, "thres_corr": 0.8, "noise_freq": 0.06} param_initialize = {"thres_corr": 0.8, "wnd": 10, "noise_freq": 0.06} param_init_merge = {"thres_corr": 0.8}

CNMF Parameters

param_get_noise = {"noise_range": (0.06, 0.5)} param_first_spatial = { "dl_wnd": 10, "sparse_penal": 0.01, "size_thres": (25, None), } param_first_temporal = { "noise_freq": 0.06, "sparse_penal": 1, "p": 1, "add_lag": 20, "jac_thres": 0.2, } param_first_merge = {"thres_corr": 0.8} param_second_spatial = { "dl_wnd": 10, "sparse_penal": 0.01, "size_thres": (25, None), } param_second_temporal = { "noise_freq": 0.06, "sparse_penal": 1, "p": 1, "add_lag": 20, "jac_thres": 0.4, }

os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["fichier_intermediaire"] = intpath

The error is coming after this cell:

varr = load_videos(dpath, **param_loadvideos) chk, = get_optimal_chk(varr, dtype=float)

FileNotFoundError Traceback (most recent call last) Cell In[15], line 1 ----> 1 varr = load_videos(dpath, **param_loadvideos) 2 chk, = get_optimal_chk(varr, dtype=float)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:104, in load_videos(vpath, pattern, dtype, downsample, downsample_strategy, post_process) 100 vlist = natsorted( 101 [vpath + os.sep + v for v in os.listdir(vpath) if re.search(pattern, v)] 102 ) 103 if not vlist: --> 104 raise FileNotFoundError( 105 "No data with pattern {}" 106 " found in the specified folder {}".format(pattern, vpath) 107 ) 108 print("loading {} videos in folder {}".format(len(vlist), vpath)) 110 file_extension = os.path.splitext(vlist[0])[1]

FileNotFoundError: No data with pattern video conversion[0].tiff found in the specified folder C:\WINDOWS\system32\inscopix_video

leodiej commented 1 year ago

Maybe the video is too heavy? What is the maximum input video size that minian can support?

wmau commented 1 year ago

You did not correctly define the file name pattern. Try param_load_videos = { "pattern": "video conversion .tiff", "dtype": np.uint8, "downsample": dict(frame=1, height=1, width=1), "downsample_strategy": "subset", }

On Wed, May 3, 2023, 9:31 AM leodiej @.***> wrote:

Maybe the video is too heavy? What is the mawimum input video size that minian can support?

— Reply to this email directly, view it on GitHub https://github.com/denisecailab/minian/issues/241#issuecomment-1533036085, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4YH53UDUAX4KVE3MAUX3TXEJM3XANCNFSM6AAAAAAXUIDQ2E . You are receiving this because you are subscribed to this thread.Message ID: @.***>

leodiej commented 1 year ago

I changed it and I got an error too. If I limit the number of slices and put in line 5 : subset = dict(frame=slice(0, 499)) for example, would it work? I am thinking maybe the video is too heavy. It's a 35GB video.

wmau commented 1 year ago

Please always paste the full error in your message. It is difficult to diagnose without the error message.

On Wed, May 3, 2023, 9:48 AM leodiej @.***> wrote:

I changed it and I got an error too. If I limit the number of slices and put in line 5 : subset = dict(frame=slice(0, 499)) for example, would it work? I am thinking maybe the video is too heavy. It's a 35GB video.

— Reply to this email directly, view it on GitHub https://github.com/denisecailab/minian/issues/241#issuecomment-1533063539, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4YH555CIESLLV5BRVGW5DXEJO3RANCNFSM6AAAAAAXUIDQ2E . You are receiving this because you commented.Message ID: @.***>

leodiej commented 1 year ago

ValueError Traceback (most recent call last) Cell In[7], line 1 ----> 1 varr = load_videos(dpath, **param_loadvideos) 2 chk, = get_optimal_chk(varr, dtype=float)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:116, in load_videos(vpath, pattern, dtype, downsample, downsample_strategy, post_process) 114 movie_load_func = load_tif_lazy 115 else: --> 116 raise ValueError("Extension not supported.") 118 varr_list = [movie_load_func(v) for v in vlist] 119 varr = darr.concatenate(varr_list, axis=0)

ValueError: Extension not supported.

wmau commented 1 year ago

Try renaming your file extension to .tif instead of .tiff. Make sure to also change param_load_videos

On Wed, May 3, 2023, 10:06 AM leodiej @.***> wrote:

ValueError Traceback (most recent call last) Cell In[7], line 1 ----> 1 varr = load_videos(dpath, **param_loadvideos) 2 chk, = get_optimal_chk(varr, dtype=float)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:116, in load_videos(vpath, pattern, dtype, downsample, downsample_strategy, post_process) 114 movie_load_func = load_tif_lazy 115 else: --> 116 raise ValueError("Extension not supported.") 118 varr_list = [movie_load_func(v) for v in vlist] 119 varr = darr.concatenate(varr_list, axis=0)

ValueError: Extension not supported.

— Reply to this email directly, view it on GitHub https://github.com/denisecailab/minian/issues/241#issuecomment-1533091726, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4YH57ID65AVBJYE66UVR3XEJQ5LANCNFSM6AAAAAAXUIDQ2E . You are receiving this because you commented.Message ID: @.***>

wmau commented 1 year ago

It is also possible minian cannot support the BigTiff format so you may need a preprocessing step to divide up the file into smaller tifs.

On Wed, May 3, 2023, 10:22 AM William Mau @.***> wrote:

Try renaming your file extension to .tif instead of .tiff. Make sure to also change param_load_videos

On Wed, May 3, 2023, 10:06 AM leodiej @.***> wrote:

ValueError Traceback (most recent call last) Cell In[7], line 1 ----> 1 varr = load_videos(dpath, **param_loadvideos) 2 chk, = get_optimal_chk(varr, dtype=float)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:116, in load_videos(vpath, pattern, dtype, downsample, downsample_strategy, post_process) 114 movie_load_func = load_tif_lazy 115 else: --> 116 raise ValueError("Extension not supported.") 118 varr_list = [movie_load_func(v) for v in vlist] 119 varr = darr.concatenate(varr_list, axis=0)

ValueError: Extension not supported.

— Reply to this email directly, view it on GitHub https://github.com/denisecailab/minian/issues/241#issuecomment-1533091726, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4YH57ID65AVBJYE66UVR3XEJQ5LANCNFSM6AAAAAAXUIDQ2E . You are receiving this because you commented.Message ID: @.***>

leodiej commented 1 year ago

I renamed the file extension to .tif and apriori it works. Thank you for your help.

leodiej commented 1 year ago

Hi. I have get a problem with the video displaying. Then I tried to load an other one and still, "The extension is not suppported".

Set up Initial Basic Parameters

minian_path = "." dpath = "./inscopix/" minian_ds_path = os.path.join(dpath, "minian2") intpath = "./minian_intpath" subset = dict(frame=slice(0, None)) subset_mc = None interactive = True output_size = 100 n_workers = int(os.getenv("MINIAN_NWORKERS", 4)) param_save_minian = { "dpath": minian_ds_path, "meta_dict": dict(session=-1, animal=-2), "overwrite": True, }

Pre-processing Parameters

param_load_videos = { "pattern": "2021-08-10-13-39-53_video_trig_0.tif", "dtype": np.uint8, "downsample": dict(frame=1, height=1, width=1), "downsample_strategy": "subset", } param_denoise = {"method": "median", "ksize": 7} param_background_removal = {"method": "tophat", "wnd": 15}

Motion Correction Parameters

subset_mc = None param_estimate_motion = {"dim": "frame"}

Initialization Parameters

param_seeds_init = { "wnd_size": 1000, "method": "rolling", "stp_size": 500, "max_wnd": 15, "diff_thres": 3, } param_pnr_refine = {"noise_freq": 0.06, "thres": 1} param_ks_refine = {"sig": 0.05} param_seeds_merge = {"thres_dist": 10, "thres_corr": 0.8, "noise_freq": 0.06} param_initialize = {"thres_corr": 0.8, "wnd": 10, "noise_freq": 0.06} param_init_merge = {"thres_corr": 0.8}

CNMF Parameters

param_get_noise = {"noise_range": (0.06, 0.5)} param_first_spatial = { "dl_wnd": 10, "sparse_penal": 0.01, "size_thres": (25, None), } param_first_temporal = { "noise_freq": 0.06, "sparse_penal": 1, "p": 1, "add_lag": 20, "jac_thres": 0.2, } param_first_merge = {"thres_corr": 0.8} param_second_spatial = { "dl_wnd": 10, "sparse_penal": 0.01, "size_thres": (25, None), } param_second_temporal = { "noise_freq": 0.06, "sparse_penal": 1, "p": 1, "add_lag": 20, "jac_thres": 0.4, }

os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["MINIAN_INTPATH"] = intpath

varr = load_videos(dpath, **param_loadvideos) chk, = get_optimal_chk(varr, dtype=float)

KeyError Traceback (most recent call last) File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\tifffile\tifffile.py:3142, in TiffFile.init(self, arg, mode, name, offset, size, _multifile, _useframes, _parent, **kwargs) 3141 try: -> 3142 byteorder = {b'II': '<', b'MM': '>', b'EP': '<'}[header[:2]] 3143 except KeyError:

KeyError: b'\xa0\x00'

During handling of the above exception, another exception occurred:

TiffFileError Traceback (most recent call last) Cell In[7], line 1 ----> 1 varr = load_videos(dpath, **param_loadvideos) 2 chk, = get_optimal_chk(varr, dtype=float)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:118, in load_videos(vpath, pattern, dtype, downsample, downsample_strategy, post_process) 115 else: 116 raise ValueError("Extension not supported.") --> 118 varr_list = [movie_load_func(v) for v in vlist] 119 varr = darr.concatenate(varr_list, axis=0) 120 varr = xr.DataArray( 121 varr, 122 dims=["frame", "height", "width"], (...) 127 ), 128 )

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:118, in (.0) 115 else: 116 raise ValueError("Extension not supported.") --> 118 varr_list = [movie_load_func(v) for v in vlist] 119 varr = darr.concatenate(varr_list, axis=0) 120 varr = xr.DataArray( 121 varr, 122 dims=["frame", "height", "width"], (...) 127 ), 128 )

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\minian\utilities.py:161, in load_tif_lazy(fname) 147 def load_tif_lazy(fname: str) -> darr.array: 148 """ 149 Lazy load a tif stack of images. 150 (...) 159 Resulting dask array representation of the tif stack. 160 """ --> 161 data = TiffFile(fname) 162 f = len(data.pages) 164 fmread = da.delayed(load_tif_perframe)

File C:\ProgramData\Anaconda3\envs\minian2\lib\site-packages\tifffile\tifffile.py:3144, in TiffFile.init(self, arg, mode, name, offset, size, _multifile, _useframes, _parent, **kwargs) 3142 byteorder = {b'II': '<', b'MM': '>', b'EP': '<'}[header[:2]] 3143 except KeyError: -> 3144 raise TiffFileError(f'not a TIFF file {header!r}') 3146 version = struct.unpack(byteorder + 'H', header[2:4])[0] 3147 if version == 43: 3148 # BigTiff

TiffFileError: not a TIFF file b'\xa0\x00\xa0\n'