From ba9a9a835c810fb37f172b08b1800027511a7498 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 14:43:49 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eeglab/_eeglab.py | 73 ++++++++++++++++++++++++++++++++++++---- mne/io/eeglab/eeglab.py | 8 ++--- 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/mne/io/eeglab/_eeglab.py b/mne/io/eeglab/_eeglab.py index d32f47446a1..682793bde6c 100644 --- a/mne/io/eeglab/_eeglab.py +++ b/mne/io/eeglab/_eeglab.py @@ -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: diff --git a/mne/io/eeglab/eeglab.py b/mne/io/eeglab/eeglab.py index 9a883493a16..32b0dd912bb 100644 --- a/mne/io/eeglab/eeglab.py +++ b/mne/io/eeglab/eeglab.py @@ -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]) @@ -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):