Diff for "InterpolateData" - Meg Wiki
location: Diff for "InterpolateData"
Differences between revisions 9 and 10
Revision 9 as of 2010-09-09 10:08:03
Size: 2306
Editor: YaaraErez
Comment:
Revision 10 as of 2011-06-28 12:43:08
Size: 2411
Editor: pc0339
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
Note: Run the script in Matlab R2006b rather than R2009a! The script might crash if running in R2009a.

Interpolate MEG data to standard sensor array

This Matlab script will interpolate data to a standard sensor array

Maxfilter options:

maxfilter -f %s -o %s -trans %s -v -frame head -origin 0 0 45 -force -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat Note: Run the script in Matlab R2006b rather than R2009a! The script might crash if running in R2009a.


% For files specified in cell array "files{}", apply maxfilter with -trans
% option in order to interpolate data to sensor array specified in "trans_file"
% originall file names will be appended by "_t", or by whatever is specified in "t_ext"
% for each transed file, a log-file with maxfilter output will be created ("*.log")
% OH, March 2009

% you can pre-specify a list of files here
fiff_files = {'/fullpath/file4subj1.fif', ...
         '/fullpath/file4subj2.fif', ...
         '/fullpath/file4subj3.fif'};

% Fiff-file with standard sensor geometry to which the others will be interpolated
trans_file = '/fullpath/fiff4trans.fif';  

t_ext = '_t';   % suffix for filenames of transed files

if ~exist(trans_file, 'file'),
    fprintf(1, 'Cannot proceed without trans_file %s\n', trans_file);
    return;
end;
trans_data = fiff_read_evoked( trans_file );     % read fiff-file with standard sensor geometry

nr_files = length(fiff_files);

for ff = 1:nr_files,     % for each input file, apply maxfilter -trans, then reinsert digitiser points
    in_file = fiff_files{ff};
    [thispath,thisfile,thisext,thisversn] = fileparts(in_file);
    out_file = fullfile(thispath, [thisfile t_ext thisext]);
    log_file = fullfile(thispath, [thisfile t_ext '.log']);

    % maxfilter -trans...
    eval(sprintf('!/neuro/bin/util/maxfilter -f %s -o %s -trans %s -v -frame head -origin 0 0 45 -force -ctc /neuro/databases/ctc/ct_sparse.fif -cal /neuro/databases/sss/sss_cal.dat | tee %s', in_file, out_file, trans_file, log_file));
    
    % reinsert digitiser points...
    data = fiff_read_evoked( out_file );        % read invidual data file with data interpolated to standard sensor geometry
    data.info.dig = trans_data.info.dig;        % insert digitised points from standard geometry to interpolated data set
    fiff_write_evoked( out_file, data );    % write interpolated data back to fiff-file
end;

CbuMeg: InterpolateData (last edited 2013-03-08 10:02:44 by localhost)