[Mne_analysis] How to transfer the subjects’ heads into the same position?

Alexandre Gramfort alexandre.gramfort at inria.fr
Wed Dec 12 15:12:49 EST 2018
Search archives:

        External Email - Use Caution        

hi Maria,

just insert:

info_to['dev_head_t'] = your_transform

before the call to _map_meg_channels

I assume the transform you pasted is called your_transform

HTH
Alex

On Sat, Nov 24, 2018 at 11:28 AM Maria Hakonen <maria.hakonen at gmail.com> wrote:
>
>         External Email - Use Caution
>
> Hi all,
>
> I would like to transfer all subjects’ heads into the same position.
> I have calculated an average head position across subjects, created a transformation matrix and saved it as a trans.fif file (i.e. this is what can be given as 'destination' in Maxwell Filter):
> <Transform  |  MEG device->head>
> [[ 1.          0.          0.          0.        ]
>  [ 0.          1.          0.         -0.04299995]
>  [ 0.          0.          1.          0.0547426 ]
>  [ 0.          0.          0.          1.        ]]
>
> Could someone please let me know how this information could be given in the code Alex sent me in the previous mail of this discussion?
>
> Here is yet the code:
>
> def remap_evoked(evoked, info_to, mode='fast'):
>     # get info that should only differ in dev_head transform
>     from mne import pick_types, pick_info
>     from mne.forward import _map_meg_channels
>     picks = pick_types(evoked.info, meg=True, eeg=False, ref_meg=True)
>
>     info_from = pick_info(evoked.info, picks)
>     info_to = pick_info(info_to, picks)
>     mapping = _map_meg_channels(info_from, info_to, mode=mode)
>
>     evoked.copy()
>     evoked.info = info_to  # update info
>     evoked.data[picks] = np.dot(mapping, evoked.data[picks])
>
>     return evoked
>
> Best,
> Maria
>
> ke 3. lokak. 2018 klo 7.55 Hakonen Maria (maria.hakonen at aalto.fi) kirjoitti:
>>
>>         External Email - Use Caution
>>
>> Thanks a lot!
>>
>> Best,
>> Maria
>> ________________________________________
>> Lähettäjä: mne_analysis-bounces at nmr.mgh.harvard.edu <mne_analysis-bounces at nmr.mgh.harvard.edu> käyttäjän Alexandre Gramfort <alexandre.gramfort at inria.fr> puolesta
>> Lähetetty: 30. syyskuuta 2018 21:57:18
>> Vastaanottaja: Discussion and support forum for the users of MNE Software
>> Aihe: Re: [Mne_analysis]        How to transfer the subjects’ heads into the same position?
>>
>>         External Email - Use Caution
>>
>> hi Maria,
>>
>> the following code snippet is fully tested but it should do in theory
>> do what you want.
>> It maps an evoked object to a new set of sensor locations:
>>
>> ---
>>
>> def remap_evoked(evoked, info_to, mode='fast'):
>>     # get info that should only differ in dev_head transform
>>     from mne import pick_types, pick_info
>>     from mne.forward import _map_meg_channels
>>     picks = pick_types(evoked.info, meg=True, eeg=False, ref_meg=True)
>>
>>     info_from = pick_info(evoked.info, picks)
>>     info_to = pick_info(info_to, picks)
>>     mapping = _map_meg_channels(info_from, info_to, mode=mode)
>>
>>     evoked.copy()
>>     evoked.info = info_to  # update info
>>     evoked.data[picks] = np.dot(mapping, evoked.data[picks])
>>
>>     return evoked
>>
>> ---
>>
>> let's see if someone has the time to make it a proper MNE function.
>>
>> HTH
>> Alex
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>>
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis



More information about the Mne_analysis mailing list