Skip to content

Commit

Permalink
STY: black [ignore-rev]
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 31, 2024
1 parent b330385 commit bd0d585
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,24 +934,32 @@ def indirectory(path):
finally:
os.chdir(cwd)


def load_spm_mat(spm_mat_file, **kwargs):
try:
mat = sio.loadmat(spm_mat_file, **kwargs)
except NotImplementedError:
import h5py
import numpy as np

mat = dict(SPM=np.array([[sio.matlab.mat_struct()]]))

# Get Vbeta, Vcon, and Vspm file names
with h5py.File(spm_mat_file, "r") as h5file:
fnames = dict()
try:
fnames["Vbeta"] = [u"".join(chr(c[0]) for c in h5file[obj_ref[0]]) for obj_ref in h5file["SPM"]["Vbeta"]["fname"]]
fnames["Vbeta"] = [
u"".join(chr(c[0]) for c in h5file[obj_ref[0]])
for obj_ref in h5file["SPM"]["Vbeta"]["fname"]
]
except Exception:
fnames["Vbeta"] = []
for contr_type in ["Vcon", "Vspm"]:
try:
fnames[contr_type] = [u"".join(chr(c[0]) for c in h5file[obj_ref[0]]["fname"]) for obj_ref in h5file["SPM"]["xCon"][contr_type]]
fnames[contr_type] = [
u"".join(chr(c[0]) for c in h5file[obj_ref[0]]["fname"])
for obj_ref in h5file["SPM"]["xCon"][contr_type]
]
except Exception:
fnames[contr_type] = []

Expand Down Expand Up @@ -980,4 +988,4 @@ def load_spm_mat(spm_mat_file, **kwargs):
else:
setattr(mat["SPM"][0, 0], "xCon", np.empty((0, 0), dtype=object))

return mat
return mat

0 comments on commit bd0d585

Please sign in to comment.