You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: concatenate_epochs can be more memory efficient #6758
I was trying to concatenate 2 epochs with mne.concatenate_epochs, but python return memory error related to numpy array.
Last_epochs_standard = mne.concatenate_epochs([epochs1,epochs2])
Loading data for 33684 events and 1688 original time points ...
Loading data for 47154 events and 1688 original time points ...
Traceback (most recent call last):
File "", line 1, in
File "/home/wvxxxx/anaconda3/envs/Nex/lib/python3.7/site-packages/mne/epochs.py", line 2723, in concatenate_epochs
add_offset=add_offset))
File "/home/wvxxxx/anaconda3/envs/Nex/lib/python3.7/site-packages/mne/epochs.py", line 2683, in _concatenate_epochs
data = np.concatenate(data, axis=0)
File "<array_function internals>", line 6, in concatenate
MemoryError: Unable to allocate array with shape (80838, 32, 1688) and data type float64
The data size is the problem with mne.concatenate. Does it have another way to proceed ?
Added this to #6380 so that we can keep track of the places we want to add preload=str support in one place, closing this (but feel free to continue discussion)
Ahh, it's probably then because our code does (effectively) epochs.get_data() and then allocates then assigns. We can probably make this a bit more efficient by iterating over the two epochs objects rather than calling get_data (which is probably what we do) so that only one epoch per time ends up in memory. This will also only work if we know len(epochs) ahead of time, which is an additional complication (for non-preloaded ones we'll need to call drop_bad on both then iterate) but could be workable.
Activity
agramfort commentedon Sep 12, 2019
larsoner commentedon Sep 12, 2019
Added this to #6380 so that we can keep track of the places we want to add
preload=strsupport in one place, closing this (but feel free to continue discussion)WilliamLabCea commentedon Sep 12, 2019
Not really. I have 63Gio in my actual computer. Each epoch data are not greater than 8go size.
larsoner commentedon Sep 12, 2019
On disk they are stored in single precision (4 bytes) but in memory they are stored as double (8 bytes). So:
And if each is preloaded to begin with, you have to double this requirement (> 64 GB).
WilliamLabCea commentedon Sep 12, 2019
I read already data with preload=False.
larsoner commentedon Sep 12, 2019
Ahh, it's probably then because our code does (effectively)
epochs.get_data()and then allocates then assigns. We can probably make this a bit more efficient by iterating over the twoepochsobjects rather than callingget_data(which is probably what we do) so that only one epoch per time ends up in memory. This will also only work if we knowlen(epochs)ahead of time, which is an additional complication (for non-preloaded ones we'll need to calldrop_badon both then iterate) but could be workable.[-]MemoryError / mne.concatenate[/-][+]ENH: concatenate_epochs can be more memory efficient[/+]larsoner commentedon Sep 1, 2020
@WilliamLabCea #8185 should hopefully fix this