# Memory Error

**URL:** <https://mne.discourse.group/t/memory-error/2235>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [June 25, 2020, 7:03pm UTC](https://mne.discourse.group/t/memory-error/2235 "2020-06-25T19:03:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 7:03pm UTC](https://mne.discourse.group/t/memory-error/2235/1 "2020-06-25T19:03:19Z")

</div>

External Email - Use Caution

Dear MNE users,

I am trying to do something similar that has been done in this example:  
[https://mne.tools/stable/auto\_examples/inverse/plot\_psf\_ctf\_vertices.html#sphx-glr-auto-examples-inverse-plot-psf-ctf-vertices-py](https://mne.tools/stable/auto_examples/inverse/plot_psf_ctf_vertices.html#sphx-glr-auto-examples-inverse-plot-psf-ctf-vertices-py)

Except, I would like to compute my forward and Inverse operator with free  
orientation instead of being fixed or perpendicular to the cortical  
surface. However, I am getting this following error once I try to compute  
it. Is there any workaround to skip this memory error??

Best,  
Dip

\*Error: \*

\*Traceback (most recent call last): File  
"/media/diptyajit/Elements/Pycharm\_Aud\_Cog/plot\_psf\_ctf\_vertices.py", line  
53, in \<module\> snr = 3.0 File "\<decorator-gen-313\>", line 21, in  
make\_inverse\_resolution\_matrix File  
"/home/diptyajit/anaconda3/lib/python3.7/site-packages/mne/minimum\_norm/resolution\_matrix.py",  
line 60, in make\_inverse\_resolution\_matrix resmat =  
invmat.dot(leadfield)MemoryError: Unable to allocate array with shape  
(56310, 56310) and data type float64\*  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200625/a0bfba59/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200625/a0bfba59/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 8:49pm UTC](https://mne.discourse.group/t/memory-error/2235/2 "2020-06-25T20:49:56Z")

</div>

External Email - Use Caution

hi,

try reducing the size of your source space or find a machine with more RAM.  
It seems you need at least 25GB here.

HTH  
Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 26, 2020, 1:04pm UTC](https://mne.discourse.group/t/memory-error/2235/3 "2020-06-26T13:04:05Z")

</div>

External Email - Use Caution

Hi alex,

Thanks for the suggestions. I tried with reduced source space('oct6'). I  
can compute the resolution matrix but it doesn't match the size of the no.  
of vertices of the original source space. Therefore, I am getting an error  
while saving it as source estimate object .  
Details:  
original source space: 7503 locations (3 dipoles per each location)  
Dimension of Inverse Matrix: (22509, 187)  
Dimensions of resolution matrix: 22509 by 22509.  
ValueError: Number of vertices (7503) and stc.shape[0] (22509) must match

However, I am expecting a resolution matrix with size of 7503\*7503. Is the  
resolution matrix being calculated each dipole location instead of taking  
of normal of 3 components?? Any idea?

best,  
Dip

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 29, 2020, 8:20pm UTC](https://mne.discourse.group/t/memory-error/2235/4 "2020-06-29T20:20:27Z")

</div>

External Email - Use Caution

hi,

cc Olaf

it could be a bug. Can you open an issue so we can have a look at it?

Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 30, 2020, 9:27am UTC](https://mne.discourse.group/t/memory-error/2235/5 "2020-06-30T09:27:03Z")

</div>

External Email - Use Caution

Hi,

when you compute the resolution matrix R for n locations and free orientations, then R will have dimension (3\*n)x(3\*n), since every dipole can affect every other dipole. If you want to put this into an STC, you will have to combine source orientations (e.g. RMS) in a separate step.  
If this doesn't answer your question, please send me some more details about what exactly you are doing, and I'll look into it.

Best wishes,

Olaf
