diff --git a/hmp/io/mne_epochs.py b/hmp/io/mne_epochs.py index 395c1b7d..2f9ce6d1 100644 --- a/hmp/io/mne_epochs.py +++ b/hmp/io/mne_epochs.py @@ -109,28 +109,32 @@ def read_mne_epochs( ], ) - epoch_data = [ - utils.hmp_data_format( - epochs.get_data(copy=False).astype(dtype), - epochs.info['sfreq'], - epochs.tmin, - epochs.tmax, - epochs=[int(x) for x in valid_epoch_index], - channel=epochs.ch_names, - metadata=epochs.metadata, - ) - for epochs, valid_epoch_index in epochs_list - ] - # Recover info from first epochs object info = epochs_list[0][0].info final_prep_kwargs = deepcopy(preprocessing_kwargs) final_prep_kwargs['sfreq'] = epochs_list[0][0].info['sfreq'] final_prep_kwargs['lowpass'] = epochs_list[0][0].info['lowpass'] final_prep_kwargs['highpass'] = epochs_list[0][0].info['highpass'] + + epoch_data = [] + while epochs_list: + epochs, valid_epoch_index = epochs_list.pop(0) + epoch_data.append( + utils.hmp_data_format( + epochs.get_data(copy=False).astype(dtype), + epochs.info['sfreq'], + epochs.tmin, + epochs.tmax, + epochs=[int(x) for x in valid_epoch_index], + channel=epochs.ch_names, + metadata=epochs.metadata, + ) + ) + del epochs, valid_epoch_index + + epoch_data = utils._concat_recordings(epoch_data, recordings, {}, final_prep_kwargs, subj_name) - return epoch_data, info def _process_epoch_dataset(recording, montage, verbose,