Home > vbmeg > demo > tutorial_for_vbmeg2 > easy_VBMEG > correct_baseline_eeg.m

correct_baseline_eeg

PURPOSE ^

Correct baseline of EEG data

SYNOPSIS ^

function correct_baseline_eeg(p)

DESCRIPTION ^

 Correct baseline of EEG data

 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 correct_baseline_eeg(p)
0002 % Correct baseline of EEG data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Set parameters
0010 twin_base = [-0.5 0];% time window of baseline
0011 ch_eeg = 1:63;
0012 
0013 % Load time information
0014 file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 's1.eeg.mat');
0015 [~, ~, time_info] = vb_load_meg_data(file);
0016 [~, from] = min(abs(time_info.time-twin_base(1)));
0017 [~, to] = min(abs(time_info.time-twin_base(2)));
0018 
0019 
0020 % Load data
0021 old_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 's1.eeg.mat');
0022 load(old_file, 'eeg_data')
0023 
0024 for ch = ch_eeg
0025     for tr = 1:size(eeg_data, 3)
0026         eeg_data(ch, :, tr) = eeg_data(ch, :, tr)-mean(eeg_data(ch, from:to, tr), 2);
0027     end
0028 end
0029 
0030 % Save baseline-corrected EEG data
0031 new_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'br_s1.eeg.mat');
0032 copyfile(old_file, new_file); 
0033 
0034 
0035 trial_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 's1.eeg.mat');
0036 load(trial_file, 'EEGinfo')
0037 EEGinfo.blink = zeros(1, EEGinfo.Nrepeat);
0038 
0039 vb_save(new_file, 'eeg_data','EEGinfo');
0040 
0041

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