Home > vbmeg > functions > device > meg > neuromag > vb_load_neuromag_sensor.m

vb_load_neuromag_sensor

PURPOSE ^

Load NEUROMAG MEG sensor information

SYNOPSIS ^

function [pick, Qpick, CoilWeight, Vcenter, channel_info] =vb_load_neuromag_sensor(meg_file, active_swt)

DESCRIPTION ^

 Load NEUROMAG MEG sensor information
 [usage]
   [pick, Qpick, CoilWeight, Vcenter] = ...
     vb_load_neuromag_sensor(meg_file, ref_swt, active_swt)

 [input]
     meg_file : <required> meg-mat file
   active_swt : <optional> <<boolean>> flag whether to filter active channels
              :    true) : Yes. This function filters active channels.
              : [false]) : No. This function does not filter active channels.

 [output]
    pick              : position of detector coils.
    Qpick             : direction of coils.
                      : if ref is true, these are directions of refference
    CoilWeight        : (m,n) n-th coil weight for m-th sensor channel
                  basis(channel,dipole) = sensor_weight * basis(coil,dipole)
    Vcenter           : % origin of sphere model [m]
    channel_info      : <<struct>> channel information of loaded data
                        :  .Active [Nchannel x 1]
                        :  .Name   [Nchannel x 1]
                        :  .Type   [Nchannel x 1]
                        :  .ID     [Nchannel x 1]
                       not supported reference channel info.
 [history]
   2018-08-22 (Takeda) 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 [pick, Qpick, CoilWeight, Vcenter, channel_info] = ...
0002     vb_load_neuromag_sensor(meg_file, active_swt)
0003 % Load NEUROMAG MEG sensor information
0004 % [usage]
0005 %   [pick, Qpick, CoilWeight, Vcenter] = ...
0006 %     vb_load_neuromag_sensor(meg_file, ref_swt, active_swt)
0007 %
0008 % [input]
0009 %     meg_file : <required> meg-mat file
0010 %   active_swt : <optional> <<boolean>> flag whether to filter active channels
0011 %              :    true) : Yes. This function filters active channels.
0012 %              : [false]) : No. This function does not filter active channels.
0013 %
0014 % [output]
0015 %    pick              : position of detector coils.
0016 %    Qpick             : direction of coils.
0017 %                      : if ref is true, these are directions of refference
0018 %    CoilWeight        : (m,n) n-th coil weight for m-th sensor channel
0019 %                  basis(channel,dipole) = sensor_weight * basis(coil,dipole)
0020 %    Vcenter           : % origin of sphere model [m]
0021 %    channel_info      : <<struct>> channel information of loaded data
0022 %                        :  .Active [Nchannel x 1]
0023 %                        :  .Name   [Nchannel x 1]
0024 %                        :  .Type   [Nchannel x 1]
0025 %                        :  .ID     [Nchannel x 1]
0026 %                       not supported reference channel info.
0027 % [history]
0028 %   2018-08-22 (Takeda) initial version
0029 %
0030 % Copyright (C) 2011, ATR All Rights Reserved.
0031 % License : New BSD License(see VBMEG_LICENSE.txt)
0032 
0033 % --- CHECK ARGUMENTS --- %
0034 if ~exist('meg_file', 'var'), meg_file = ''; end
0035 if ~exist('active_swt', 'var'), active_swt = []; end
0036 [meg_file, active_swt] = ...
0037     inner_check_arguments(meg_file, active_swt);
0038 
0039 % --- MAIN PROCEDURE --------------------------------------------------------- %
0040 %
0041 channel_info = [];
0042 
0043 % --- meg channels
0044 load(meg_file, 'MEGinfo', 'pick', 'Qpick');
0045 
0046 CoilWeight = vb_meginfo_get_sensor_weight_meg(MEGinfo);
0047 
0048 if isfield(MEGinfo, 'Vcenter')
0049     Vcenter = MEGinfo.Vcenter;
0050 else
0051     Vcenter = [];
0052 end
0053 
0054 % ----- active filter
0055 ch_info_meg    = vb_load_channel_info(meg_file, 'MEG');
0056 active_channel = vb_info_get_active_channel(MEGinfo, 1);
0057 if isempty(active_channel)
0058     active_swt = false;
0059 end
0060 
0061 if ~active_swt
0062     channel_info = ch_info_meg;
0063     return;
0064 else
0065     active_idx = find(active_channel == 1);
0066     active_coil_idx = find(sum(abs(CoilWeight(active_idx, :)), 1) > 0);
0067     
0068     if ~isempty(pick)
0069         pick = pick(active_coil_idx, :);
0070     end
0071     
0072     if ~isempty(Qpick)
0073         Qpick = Qpick(active_coil_idx, :);
0074     end
0075     
0076     if ~isempty(CoilWeight)
0077         CoilWeight = CoilWeight(active_idx, active_coil_idx);
0078     end
0079 end
0080 channel_info.Active = ch_info_meg.Active(active_idx);
0081 channel_info.Name   = ch_info_meg.Name(active_idx);
0082 channel_info.Type   = ch_info_meg.Type(active_idx);
0083 channel_info.ID     = ch_info_meg.ID(active_idx);
0084 
0085 %
0086 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0087 
0088 % --- INNER FUNCTIONS -------------------------------------------------------- %
0089 %
0090 % --- inner_check_arguments()
0091 %
0092 function [meg_file, active_swt] = ...
0093     inner_check_arguments(meg_file, active_swt)
0094 func_ = mfilename;
0095 
0096 if isempty(meg_file)
0097     error('(%s) meg_file is a required parameter', func_);
0098 end
0099 
0100 if exist(meg_file, 'file') ~= 2
0101     error('(%s) cannot find meg_file (%s)', func_, meg_file);
0102 end
0103 
0104 if isempty(active_swt)
0105     active_swt = false;
0106 end
0107 return;
0108 %
0109 % --- end of inner_check_arguments()
0110 %
0111 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0112 
0113 % --- END OF FILE --- %
0114

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