# Creating inverse operator

**URL:** <https://mne.discourse.group/t/creating-inverse-operator/8771>\
**Category:** Support & Discussions\
**Tags:** visualization\
**Created:** [May 8, 2024, 11:28am UTC](https://mne.discourse.group/t/creating-inverse-operator/8771 "2024-05-08T11:28:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moh.H](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Moh.H](https://mne.discourse.group/u/Moh.H)\
**Post date:** [May 8, 2024, 11:28am UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/1 "2024-05-08T11:28:02Z")

</div>

Hello everyone;

- MNE version: 1.6.1
- operating system: Windows 10

I want to create inverse operator so I can plot them in source location. However, I just have a raw EEG data and I don’t have a structural MRI scan of the subject. As I understand, MNE provides standard source spaces with predefined locations but I couldn’t make it.  
Now, I want to know how I can inverse operator for my data. If there is anyone could help me with this or if there are any resources that could provide further insight, I would greatly appreciate it.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [May 8, 2024, 3:26pm UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/2 "2024-05-08T15:26:07Z")

</div>

Hello, you need to

- apply a template montage like `standard_1005`
- pass `subject="fsaverage"` when calling `setup_source_space()`
- pass `trans="fsaverage"` when calling `make_forward_solution()`

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![Moh.H](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Moh.H](https://mne.discourse.group/u/Moh.H)\
**Post date:** [May 9, 2024, 1:48pm UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/3 "2024-05-09T13:48:58Z")

</div>

Hello @richard  
I did like you said in `setup_source_space()`

```python
src = mne.setup_source_space(subject='fsaverage', spacing='oct6', subjects_dir=None)

```

I got this error:

> KeyError: ‘Key “SUBJECTS\_DIR” not found in the environment or in the the mne-python config file (C:\Users\Eng\.mne\mne-python.json). Try either os.environ[“SUBJECTS\_DIR”] = VALUE for a temporary solution, or mne.utils.set\_config(“SUBJECTS\_DIR”, VALUE, set\_env=True) for a permanent one. You can also set the environment variable before running python.’

Can I use the subjects that stored in mne.dataset `subjects_dir=mne.datasets.sample.data_path() / "subjects"`

I appreciate your help.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [May 9, 2024, 8:05pm UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/4 "2024-05-09T20:05:13Z")

</div>

Hi,

You can use [`fetch_fsaverage()`](https://mne.tools/stable/generated/mne.datasets.fetch_fsaverage.html) to retrieve the required FreeSurfer files.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![Moh.H](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Moh.H](https://mne.discourse.group/u/Moh.H)\
**Post date:** [May 10, 2024, 12:49pm UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/5 "2024-05-10T12:49:57Z")

</div>

Thanks alot

---

<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:** [May 17, 2024, 12:50pm UTC](https://mne.discourse.group/t/creating-inverse-operator/8771/6 "2024-05-17T12:50:48Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
