Home > functions > device > meg > vb_meginfo_filter_EEGinfo.m

vb_meginfo_filter_EEGinfo

PURPOSE ^

leave channel label list in MEGinfo.EEGinfo according as ch_list

SYNOPSIS ^

function eeginfo = vb_meginfo_filter_EEGinfo(meginfo, ch_list)

DESCRIPTION ^

 leave channel label list in MEGinfo.EEGinfo according as ch_list

 [usage]
   eeginfo = vb_meginfo_filter_EEGinfo(meginfo, ch_list)

 [input]
   meginfo : <required> <<struct>> MEG header information
   ch_list : <required> valid channel label list

 [output]
   eeginfo : <<struct>> MEGinfo.EEGinfo whose fields are as follows
            :   there are two types *_name (label name) and *_ix (index)
            :   .all_ch       : all channel
            :   .eeg_ch       : eeg channel
            :   .null_ch      : null channel
            :   .etc_ch       : etc channel
            :   .trigger_ch   : trigger channel
            :   .ecg_ch       : ecg channel
            :   .refmg_ch     : refference magnetometer
           :  sizes of these fields are [N x 1]

 [note]
   if there is not appropriate label, the channel will be removed

 [history]
   2007-07-13 (Sako) initial version

 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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function  eeginfo = vb_meginfo_filter_EEGinfo(meginfo, ch_list)
0002 % leave channel label list in MEGinfo.EEGinfo according as ch_list
0003 %
0004 % [usage]
0005 %   eeginfo = vb_meginfo_filter_EEGinfo(meginfo, ch_list)
0006 %
0007 % [input]
0008 %   meginfo : <required> <<struct>> MEG header information
0009 %   ch_list : <required> valid channel label list
0010 %
0011 % [output]
0012 %   eeginfo : <<struct>> MEGinfo.EEGinfo whose fields are as follows
0013 %            :   there are two types *_name (label name) and *_ix (index)
0014 %            :   .all_ch       : all channel
0015 %            :   .eeg_ch       : eeg channel
0016 %            :   .null_ch      : null channel
0017 %            :   .etc_ch       : etc channel
0018 %            :   .trigger_ch   : trigger channel
0019 %            :   .ecg_ch       : ecg channel
0020 %            :   .refmg_ch     : refference magnetometer
0021 %           :  sizes of these fields are [N x 1]
0022 %
0023 % [note]
0024 %   if there is not appropriate label, the channel will be removed
0025 %
0026 % [history]
0027 %   2007-07-13 (Sako) initial version
0028 %
0029 % Copyright (C) 2011, ATR All Rights Reserved.
0030 % License : New BSD License(see VBMEG_LICENSE.txt)
0031 
0032 % --- CHECK ARGUMENTS --- %
0033 if ~exist('meginfo', 'var') meginfo = []; end
0034 if ~exist('ch_list', 'var') ch_list = []; end
0035 [meginfo, ch_list] = inner_check_arguments(meginfo, ch_list);
0036 
0037 % --- MAIN PROCEDURE --------------------------------------------------------- %
0038 %
0039 eeginfo = meginfo.EEGinfo;
0040 
0041 if isempty(meginfo.EEGinfo) || isempty(ch_list)
0042   return;
0043 end
0044 
0045 field_ch_name = { ...
0046     'eeg_ch_name', ...
0047     'null_ch_name', ...
0048     'etc_ch_name', ...
0049     'trigger_ch_name', ...
0050     'ecg_ch_name', ...
0051     'refmg_ch_name' ...
0052 };
0053 
0054 field_ch_idx = { ...
0055     'eeg_ch_ix', ...
0056     'null_ch_ix', ...
0057     'etc_ch_ix', ...
0058     'trigger_ch_ix', ...
0059     'ecg_ch_ix', ...
0060     'refmg_ch_ix' ...
0061 };
0062 
0063 %
0064 % --- get channel type & make eeg data
0065 %
0066 start_pos = 1;
0067 
0068 all_name = [];
0069 
0070 for field_cnt = 1:length(field_ch_name)
0071   cur_field = field_ch_name{field_cnt};
0072   cur_ix_field = field_ch_idx{field_cnt};
0073   
0074   if isfield(eeginfo, cur_field)
0075     [res,idx] = vb_util_check_numerical_lists(eeginfo.(cur_field), ch_list);
0076     if ~isempty(idx)
0077       eeginfo.(cur_field) = eeginfo.(cur_field)(idx,:);
0078       all_name = [all_name;eeginfo.(cur_field)];
0079 
0080       end_pos = start_pos + length(idx) - 1;
0081       eeginfo.(cur_ix_field) = [start_pos:end_pos]';
0082       
0083       start_pos = start_pos + length(idx);
0084     else
0085       eeginfo = rmfield(eeginfo, cur_field);
0086       eeginfo = rmfield(eeginfo, cur_ix_field);
0087     end
0088   end
0089 end
0090 
0091 eeginfo.all_ch_name = all_name;
0092 eeginfo.all_ch_ix = [1:start_pos-1]';
0093 
0094 return;
0095 %
0096 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0097 
0098 % --- INNER FUNCTIONS -------------------------------------------------------- %
0099 %
0100 % --- inner_check_arguments()
0101 %
0102 function [meginfo, ch_list] = inner_check_arguments(meginfo, ch_list)
0103 func_ = mfilename;
0104 
0105 if isempty(meginfo)
0106   error('(%s)meginfo is a required parameter', func_);
0107 end
0108 
0109 if ~isfield(meginfo, 'EEGinfo')
0110   meginfo.EEGinfo = [];
0111 end
0112 
0113 if isempty(ch_list)
0114   % require no action
0115 end
0116 return;
0117 %
0118 % --- end of inner_check_arguments()
0119 %
0120 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0121 
0122 %%% END OF FILE %%%

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