Home > vbmeg > external > mne > mne_label_time_courses.m

mne_label_time_courses

PURPOSE ^

SYNOPSIS ^

function [ values, times, vertices ] = mne_label_time_courses(labelfile,stcfile)

DESCRIPTION ^

 function [ values, times ] = mne_label_time_courses(labelfile,stcfile)

 Extract the time courses corresponding to a label file from an stc file

 labelfile - The name of the label file
 stcfile   - The name of the stc file (must be on the same subject and
 hemisphere as the stc file

 values    - The time courses
 times     - The time points
 vertices  - The vertices corresponding to the time points

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ values, times, vertices ] = mne_label_time_courses(labelfile,stcfile)
0002 %
0003 % function [ values, times ] = mne_label_time_courses(labelfile,stcfile)
0004 %
0005 % Extract the time courses corresponding to a label file from an stc file
0006 %
0007 % labelfile - The name of the label file
0008 % stcfile   - The name of the stc file (must be on the same subject and
0009 % hemisphere as the stc file
0010 %
0011 % values    - The time courses
0012 % times     - The time points
0013 % vertices  - The vertices corresponding to the time points
0014 %
0015 
0016 %
0017 %
0018 %   Author : Matti Hamalainen, MGH Martinos Center
0019 %   License : BSD 3-clause
0020 %
0021 %
0022 %
0023 me='MNE:mne_label_time_courses';
0024 
0025 if nargin ~= 2
0026     error(me,'Incorrect number of arguments');
0027 end
0028 try
0029     stc = mne_read_stc_file(stcfile);
0030 catch
0031     error(me,'%s',mne_omit_first_line(lasterr));
0032 end
0033 
0034 try
0035     lab = mne_read_label_file(labelfile);
0036 catch
0037     error(me,'%s',mne_omit_first_line(lasterr));
0038 end
0039 
0040 [vertices,ia,ib] = intersect(double(stc.vertices),double(lab.vertices));
0041 if length(vertices) == 0 
0042     error(me,'No vertices match the label in the stc file');
0043 end
0044 
0045 values = stc.data(ia,:);
0046 times  = zeros(1,size(stc.data,2));
0047 for k = 0:length(times)-1
0048     times(k+1) = stc.tmin + k*stc.tstep;
0049 end
0050 
0051 end
0052

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005