diff --git a/src/roiextractors/extractors/hdf5imagingextractor/hdf5imagingextractor.py b/src/roiextractors/extractors/hdf5imagingextractor/hdf5imagingextractor.py index 5113c928..ab53628b 100644 --- a/src/roiextractors/extractors/hdf5imagingextractor/hdf5imagingextractor.py +++ b/src/roiextractors/extractors/hdf5imagingextractor/hdf5imagingextractor.py @@ -1,4 +1,5 @@ from pathlib import Path +from warnings import warn import numpy as np @@ -39,10 +40,8 @@ def __init__( self.filepath = Path(file_path) self._sampling_frequency = sampling_frequency self._mov_field = mov_field - assert self.filepath.suffix in [ - ".h5", - ".hdf5", - ], "'file_path' file is not an .hdf5 or .h5 file" + if self.filepath.suffix not in [".h5", ".hdf5"]: + warn("'file_path' file is not an .hdf5 or .h5 file") self._channel_names = channel_names self._file = h5py.File(file_path, "r") diff --git a/src/roiextractors/extractors/sbximagingextractor/sbximagingextractor.py b/src/roiextractors/extractors/sbximagingextractor/sbximagingextractor.py index ecaa6a79..bb9eaf8b 100644 --- a/src/roiextractors/extractors/sbximagingextractor/sbximagingextractor.py +++ b/src/roiextractors/extractors/sbximagingextractor/sbximagingextractor.py @@ -1,5 +1,6 @@ import os from pathlib import Path +from warnings import warn import numpy as np @@ -47,7 +48,10 @@ def _check_file_path(file_path): file_path = Path(file_path) assertion_msg = "for file_path arg, provide a path to one .sbx / .mat file" file_type = file_path.suffix - assert file_type in [".mat", ".sbx"], assertion_msg + if file_type not in [".mat", ".sbx"]: + warn( + "File suffix ({file_type}) is not one of .mat or .sbx - the SbxImagingExtractor may not be appropriate!" + ) if file_type == ".mat": mat_file_path = file_path sbx_file_path = file_path.with_suffix(".sbx") diff --git a/src/roiextractors/extractors/tiffimagingextractors/tiffimagingextractor.py b/src/roiextractors/extractors/tiffimagingextractors/tiffimagingextractor.py index 80ed45be..d5398de0 100644 --- a/src/roiextractors/extractors/tiffimagingextractors/tiffimagingextractor.py +++ b/src/roiextractors/extractors/tiffimagingextractors/tiffimagingextractor.py @@ -1,5 +1,5 @@ from pathlib import Path -import warnings +from warnings import warn import numpy as np from tqdm import tqdm @@ -36,7 +36,11 @@ def __init__(self, file_path: PathType, sampling_frequency: FloatType): ImagingExtractor.__init__(self) self.file_path = Path(file_path) self._sampling_frequency = sampling_frequency - assert self.file_path.suffix in [".tiff", ".tif", ".TIFF", ".TIF"] + if self.file_path.suffix not in [".tiff", ".tif", ".TIFF", ".TIF"]: + warn( + "File suffix ({self.file_path.suffix}) is not one of .tiff, .tif, .TIFF, or .TIF! " + "The TiffImagingExtracto may not be appropriate." + ) with tifffile.TiffFile(self.file_path) as tif: self._num_channels = len(tif.series) @@ -44,7 +48,7 @@ def __init__(self, file_path: PathType, sampling_frequency: FloatType): try: self._video = tifffile.memmap(self.file_path, mode="r") except ValueError: - warnings.warn( + warn( "memmap of TIFF file could not be established. Reading entire matrix into memory. " "Consider using the ScanImageTiffExtractor for lazy data access." )