Home > functions > device > meg > preprocess > vb_megfile_remove_offset.m

vb_megfile_remove_offset

PURPOSE ^

Remove offset of signal by subtracting the mean signal amplitude

SYNOPSIS ^

function vb_megfile_remove_offset(megfile,megfile_new,baseline)

DESCRIPTION ^

 Remove offset of signal by subtracting the mean signal amplitude

 --- Syntax
 vb_megfile_remove_offset(megfile,megfile_new,baseline)

 --- Input (optional)
 baseline: Time index of baseline period. If not specified, pretrigger
 is used.

 --- Example
 >> megfile1='meg1.meg.mat';
 >> megfile2='meg2.meg.mat';
 >> baseline=[101 500];

 --- History
 2008-05-08 Taku Yoshioka
 2008-06-16 Taku Yoshioka
 2008-06-27 Taku Yoshioka (baseline)
 2010-01-26 (Sako) renamed

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vb_megfile_remove_offset(megfile,megfile_new,baseline)
0002 % Remove offset of signal by subtracting the mean signal amplitude
0003 %
0004 % --- Syntax
0005 % vb_megfile_remove_offset(megfile,megfile_new,baseline)
0006 %
0007 % --- Input (optional)
0008 % baseline: Time index of baseline period. If not specified, pretrigger
0009 % is used.
0010 %
0011 % --- Example
0012 % >> megfile1='meg1.meg.mat';
0013 % >> megfile2='meg2.meg.mat';
0014 % >> baseline=[101 500];
0015 %
0016 % --- History
0017 % 2008-05-08 Taku Yoshioka
0018 % 2008-06-16 Taku Yoshioka
0019 % 2008-06-27 Taku Yoshioka (baseline)
0020 % 2010-01-26 (Sako) renamed
0021 %
0022 % Copyright (C) 2011, ATR All Rights Reserved.
0023 % License : New BSD License(see VBMEG_LICENSE.txt)
0024 
0025 const = vb_define_const;
0026 
0027 if nargin<1, help vb_megfile_remove_offset; end
0028 
0029 MEGinfo = vb_load_meg_info(megfile);
0030 
0031 % Baseline
0032 if nargin<3 || isempty(baseline), 
0033   Tbase = 1:MEGinfo.Pretrigger;
0034 else
0035   Tbase = baseline(1):baseline(2);
0036 end
0037 
0038 % Remove offset
0039 for i=1:MEGinfo.Nrepeat
0040   load_spec.TrialNumber = i;
0041   load_spec.ActiveChannel = false;
0042   
0043   load_spec.ChannelType = const.DATA_TYPE_MAIN;
0044   meg_data = vb_load_meg_data(megfile,load_spec);
0045   
0046   load_spec.ChannelType = const.DATA_TYPE_EXTRA;
0047   ext_data = vb_load_meg_data(megfile,load_spec);
0048   
0049   load_spec.ChannelType = const.DATA_TYPE_REFERENCE;
0050   ref_data = vb_load_meg_data(megfile,load_spec);
0051   
0052   offset = mean(meg_data(:,Tbase),2);
0053   meg_data = meg_data-repmat(offset,[1 size(meg_data,2)]);
0054   new_data.bexp(:,:,i) = meg_data;
0055   new_data.bexp_ext(:,:,i) = ext_data;
0056   new_data.refmg(:,:,i) = ref_data;
0057 end
0058 
0059 vb_msrmnt_store_data(megfile,new_data,[],megfile_new);
0060

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005