how to extract the label time series using MNE-toolbox

Hi MNEers,
Recently I am conducting an epilepy MEG analysis project.
I used MNE toolbox to create a cortex constrained source space (5891 sources) and calculated the lead fead matrix (free orientaion, 5891 (sources) x 3 (directions xyz) x 306 (channels) matrix ).
By on house code, I applied the inverse problem (beamformer) operator to a segment of epileptiform MEG and then got a 5891 (sources) x 3 (directions) x 500 (time points) matrix (SDTM), which is source time series.

My questions are as,
1) how to get the information on which source belong to which regions by label operations (for example source A is included in temporal cortex). If I got such information, I can get a collective time series for a region by averaging (or other ways to get a representative time series) all the source time series in this region. anyone have a quick code to share it to me?

2) epileptiform MEG is difficult to average. and for such MEG, we have only one "trial". MNE python is quite suitable to process multiple trials MEG data. How to use the several functions to process single "trials" epileptiform MEG?
for example,
if I know SDTM in matlab format, how to use it as the input of the function mne.extract_label_time_course?
The stcs para equals to the SDTM?

The following is the three examples for the functions extracted from
http://martinos.org/mne/stable/auto_examples/connectivity/plot_mne_inverse_label_connectivity.html#example-connectivity-plot-mne-inverse-label-connectivity-py
stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, method,
                            pick_ori="normal", return_generator=True)

# Get labels for FreeSurfer 'aparc' cortical parcellation with 34 labels/hemi
labels, label_colors = mne.labels_from_parc('sample', parc='aparc',
                                            subjects_dir=subjects_dir)

# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels, src, mode='mean_flip',
                                         return_generator=True)
Best wishes,
Junpeng
2014-03-18

junpeng.zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140318/0a849c56/attachment.html

hi,

Recently I am conducting an epilepy MEG analysis project.
I used MNE toolbox to create a cortex constrained source space (5891
sources) and calculated the lead fead matrix (free orientaion, 5891
(sources) x 3 (directions xyz) x 306 (channels) matrix ).
By on house code, I applied the inverse problem (beamformer) operator to a
segment of epileptiform MEG and then got a 5891 (sources) x 3 (directions) x
500 (time points) matrix (SDTM), which is source time series.

so you have 3 time series per location. Which is not make stc contain.

My questions are as,
1) how to get the information on which source belong to which regions by
label operations (for example source A is included in temporal cortex). If
I got such information, I can get a collective time series for a region by
averaging (or other ways to get a representative time series) all the source
time series in this region. anyone have a quick code to share it to me?

if you use instances of SourceEstimates (stc objects) you can use labels.
I assume you use a surface source space. You can look at the code
of the in_label method.

http://martinos.org/mne/stable/generated/mne.SourceEstimate.html#mne.SourceEstimate.in_label

2) epileptiform MEG is difficult to average. and for such MEG, we have only
one "trial". MNE python is quite suitable to process multiple trials MEG
data. How to use the several functions to process single "trials"
epileptiform MEG?
for example,
if I know SDTM in matlab format, how to use it as the input of the function
mne.extract_label_time_course?
The stcs para equals to the SDTM?

you can get an Evoked instance by average a single Epoch.

The following is the three examples for the functions extracted from
http://martinos.org/mne/stable/auto_examples/connectivity/plot_mne_inverse_label_connectivity.html#example-connectivity-plot-mne-inverse-label-connectivity-py

stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, method,
                            pick_ori="normal", return_generator=True)

# Get labels for FreeSurfer 'aparc' cortical parcellation with 34
labels/hemi
labels, label_colors = mne.labels_from_parc('sample', parc='aparc',
                                            subjects_dir=subjects_dir)

# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels, src,
mode='mean_flip',
                                         return_generator=True)

it does not make sense to you mean_flip unless you have fixed orient
source space
or used pick_ori='normal'. You can just average you have positive
values in the stc.

Hope this helps,

Alex

Hi Alex,
   Thank you very much!
   I got the direction to solve the problem! I will try it!
Best wishes and thank you for your great contribution to the community!

Jupeng Zhang, Ph.D
Associate Professor
Sichuan Applied Psychology Research Center
Chengdu Medical College
Chengdu, China
email: junpeng.zhang at gmail.com

2014-03-19

junpeng.zhang

???Alexandre Gramfort <alexandre.gramfort at telecom-paristech.fr>
???2014-03-19 04:01
???Re: [Mne_analysis] how to extract the label time series using MNE-toolbox
???"junpeng.zhang"<junpeng.zhang at gmail.com>
???"mne_analysis at nmr.mgh.harvard.edu"<mne_analysis at nmr.mgh.harvard.edu>

hi,

Recently I am conducting an epilepy MEG analysis project.
I used MNE toolbox to create a cortex constrained source space (5891
sources) and calculated the lead fead matrix (free orientaion, 5891
(sources) x 3 (directions xyz) x 306 (channels) matrix ).
By on house code, I applied the inverse problem (beamformer) operator to a
segment of epileptiform MEG and then got a 5891 (sources) x 3 (directions) x
500 (time points) matrix (SDTM), which is source time series.

so you have 3 time series per location. Which is not make stc contain.

My questions are as,
1) how to get the information on which source belong to which regions by
label operations (for example source A is included in temporal cortex). If
I got such information, I can get a collective time series for a region by
averaging (or other ways to get a representative time series) all the source
time series in this region. anyone have a quick code to share it to me?

if you use instances of SourceEstimates (stc objects) you can use labels.
I assume you use a surface source space. You can look at the code
of the in_label method.

http://martinos.org/mne/stable/generated/mne.SourceEstimate.html#mne.SourceEstimate.in_label

2) epileptiform MEG is difficult to average. and for such MEG, we have only
one "trial". MNE python is quite suitable to process multiple trials MEG
data. How to use the several functions to process single "trials"
epileptiform MEG?
for example,
if I know SDTM in matlab format, how to use it as the input of the function
mne.extract_label_time_course?
The stcs para equals to the SDTM?

you can get an Evoked instance by average a single Epoch.

The following is the three examples for the functions extracted from
http://martinos.org/mne/stable/auto_examples/connectivity/plot_mne_inverse_label_connectivity.html#example-connectivity-plot-mne-inverse-label-connectivity-py

stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, method,
                            pick_ori="normal", return_generator=True)

# Get labels for FreeSurfer 'aparc' cortical parcellation with 34
labels/hemi
labels, label_colors = mne.labels_from_parc('sample', parc='aparc',
                                            subjects_dir=subjects_dir)

# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels, src,
mode='mean_flip',
                                         return_generator=True)

it does not make sense to you mean_flip unless you have fixed orient
source space
or used pick_ori='normal'. You can just average you have positive
values in the stc.

Hope this helps,

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140319/e6dd7b8a/attachment.html

Hi Alex,

Thank you for kind response.
I still have a question. Please see the highlighted fonts.

Recently I am conducting an epilepy MEG analysis project.
I used MNE toolbox to create a cortex constrained source space (5891
sources) and calculated the lead fead matrix (free orientaion, 5891
(sources) x 3 (directions xyz) x 306 (channels) matrix ).
By on house code, I applied the inverse problem (beamformer) operator to a
segment of epileptiform MEG and then got a 5891 (sources) x 3 (directions) x
500 (time points) matrix (SDTM), which is source time series.

so you have 3 time series per location. Which is not make stc contain.

My questions are as,
1) how to get the information on which source belong to which regions by
label operations (for example source A is included in temporal cortex). If
I got such information, I can get a collective time series for a region by
averaging (or other ways to get a representative time series) all the source
time series in this region. anyone have a quick code to share it to me?

if you use instances of SourceEstimates (stc objects) you can use labels.
I assume you use a surface source space. You can look at the code
of the in_label method.

http://martinos.org/mne/stable/generated/mne.SourceEstimate.html#mne.SourceEstimate.in_label

2) epileptiform MEG is difficult to average. and for such MEG, we have only
one "trial". MNE python is quite suitable to process multiple trials MEG
data. How to use the several functions to process single "trials"
epileptiform MEG?
for example,
if I know SDTM in matlab format, how to use it as the input of the function
mne.extract_label_time_course?
The stcs para equals to the SDTM?

you can get an Evoked instance by average a single Epoch.
I ever tried to create a instance but in the epilepy raw data, there is no any events writed in the file.
When I import a .eve file, the error will be no event to average...
How to transform a raw.fif into a ave.fif when the raw file has no events indicated?
My epilepsy raw file info: 11s ----702s.

Best wishes,
Junpeng Zhang

The following is the three examples for the functions extracted from
http://martinos.org/mne/stable/auto_examples/connectivity/plot_mne_inverse_label_connectivity.html#example-connectivity-plot-mne-inverse-label-connectivity-py

stcs = apply_inverse_epochs(epochs, inverse_operator, lambda2, method,
                            pick_ori="normal", return_generator=True)

# Get labels for FreeSurfer 'aparc' cortical parcellation with 34
labels/hemi
labels, label_colors = mne.labels_from_parc('sample', parc='aparc',
                                            subjects_dir=subjects_dir)

# Average the source estimates within each label using sign-flips to reduce
# signal cancellations, also here we return a generator
src = inverse_operator['src']
label_ts = mne.extract_label_time_course(stcs, labels, src,
mode='mean_flip',
                                         return_generator=True)

it does not make sense to you mean_flip unless you have fixed orient
source space
or used pick_ori='normal'. You can just average you have positive
values in the stc.

Hope this helps,

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20140319/45e06c57/attachment.html

hi Junpeng,

you need to define events visually/manually in mne_browse_raw

HTH
A

Hi Alex,
Thank you very much!
The following link tells us how to define events. Thanks
http://martinos.org/mne/stable/manual/browse.html#babdfaha

Best wishes,
Junpeng
2014-03-19

junpeng.zhang

???Alexandre Gramfort <alexandre.gramfort at telecom-paristech.fr>
???2014-03-19 20:07
???Re: Re: [Mne_analysis] how to extract the label time series using MNE-toolbox
???"junpeng.zhang"<junpeng.zhang at gmail.com>
???"mne_analysis at nmr.mgh.harvard.edu"<mne_analysis at nmr.mgh.harvard.edu>

hi Junpeng,

you need to define events visually/manually in mne_browse_raw

HTH
A