Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 3, 2025
1 parent b6871cc commit ba9a9a8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 11 deletions.
73 changes: 67 additions & 6 deletions mne/io/eeglab/_eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,80 @@ def _readmat(fname, uint16_codec=None, preload=False):
fname, squeeze_me=True, mat_dtype=False, uint16_codec=uint16_codec
)
else:
info_fields = ['setname', 'filename', 'filepath', 'subject', 'group', 'condition', 'session', 'comments', 'nbchan', 'trials', 'pnts', 'srate', 'xmin', 'xmax', 'times', 'icaact', 'icawinv', 'icasphere', 'icaweights', 'icachansind', 'chanlocs', 'urchanlocs', 'chaninfo', 'ref', 'event', 'urevent', 'eventdescription', 'epoch', 'epochdescription', 'reject', 'stats', 'specdata', 'specicaact', 'splinefile', 'icasplinefile', 'dipfit', 'history', 'saved', 'etc']
info_fields = [
"setname",
"filename",
"filepath",
"subject",
"group",
"condition",
"session",
"comments",
"nbchan",
"trials",
"pnts",
"srate",
"xmin",
"xmax",
"times",
"icaact",
"icawinv",
"icasphere",
"icaweights",
"icachansind",
"chanlocs",
"urchanlocs",
"chaninfo",
"ref",
"event",
"urevent",
"eventdescription",
"epoch",
"epochdescription",
"reject",
"stats",
"specdata",
"specicaact",
"splinefile",
"icasplinefile",
"dipfit",
"history",
"saved",
"etc",
]
eeg = loadmat(
fname, variable_names=info_fields, squeeze_me=True, mat_dtype=False, uint16_codec=uint16_codec
fname,
variable_names=info_fields,
squeeze_me=True,
mat_dtype=False,
uint16_codec=uint16_codec,
)
variables = whosmat(str(fname))
for var in variables:
if var[0] == 'data':
numeric_types = ['int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'single', 'double']
if var[0] == "data":
numeric_types = [
"int8",
"int16",
"int32",
"int64",
"uint8",
"uint16",
"uint32",
"uint64",
"single",
"double",
]
if var[2] in numeric_types:
# in preload=False mode and data is in .set file
eeg['data'] = str(fname)
eeg["data"] = str(fname)
else:
eeg['data'] = loadmat(fname, variable_names=['data'], squeeze_me=True, mat_dtype=False, uint16_codec=uint16_codec)
eeg["data"] = loadmat(
fname,
variable_names=["data"],
squeeze_me=True,
mat_dtype=False,
uint16_codec=uint16_codec,
)
break
return _check_for_scipy_mat_struct(eeg)
else:
Expand Down
8 changes: 3 additions & 5 deletions mne/io/eeglab/eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
def _check_eeglab_fname(fname, dataname):
"""Check whether the filename is valid.
Check if the file extension is ``.fdt`` (older ``.dat`` being invalid)
or ``.set`` (new EEGLAB format) or whether the ``EEG.data`` filename exists.
Check if the file extension is ``.fdt`` (older ``.dat`` being invalid)
or ``.set`` (new EEGLAB format) or whether the ``EEG.data`` filename exists.
If ``EEG.data`` file is absent the set file name with .set changed to .fdt is checked.
"""
fmt = str(op.splitext(dataname)[-1])
Expand All @@ -50,9 +50,7 @@ def _check_eeglab_fname(fname, dataname):
"version and resave the data in .fdt format"
)
if fmt != ".set" and fmt != ".fdt":
raise ValueError(
"The file extension must be .set or .fdt, not {}".format(fmt)
)
raise ValueError(f"The file extension must be .set or .fdt, not {fmt}")
basedir = op.dirname(fname)
data_fname = op.join(basedir, dataname)
if not op.exists(data_fname):
Expand Down

0 comments on commit ba9a9a8

Please sign in to comment.