diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b3bc394..88fe901c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +* Remove unecessary scipy import error handling [#315]((https://github.com/catalystneuro/roiextractors/pull/315) + # v0.5.8 ### Fixes @@ -14,6 +16,7 @@ * Updated zenodo to get a DOI on each release: No PR + # v0.5.7 ### Features diff --git a/src/roiextractors/extraction_tools.py b/src/roiextractors/extraction_tools.py index 6f8a5874..94012746 100644 --- a/src/roiextractors/extraction_tools.py +++ b/src/roiextractors/extraction_tools.py @@ -16,7 +16,6 @@ from platform import python_version import lazy_ops -import scipy import numpy as np from numpy.typing import ArrayLike, DTypeLike from tqdm import tqdm @@ -29,22 +28,7 @@ HAVE_H5 = True except ImportError: HAVE_H5 = False -try: - if hasattr(scipy.io.matlab, "mat_struct"): - from scipy.io.matlab import mat_struct - else: - from scipy.io.matlab.mio5_params import mat_struct - - HAVE_Scipy = True -except AttributeError: - if hasattr(scipy, "io") and hasattr(scipy.io.matlab, "mat_struct"): - from scipy.io import mat_struct - else: - from scipy.io.matlab.mio5_params import mat_struct - HAVE_Scipy = True -except ImportError: - HAVE_Scipy = False try: import zarr @@ -630,7 +614,8 @@ def check_keys(dict): AssertionError If scipy is not installed. """ - assert HAVE_Scipy, "To write to h5 you need to install scipy: pip install scipy" + from scipy.io.matlab.mio5_params import mat_struct + for key in dict: if isinstance(dict[key], mat_struct): dict[key] = todict(dict[key]) @@ -650,7 +635,11 @@ def todict(matobj): dict: dict Dictionary with mat-objects converted to nested dictionaries. """ + from scipy.io.matlab.mio5_params import mat_struct + dict = {} + from scipy.io.matlab.mio5_params import mat_struct + for strg in matobj._fieldnames: elem = matobj.__dict__[strg] if isinstance(elem, mat_struct):