Home > vbmeg > demo > tutorial_for_vbmeg2 > easy_VBMEG > 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, 'ibr_s1.eeg.mat');
0014 
0015 % Set output file
0016 save_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'ribr_s1.eeg.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, 'EEGinfo');
0026 EEGinfo.ActiveChannel(bad_ch) = 0;
0027 disp([num2str(length(bad_ch)) ' channels are rejected.'])
0028 
0029 % Save result
0030 copyfile(data_file, save_file);
0031 vb_save(save_file,'EEGinfo');
0032 
0033 % Check if bad channels were rejected
0034 data = vb_load_meg_data(save_file);
0035 if max(abs(data(:))) > threshold
0036     error(['Bad channels still remain.'])
0037 end
0038

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