Hi everyone, I am trying to obtain a leadfield matrix (channels x brain regions) which in my case would be 62x200 (I am using a brain atlas with 200 parcels). Any idea on how to move from the â€ścanonicalâ€ť leadfield matrix (channels x sources) to the one Iâ€™ve just described. Since mne has a function to extract the parcels time series, there should be an easy way to extract the leadfield matrix without scripting it from scratch.

what would be for you the forward field of a parcel? putting the full parcel with a constant activation of 1?

Alex

Hi @agramfort thanks for reply to this. It would be the same as the â€ścanonicalâ€ť leadfield array but instead having the vertices on the second dim, it will have the average of the values for the vertices that falls in the parcels. Anyway, Iâ€™ve just solved the issue myselfâ€¦just some extra-work with mne.decimate

Thanks

ok thatâ€™s equivalent to what I suggest above. Itâ€™s as if you were to put a constant activity over each parcel.

you would just want the leadfield as a numpy array?

Alex

@agramfort please find the piece of code I wrote below for a sanity check and for other people who might encounter the same issue. Could you please take a look at it?

``````stcs = mne.read_source_estimate(op.join(eeg_path + 'sub_0014-stc'))

subject +  '/label/lh.Schaefer2018_200Parcels_7Networks_order.annot'))[0]

subject +  '/label/rh.Schaefer2018_200Parcels_7Networks_order.annot'))[0]

regmap = np.concatenate([lh_regmap, rh_regmap+np.max(lh_regmap)])

vtx2use = np.concatenate([stcs.vertices[0], stcs.vertices[1]+np.max(stcs.vertices[0])])
regions_idx = regmap[vtx2use]

fwd_fixed = mne.convert_forward_solution(fwd, surf_ori=True, force_fixed=True,
use_cps=True)

for xx in range(1,np.unique(regions_idx).shape[0]):

Output is:

Leadfield size : 62 sensors x 23121 dipoles
Leadfield size : 62 sensors x 7707 dipoles
Leadfield size : 62 sensors x 200 regions

Could you please confirm that is correct?

Thanks``````

itâ€™s hard to tell without running the code. Can you share snippet using the mne-sample-data so it works also on my machine?

thanks
Alex

@agramfort I apologize but I donâ€™t have the mne-sample-data here. Anyway it should be easy to run. Please set up:
stcs = the source estimate
lh_regmap = path to the annotation file of the .annot file (in your case it would be the lh.aparc.annot)
rh_regmap = same as lh_regmap but for the right hemisphere.

Here is the code.

``````stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, inv_method, pick_ori=None, return_generator=True)
subject +  '/label/lh.aparc.annot'))[0]

subject +  '/label/rh.aparc.annot'))[0]
``````

Hope this helps

hi Davide,

yes itâ€™s easy for me to do but itâ€™s still minutes for me. You can easily do this yourself too.
Letâ€™s balance the efforts here so we can collectively progress.

Alex

1 Like

You can download the data by running `mne.datasets.sample.data_path()`