Skip to content

Commit

Permalink
Fix copyfile_eeglab type conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Mar 8, 2023
1 parent 0b1a61d commit 75b6e7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <whats_new_previous_releases>`

Expand Down
9 changes: 9 additions & 0 deletions mne_bids/copyfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 75b6e7e

Please sign in to comment.