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

reject_channel_meg

PURPOSE ^

Reject noisy MEG channels

SYNOPSIS ^

function reject_channel_meg(p)

DESCRIPTION ^

 Reject noisy MEG 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_meg(p)
0002 % Reject noisy MEG 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 = 2*10^(-12);
0011 sleep_ch={'38','260'};% These channels did not work.
0012 
0013 % Set input file
0014 data_file = fullfile(p.proj_root, p.meg_dirname, p.trial_dirname, 'i_all.info.mat');
0015 
0016 % Set output file
0017 save_file = fullfile(p.proj_root, p.meg_dirname, p.trial_dirname, 'ri_all.info.mat');
0018 
0019 % Load MEG data and MEGinfo
0020 [data, ch_info] = vb_load_meg_data(data_file);
0021 load(data_file, 'fileinfo', 'Measurement')
0022 load(fileinfo.filename{1}, 'MEGinfo')
0023 
0024 % Obtain indices of sleep channels
0025 ix_sleep_ch = zeros(1, length(sleep_ch));
0026 for c = 1:length(ch_info.ID)
0027     if strcmp(ch_info.Name{c}, sleep_ch{1})
0028         ix_sleep_ch(1) = c;
0029     elseif strcmp(ch_info.Name{c}, sleep_ch{2})
0030         ix_sleep_ch(2) = c;
0031     end
0032 end
0033 
0034 % Reject bad channels
0035 [Nch, Nsample, Ntr]=size(data);
0036 data2 = reshape(data, [Nch, Nsample*Ntr]);
0037 bad_ch = [find(max(abs(data2), [], 2) > threshold)' ix_sleep_ch];
0038 fileinfo.ActiveChannel(bad_ch) = 0;
0039 
0040 disp([num2str(length(bad_ch)) ' channels are rejected.'])
0041 
0042 % Save result
0043 save(save_file, 'fileinfo', 'Measurement')
0044 
0045 % Check if bad channels were rejected
0046 data = vb_load_meg_data(save_file);
0047 if max(abs(data(:))) > threshold
0048     error(['Bad channels still remain.'])
0049 end
0050

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