Home > vbmeg > demo > tutorial_for_vbmeg2 > advanced > reject_channel_eeg.m

reject_channel_eeg

PURPOSE ^

Reject noisy EEG channels

SYNOPSIS ^

function reject_channel_eeg(p)

DESCRIPTION ^

 Reject noisy EEG channels

 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 reject_channel_eeg(p)
0002 % Reject noisy EEG channels
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Threshold for detecting noisy channels [V]
0010 threshold = 5*10^(-4);
0011 
0012 % Set input file
0013 data_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'i_all.info.mat');
0014 
0015 % Set output file
0016 save_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'ri_all.info.mat');
0017 
0018 % Load EEG data
0019 data = vb_load_meg_data(data_file);
0020 [Nch, Nsample, Ntr]=size(data);
0021 data2 = reshape(data, [Nch,Nsample*Ntr]);
0022 
0023 % Reject bad channels
0024 bad_ch = find(max(abs(data2), [], 2) > threshold);
0025 load(data_file, 'fileinfo', 'Measurement')
0026 fileinfo.ActiveChannel(bad_ch) = 0;
0027 disp([num2str(length(bad_ch)) ' channels are rejected.'])
0028 
0029 % Save result
0030 save(save_file,'fileinfo','Measurement')
0031 
0032 % Check if bad channels were rejected
0033 data = vb_load_meg_data(save_file);
0034 if max(abs(data(:))) > threshold
0035     error(['Bad channels still remain.'])
0036 end
0037

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