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

neuromag_load_ch_info

PURPOSE ^

load channel information from data-fiffile

SYNOPSIS ^

function [ch_info,pos_info] = neuromag_load_ch_info(fiffile)

DESCRIPTION ^

 load channel information from data-fiffile
 [USAGE]
    [ch_info] = neuromag_load_ch_info(<fiffile>);
 [IN]
    fiffile : neuromag data fiffile.
 [OUT]
    ch_info : includes channel information and transform matrix
             .Nch      [double]
                 : The number of channels.
             .channel_ix   [Nch x 1 double]
                 : MEG channel name list.
             .sensort_type [Nch x 1 double]
                 : sensor type list
             .coil_type    {Nch x 1 cell}
                 : coil type string list
                   ex. coil_type{1} = 'VV_PLANAR_T1'
             .trans_coil2head   : {Nch x 1}
                 : transformation matrix (COIL  ==> HEAD)
                   trans_coil2head{n} = [4x4 double]
             .trans_coil2device : {Nch x 1}
                 : transformation matrix list (COIL  ==> DEVICE)
                   trans_coil2device{n} = [4x4 double]
             .trans_device2head : [4 x 4 double]
                 : transformation matrix (DEVICE  ==> HEAD)

    pos_info : fitting points in head coordinate
             .fiducial : fiducial points (LPA, Nasion, RPA)
             .hpi : points used to fitting with MEG
             .head_point : head points used to fitting with MRI
             .eeg : EEG sensor position

  [rHead 1]   = [rCoil 1] * ch_info.trans_coil2head{n}'
  [rDevice 1] = [rCoil 1] * ch_info.trans_coil2device{n}'
  [rHead 1]   = [rDevise 1] * ch_info.trans_device2head{n}'

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

 2012/11/15 M.Fukushima
 * modified to import Henson dataset

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ch_info,pos_info] = neuromag_load_ch_info(fiffile)
0002 % load channel information from data-fiffile
0003 % [USAGE]
0004 %    [ch_info] = neuromag_load_ch_info(<fiffile>);
0005 % [IN]
0006 %    fiffile : neuromag data fiffile.
0007 % [OUT]
0008 %    ch_info : includes channel information and transform matrix
0009 %             .Nch      [double]
0010 %                 : The number of channels.
0011 %             .channel_ix   [Nch x 1 double]
0012 %                 : MEG channel name list.
0013 %             .sensort_type [Nch x 1 double]
0014 %                 : sensor type list
0015 %             .coil_type    {Nch x 1 cell}
0016 %                 : coil type string list
0017 %                   ex. coil_type{1} = 'VV_PLANAR_T1'
0018 %             .trans_coil2head   : {Nch x 1}
0019 %                 : transformation matrix (COIL  ==> HEAD)
0020 %                   trans_coil2head{n} = [4x4 double]
0021 %             .trans_coil2device : {Nch x 1}
0022 %                 : transformation matrix list (COIL  ==> DEVICE)
0023 %                   trans_coil2device{n} = [4x4 double]
0024 %             .trans_device2head : [4 x 4 double]
0025 %                 : transformation matrix (DEVICE  ==> HEAD)
0026 %
0027 %    pos_info : fitting points in head coordinate
0028 %             .fiducial : fiducial points (LPA, Nasion, RPA)
0029 %             .hpi : points used to fitting with MEG
0030 %             .head_point : head points used to fitting with MRI
0031 %             .eeg : EEG sensor position
0032 %
0033 %  [rHead 1]   = [rCoil 1] * ch_info.trans_coil2head{n}'
0034 %  [rDevice 1] = [rCoil 1] * ch_info.trans_coil2device{n}'
0035 %  [rHead 1]   = [rDevise 1] * ch_info.trans_device2head{n}'
0036 %
0037 % Copyright (C) 2011, ATR All Rights Reserved.
0038 % License : New BSD License(see VBMEG_LICENSE.txt)
0039 %
0040 % 2012/11/15 M.Fukushima
0041 % * modified to import Henson dataset
0042 
0043 %
0044 % --- Previous check
0045 %
0046 if ~exist('fiffile', 'var') || exist(fiffile, 'file') ~=2
0047     error('fiffile is invalid.');
0048 end
0049 
0050 %
0051 % --- Get Channel Info
0052 %
0053 
0054 % NUMBER : Channel ID numbers     [n x 1]
0055 %   NAME : Channel name matrix    [n x m]
0056 %   NAME(n,:) is a strings like  'MEG 0111'
0057 %      T : The transformation between 'COIL' and either
0058 %          'HEAD' or 'DEVICE' (@see MEGMODEL)
0059 %          {n x 1} : T{n} = [4x4 double]
0060 %   GRAD :
0061 %        : 0 for magnetometers, 1 for planar gradiometers [n x 1]
0062 %   TYPE : Names of the coil types {n x 1} like 'VV_PLANAR_T1'
0063 %  NOISE : Weighting factor for the coil types [n x 1]
0064 
0065 info = fiff_read_meas_info(fiffile);
0066 
0067 % Get info
0068 ix = strmatch('MEG', info.ch_names);
0069 NAME = [];
0070 T  = cell(0);     % coil information in head coordinate
0071 T2 = cell(0); % coil information in device coordinate
0072 GRAD = [];
0073 TYPE = [];
0074 NUMBER = [];
0075 
0076 for k=1:length(ix)
0077     NUMBER   = [NUMBER; info.chs(k).logno];
0078     NAME     = [NAME; info.ch_names{ix(k)}];
0079     T{k, 1}  = info.dev_head_t.trans * info.chs(k).coil_trans;
0080     T2{k, 1} = info.chs(k).coil_trans;
0081     GRAD     = [GRAD; neuromag_get_sensor_kind(info.chs(k).coil_type)];
0082     TYPE     = [TYPE; info.chs(k).coil_type];
0083 end
0084 
0085 %[NOISE]           = chaninfo('noise');
0086 
0087 % Get fitting point info in head coordinate
0088 X     = [info.dig.r];
0089 xtype = [info.dig.kind]';
0090 
0091 % make structure of ch_info
0092 ch_info.Nch         = length(ix);
0093 ch_info.sensor_type = GRAD;
0094 ch_info.coil_type   = TYPE; % ch_type; % TYPE;
0095 ch_info.trans_coil2device = T2;
0096 ch_info.trans_coil2head = T;
0097 ch_info.trans_device2head  = info.dev_head_t(1).trans;
0098 ch_info.channel_name = NAME;
0099 %ch_info.noise = NOISE;
0100 
0101 % Nch = length(NUMBER);
0102 Nch = ch_info.Nch;
0103 ch_info.channel_ix  = cell(Nch,1);
0104 for n=1:Nch
0105     ch_info.channel_ix{n}  = deblank(num2str(NUMBER(n)));
0106 end
0107 
0108 % Set fitting point info
0109 % xtype: (1=cardinal, 2=HPI, 3=EEG, 4=extra)
0110 ix = find(xtype == 1);
0111 pos_info.fiducial = X(:,ix)';
0112 ix = find(xtype == 2);
0113 pos_info.hpi = X(:,ix)';
0114 ix = find(xtype == 3);
0115 pos_info.eeg = X(:,ix)';
0116 ix = find(xtype == 4);
0117 pos_info.head_point = X(:,ix)';

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