When replicating the tutorial (mne_inverse_coherence_epoch) using custom data which is accessable via this link, the compiler throw MemoryError.
`
numpy.core._exceptions.MemoryError: Unable to allocate 206. GiB for an array with shape (209786886, 66) and data type complex128
`
I suspect this is due to the wide frequency range,considered
fmin = (8., 13.)
fmax = (13., 30.)
When limited the frequency to
fmin = (8.)
fmax = (13.)
The compiler return the following
MemoryError
May I know the standard practice or how to address this issue?
The data and code to reproduce the above issue give below,
Link to epochs-fif: https://drive.google.com/file/d/1pkFNJDInIL2ipvaBv7ftqTPFQ9p10pkA/view?usp=sharing
import mne
import os.path as op
from mne.datasets import fetch_fsaverage
from mne.connectivity import spectral_connectivity
from mne.minimum_norm import (apply_inverse_epochs,)
# Download fsaverage files
fs_dir = fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)
# The files live in:
subject = 'fsaverage'
trans = 'fsaverage' # MNE has a built-in fsaverage transformation
src = op.join(fs_dir, 'bem', 'fsaverage-ico-5-src.fif')
bem = op.join(fs_dir, 'bem', 'fsaverage-5120-5120-5120-bem-sol.fif')
epochs = mne.read_epochs ( 'test_data-epo.fif', preload=True )
cov = mne.compute_covariance(epochs, tmax=0.)
evoked = epochs['251'].average()
# evoked.plot_joint()
fwd = mne.make_forward_solution(epochs.info, trans=trans, src=src,
bem=bem, eeg=True, mindist=5.0, n_jobs=-1)
inv = mne.minimum_norm.make_inverse_operator(evoked.info, fwd, cov, verbose=True)
method = "dSPM" # use dSPM method (could also be MNE or sLORETA)
# Compute the inverse solution for each epoch.
snr = 1.0 # use lower SNR for single epochs
lambda2 = 1.0 / snr ** 2
stcs = apply_inverse_epochs(epochs, inv, lambda2, method,
pick_ori="normal", return_generator=True)
# Compute the coherence between sources
# fmin = (8., 13.)
# fmax = (13., 30.)
fmin = (8.)
fmax = (13.)
sfreq = epochs.info['sfreq'] # the sampling frequency
coh, freqs, times, n_epochs, n_tapers = spectral_connectivity(
stcs, method='coh', mode='fourier',
sfreq=sfreq, fmin=fmin, fmax=fmax, faverage=True, n_jobs=-1)
Software:
mne: ‘0.24.dev0’
Ubuntu 16.04
Hardware:
RAM: 32G
Intel Core i7-8700k
Appreciate for any suggestion