Home > vbmeg > functions > tool_box > neuromag > neuromag_get_channel_type.m

neuromag_get_channel_type

PURPOSE ^

return neuromag channel type information

SYNOPSIS ^

function [ ch_type ] = neuromag_get_channel_type(type_key)

DESCRIPTION ^

 return neuromag channel type information
 [usage]
   [ ch_type ] = neuromag_get_channel_type( type_key )
 [input]
   type_key : <optional> There are three patterns.
               1) if this is empty or this is not be specified,
                  return struct array of all channel types
               2) if this is character, return corresponding type code number
               3) if this is numeric, return corresponding type character
 [output]
    ch_type : 1) <struct array> fields are as follows:
               .id   : type code
               .name : type name
              2) <numeric> corresponding type code
              3) <string> correstponding type name
 [note]
   @see vb_yokogawa_get_channel_type : For yokogawa channel type
 [history]
   2011-05-24 (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 [ ch_type ] = neuromag_get_channel_type(type_key)
0002 % return neuromag channel type information
0003 % [usage]
0004 %   [ ch_type ] = neuromag_get_channel_type( type_key )
0005 % [input]
0006 %   type_key : <optional> There are three patterns.
0007 %               1) if this is empty or this is not be specified,
0008 %                  return struct array of all channel types
0009 %               2) if this is character, return corresponding type code number
0010 %               3) if this is numeric, return corresponding type character
0011 % [output]
0012 %    ch_type : 1) <struct array> fields are as follows:
0013 %               .id   : type code
0014 %               .name : type name
0015 %              2) <numeric> corresponding type code
0016 %              3) <string> correstponding type name
0017 % [note]
0018 %   @see vb_yokogawa_get_channel_type : For yokogawa channel type
0019 % [history]
0020 %   2011-05-24 (Sako) initial version
0021 %
0022 % Copyright (C) 2011, ATR All Rights Reserved.
0023 % License : New BSD License(see VBMEG_LICENSE.txt)
0024 
0025 % --- CHECK ARGUMENTS --- %
0026 if ~exist('type_key', 'var'), type_key = []; end
0027 [type_key] = inner_check_arguments(type_key);
0028 
0029 % --- MAIN PROCEDURE --------------------------------------------------------- %
0030 %
0031 
0032 % --- make an array of channel type definition
0033 
0034 % --- DEFINITION of YOKOGAWA - as a baseline for definition of neuromag
0035 type_index = 1;
0036 
0037 NullChannel         = 0;
0038 channel_type(type_index).id   = NullChannel;
0039 channel_type(type_index).name = 'NullChannel';
0040 type_index = type_index + 1;
0041 
0042 MagnetoMeter        = 1;
0043 channel_type(type_index).id   = MagnetoMeter;
0044 channel_type(type_index).name = 'MagnetoMeter';
0045 type_index = type_index + 1;
0046 
0047 AxialGradioMeter    = 2;
0048 channel_type(type_index).id   = AxialGradioMeter;
0049 channel_type(type_index).name = 'AxialGradioMeter';
0050 type_index = type_index + 1;
0051 
0052 PlanarGradioMeter   = 3;
0053 channel_type(type_index).id   = PlanarGradioMeter;
0054 channel_type(type_index).name = 'PlanarGradioMeter';
0055 type_index = type_index + 1;
0056 
0057 % ReferenceChannelMark
0058 RCMark = hex2dec('0100');
0059 
0060 Ref_MagnetoMeter       = bitor(RCMark, MagnetoMeter);
0061 channel_type(type_index).id   = Ref_MagnetoMeter;
0062 channel_type(type_index).name = 'Ref_MagnetoMeter';
0063 type_index = type_index + 1;
0064 
0065 Ref_AxialGradioMeter   = bitor(RCMark, AxialGradioMeter);
0066 channel_type(type_index).id   = Ref_AxialGradioMeter;
0067 channel_type(type_index).name = 'Ref_AxialGradioMeter';
0068 type_index = type_index + 1;
0069 
0070 Ref_PlanarGradioMeter  = bitor(RCMark, PlanarGradioMeter);
0071 channel_type(type_index).id   = Ref_PlanarGradioMeter;
0072 channel_type(type_index).name = 'Ref_PlanarGradioMeter';
0073 type_index = type_index + 1;
0074 
0075 TriggerChannel      = -1;
0076 channel_type(type_index).id   = TriggerChannel;
0077 channel_type(type_index).name = 'TriggerChannel';
0078 type_index = type_index + 1;
0079 
0080 EegChannel          = -2;
0081 channel_type(type_index).id   = EegChannel;
0082 channel_type(type_index).name = 'EegChannel';
0083 type_index = type_index + 1;
0084 
0085 EcgChannel          = -3;
0086 channel_type(type_index).id   = EcgChannel;
0087 channel_type(type_index).name = 'EcgChannel';
0088 type_index = type_index + 1;
0089 
0090 EtcChannel          = -4;
0091 channel_type(type_index).id   = EtcChannel;
0092 channel_type(type_index).name = 'EtcChannel';
0093 type_index = type_index + 1;
0094 
0095 
0096 % ----- NEUROMAG
0097 NEUROMAG_OFFSET = 0;
0098 NEUROMAG_MagnetoMeter      = MagnetoMeter + NEUROMAG_OFFSET;      % 11
0099 channel_type(type_index).id   = NEUROMAG_MagnetoMeter;
0100 channel_type(type_index).name = 'NEUROMAG_MagnetoMeter';
0101 type_index = type_index + 1;
0102 
0103 NEUROMAG_PlanarGradioMeter = PlanarGradioMeter + NEUROMAG_OFFSET; % 13
0104 channel_type(type_index).id   = NEUROMAG_PlanarGradioMeter;
0105 channel_type(type_index).name = 'NEUROMAG_PlanarGradioMeter';
0106 type_index = type_index + 1;
0107 
0108 NEUROMAG_EegChannel = EegChannel - NEUROMAG_OFFSET;               % -12
0109 channel_type(type_index).id   = NEUROMAG_EegChannel;
0110 channel_type(type_index).name = 'NEUROMAG_EegChannel';
0111 type_index = type_index + 1;
0112 
0113 NEUROMAG_EtcChannel = EtcChannel - NEUROMAG_OFFSET;               % -14
0114 channel_type(type_index).id   = NEUROMAG_EtcChannel;
0115 channel_type(type_index).name = 'NEUROMAG_EtcChannel';
0116 % type_index = type_index + 1;
0117 
0118 if isempty(type_key)
0119   ch_type = channel_type;
0120   return;
0121 elseif ischar(type_key)
0122   ch_type = inner_find_key_by_string(channel_type, type_key);
0123 elseif isnumeric(type_key)
0124   ch_type = inner_find_key_by_numeric(channel_type, type_key);
0125 end
0126 
0127 return;
0128 %
0129 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0130 
0131 % --- INNER FUNCTIONS -------------------------------------------------------- %
0132 %
0133 % --- inner_check_arguments()
0134 %
0135 function [type_key] = inner_check_arguments(type_key)
0136 if isempty(type_key)
0137   % doing nothing means to return channel type array.
0138 end
0139 return;
0140 %
0141 % --- end of inner_check_arguments()
0142 
0143 % --- inner_find_key_by_string()
0144 %
0145 function ch_type = inner_find_key_by_string(channel_type, type_key)
0146 ch_type = [];
0147 
0148 if ~ischar(type_key)
0149   warning('(%s) type_key is not character\n', 'inner_find_key_by_string');
0150   return;
0151 end
0152 
0153 n_type = length(channel_type);
0154 
0155 for i_type = 1:n_type
0156   if strcmp(channel_type(i_type).name, type_key) == 1
0157     ch_type = channel_type(i_type).id;
0158     break;
0159   end
0160 end
0161 return;
0162 %
0163 % --- end of inner_find_key_by_string()
0164 
0165 % --- inner_find_key_by_numeric()
0166 %
0167 function ch_type = inner_find_key_by_numeric(channel_type, type_key)
0168 ch_type = [];
0169 
0170 if ~isnumeric(type_key)
0171   warning('(%s) type_key is not numeric\n', 'inner_find_key_by_numeric');
0172   return;
0173 end
0174 
0175 n_type = length(channel_type);
0176 for i_type = 1:n_type
0177   if channel_type(i_type).id == type_key
0178     ch_type = channel_type(i_type).name;
0179     break;
0180   end
0181 end
0182 return;
0183 %
0184 % --- end of inner_find_key_by_numeric()
0185 %
0186 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0187 
0188 % --- END OF FILE --- %
0189

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