Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close issue 117 #315

Merged
merged 9 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Fixes

* Remove unecessary scipy import error handling [#315]((https://github.com/catalystneuro/roiextractors/pull/315)

# v0.5.8

### Fixes
Expand All @@ -14,6 +16,7 @@

* Updated zenodo to get a DOI on each release: No PR


# v0.5.7

### Features
Expand Down
23 changes: 6 additions & 17 deletions src/roiextractors/extraction_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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):
Expand Down
Loading