Home > vbmeg > functions > device > vb_info_get_active_channel_index.m

vb_info_get_active_channel_index

PURPOSE ^

return active channel index list

SYNOPSIS ^

function [idx_list] = vb_info_get_active_channel_index(info, ch_type)

DESCRIPTION ^

 return active channel index list
 [usage]
   [idx_list] = vb_info_get_active_channel_index(info, ch_type)
 [input]
       info : <required> <<struct>> MEGinfo or EEGinfo
    ch_type : <optional> <<integer>> channel type [1]
            :  1) MEG or EEG channels
            :  2) only extra channels
            :  3) all channels
 [output]
   idx_list : [N_activeCh x 1] active channel index list
 [note]
   @see vb_info_get_active_channel.m
 [history]
   2008-04-16 (Sako) initial version
   2008-06-05 (Sako) added ch_type

 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 [idx_list] = vb_info_get_active_channel_index(info, ch_type)
0002 % return active channel index list
0003 % [usage]
0004 %   [idx_list] = vb_info_get_active_channel_index(info, ch_type)
0005 % [input]
0006 %       info : <required> <<struct>> MEGinfo or EEGinfo
0007 %    ch_type : <optional> <<integer>> channel type [1]
0008 %            :  1) MEG or EEG channels
0009 %            :  2) only extra channels
0010 %            :  3) all channels
0011 % [output]
0012 %   idx_list : [N_activeCh x 1] active channel index list
0013 % [note]
0014 %   @see vb_info_get_active_channel.m
0015 % [history]
0016 %   2008-04-16 (Sako) initial version
0017 %   2008-06-05 (Sako) added ch_type
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 % --- CHECK ARGUMENTS --- %
0023 if ~exist('info', 'var'), info = []; end
0024 if ~exist('ch_type', 'var'), ch_type = []; end
0025 [info, ch_type] = inner_check_arguments(info, ch_type);
0026 
0027 % --- MAIN PROCEDURE --------------------------------------------------------- %
0028 %
0029 if vb_info_active_channel_is_valid(info)
0030   switch ch_type
0031     case 1
0032       % MEG or EEG channels
0033       active_list = vb_info_get_active_channel(info, 1);
0034       idx_list = find(active_list == 1);
0035       return;
0036       
0037     case 2
0038       % only extra channels
0039       active_list = vb_info_get_active_channel(info, 2);
0040       idx_list = info.ExtraChannelInfo.Channel_id(active_list == 1);
0041       return;
0042       
0043     case 3
0044       idx_list = ...
0045         [vb_info_get_active_channel_index(info,1); ...
0046          vb_info_get_active_channel_index(info,2)];
0047       return;
0048   end
0049 end
0050 
0051 % --- no ActiveChannel field in info
0052 Measurement = vb_info_get_measurement(info);
0053 switch Measurement
0054   case 'MEG'
0055 %     [ch_idx,ch_idx_arg,active_list] = vb_meginfo_get_channel_index_meg(info);
0056     [ch_idx] = vb_meginfo_get_channel_index_meg(info, [], true);
0057     idx_list = ch_idx(active_list == 1);
0058   case 'EEG'
0059     idx_list = vb_eeginfo_get_channel_index(info, true);
0060     return;
0061 end
0062 return;
0063 %
0064 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0065 
0066 % --- INNER FUNCTIONS -------------------------------------------------------- %
0067 %
0068 % --- inner_check_arguments()
0069 %
0070 function [info, ch_type] = inner_check_arguments(info, ch_type)
0071 if isempty(info)
0072   error('(%s)info is a required parameter\n', mfilename);
0073 end
0074 
0075 if isempty(ch_type)
0076   ch_type = 1;
0077 elseif ~isnumeric(ch_type)
0078   error('(%s)ch_type must be specify as numeric');
0079 end
0080 return;
0081 %
0082 % --- end of inner_check_arguments()
0083 %
0084 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0085 
0086 %%% END OF FILE %%%

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