From 75b6e7e847ca99ff52ad27a608719cf4f8b5bafa Mon Sep 17 00:00:00 2001 From: "DESKTOP-I57LBN2\\Lae" Date: Wed, 8 Mar 2023 13:15:48 -0500 Subject: [PATCH 1/3] Fix copyfile_eeglab type conflicts --- doc/whats_new.rst | 1 + mne_bids/copyfiles.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/doc/whats_new.rst b/doc/whats_new.rst index cd08f31ac..c7ae42a7a 100644 --- a/doc/whats_new.rst +++ b/doc/whats_new.rst @@ -52,6 +52,7 @@ Detailed list of changes ^^^^^^^^^^^^ - Amending a dataset now works in cases where the newly-written data contains additional participant properties (new columns in ``participants.tsv``) not found in the existing dataset, by `Richard Höchenberger`_ (:gh:`1113`) +- Fixes :func:`~mne_bids.copyfiles.copyfile_eeglab` to prevent data type conversion leading to an ``eeg_checkset`` failure when trying to load the file in EEGLAB, by `Laetitia Fesselier`_ (:gh:`1122`) :doc:`Find out what was new in previous releases ` diff --git a/mne_bids/copyfiles.py b/mne_bids/copyfiles.py index 8da9b707e..49a14fc0e 100644 --- a/mne_bids/copyfiles.py +++ b/mne_bids/copyfiles.py @@ -564,6 +564,15 @@ def copyfile_eeglab(src, dest): new_value[0, 0] = np.atleast_1d(np.array(tail)) eeg['data'] = new_value + # Make sure all values are saved as float + # (see https://github.com/mne-tools/mne-bids/issues/1122) + eeg['nbchan'] = float(eeg['nbchan']) + eeg['pnts'] = float(eeg['pnts']) + eeg['trials'] = float(eeg['trials']) + eeg['srate'] = float(eeg['srate']) + eeg['xmin'] = float(eeg['xmin']) + eeg['xmax'] = float(eeg['xmax']) + # Save the EEG dictionary as a Matlab struct again mdict = dict(EEG=eeg) if oldstyle else eeg savemat(file_name=dest, mdict=mdict, appendmat=False) From ce70f52cef90c0ac05de78258dd8dae94d70748a Mon Sep 17 00:00:00 2001 From: "DESKTOP-I57LBN2\\Lae" Date: Wed, 8 Mar 2023 14:57:12 -0500 Subject: [PATCH 2/3] Alternative solution using loadmat option mat_dtype --- mne_bids/copyfiles.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mne_bids/copyfiles.py b/mne_bids/copyfiles.py index 49a14fc0e..ed11eefed 100644 --- a/mne_bids/copyfiles.py +++ b/mne_bids/copyfiles.py @@ -533,18 +533,19 @@ def copyfile_eeglab(src, dest): # structure and potentially breaks re-reading of the file uint16_codec = None eeg = loadmat(file_name=src, simplify_cells=False, - appendmat=False, uint16_codec=uint16_codec) + appendmat=False, uint16_codec=uint16_codec, mat_dtype=True) oldstyle = False if 'EEG' in eeg: eeg = eeg['EEG'] oldstyle = True + has_fdt_link = False try: # If the data field is a string, it points to a .fdt file in src dir if isinstance(eeg['data'][0, 0][0], str): has_fdt_link = True except IndexError: - has_fdt_link = False + pass if has_fdt_link: fdt_fname = eeg['data'][0, 0][0] @@ -564,15 +565,6 @@ def copyfile_eeglab(src, dest): new_value[0, 0] = np.atleast_1d(np.array(tail)) eeg['data'] = new_value - # Make sure all values are saved as float - # (see https://github.com/mne-tools/mne-bids/issues/1122) - eeg['nbchan'] = float(eeg['nbchan']) - eeg['pnts'] = float(eeg['pnts']) - eeg['trials'] = float(eeg['trials']) - eeg['srate'] = float(eeg['srate']) - eeg['xmin'] = float(eeg['xmin']) - eeg['xmax'] = float(eeg['xmax']) - # Save the EEG dictionary as a Matlab struct again mdict = dict(EEG=eeg) if oldstyle else eeg savemat(file_name=dest, mdict=mdict, appendmat=False) From 074ea184fe45a7a81963576808ba2e739d1329ad Mon Sep 17 00:00:00 2001 From: "DESKTOP-I57LBN2\\Lae" Date: Wed, 8 Mar 2023 16:39:35 -0500 Subject: [PATCH 3/3] Authors/citation updates --- CITATION.cff | 3 +++ doc/authors.rst | 1 + 2 files changed, 4 insertions(+) diff --git a/CITATION.cff b/CITATION.cff index d0ad70af0..0effc3793 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -155,6 +155,9 @@ authors: family-names: Gerster affiliation: 'Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Germany' orcid: 'https://orcid.org/0000-0001-9343-6986' + - given-names: Fesselier + family-names: Laetitia + affiliation: 'McGill Centre for Integrative Neuroscience, McGill University, Montreal, Canada' - given-names: Alexandre family-names: Gramfort affiliation: 'Université Paris-Saclay, Inria, CEA, Palaiseau, France' diff --git a/doc/authors.rst b/doc/authors.rst index c9d454e88..4a046d1ae 100644 --- a/doc/authors.rst +++ b/doc/authors.rst @@ -40,3 +40,4 @@ .. _Bruno Hebling Vieira: https://bhvieira.github.io/ .. _Daniel McCloy: http://dan.mccloy.info .. _Moritz Gerster: http://moritz-gerster.com +.. _Laetitia Fesselier: https://github.com/laemtl