Home > vbmeg > functions > device > vb_info_add_posfile_info.m

vb_info_add_posfile_info

PURPOSE ^

load position data from POS-MAT file and set to the appropriate field of

SYNOPSIS ^

function [info] = vb_info_add_posfile_info(info, posfile)

DESCRIPTION ^

 load position data from POS-MAT file and set to the appropriate field of
 MEGinfo or EEGinfo

 [usage]
   [info] = vb_info_add_posfile_info(info, posfile)

 [input]
      info : <optional> <<struct>> MEG or EEG information []
           :  if this is empty, program creates MEGinfo or EEGinfo.
   posfile : <optional> <<file>> POS-MAT file ''
           :   if this is empty, empty fields will be added to info

 [output]
      info : <<struct>> updated info

 [note]
   fields which wll be added are ...
     MRI_ID
     Vcenter
     Vradius
     device_info.TransInfo

 [history]
   2008-03-12 (Sako) initial version
   2011-02-08 (Sako) modified to set empty values when posfile is invalid
   2011-05-27 (Sako) modified according to the new data format
   2016-12-19 (rhayashi) change behavior when specified posfile not found(warn->error)

 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 [info] = vb_info_add_posfile_info(info, posfile)
0002 % load position data from POS-MAT file and set to the appropriate field of
0003 % MEGinfo or EEGinfo
0004 %
0005 % [usage]
0006 %   [info] = vb_info_add_posfile_info(info, posfile)
0007 %
0008 % [input]
0009 %      info : <optional> <<struct>> MEG or EEG information []
0010 %           :  if this is empty, program creates MEGinfo or EEGinfo.
0011 %   posfile : <optional> <<file>> POS-MAT file ''
0012 %           :   if this is empty, empty fields will be added to info
0013 %
0014 % [output]
0015 %      info : <<struct>> updated info
0016 %
0017 % [note]
0018 %   fields which wll be added are ...
0019 %     MRI_ID
0020 %     Vcenter
0021 %     Vradius
0022 %     device_info.TransInfo
0023 %
0024 % [history]
0025 %   2008-03-12 (Sako) initial version
0026 %   2011-02-08 (Sako) modified to set empty values when posfile is invalid
0027 %   2011-05-27 (Sako) modified according to the new data format
0028 %   2016-12-19 (rhayashi) change behavior when specified posfile not found(warn->error)
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('info', 'var'), info = []; end
0035 if ~exist('posfile', 'var'), posfile = []; end
0036 [info, posfile] = inner_check_arguments(info, posfile);
0037 
0038 % --- MAIN PROCEDURE --------------------------------------------------------- %
0039 %
0040 func_ = mfilename;
0041 
0042 def_coord = vb_define_coordinate;
0043 
0044 if isempty(posfile)
0045   fprintf('--- (%s)posfile is empty - only set empty fields\n', func_);
0046   return;
0047 end
0048 
0049 % ----- MRI_ID
0050 info.MRI_ID = vb_posfile_load_mrikey(posfile);
0051 
0052 % ----- TransInfo
0053 [info] = vb_info_set_transinfo(info, vb_posfile_load_transinfo(posfile));
0054 
0055 % ----- Vcenter, Vradius
0056 [center, radius, c_type] = vb_posfile_get_sphericalinfo(posfile);
0057 if ~strcmp(c_type, def_coord.COORDINATE_SPM_RIGHT_M)
0058   warning('(%s)The type of obtained center coordinate is %s', func_, c_type);
0059 end
0060 
0061 info.Vcenter = center;
0062 info.Vradius = radius;
0063 
0064 return;
0065 %
0066 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0067 
0068 % --- INNER FUNCTIONS -------------------------------------------------------- %
0069 %
0070 % --- inner_check_arguments()
0071 %
0072 function [info, posfile] = inner_check_arguments(info, posfile)
0073 func_ = mfilename;
0074 
0075 if isempty(info)
0076   % set empty fields
0077   info.Vcenter = [];
0078   info.Vradius = [];
0079   info.MRI_ID = '';
0080 end
0081 
0082 if isempty(posfile)
0083   % set empty fields
0084   info.Vcenter = [];
0085   info.Vradius = [];
0086   info.MRI_ID = '';
0087 
0088 elseif exist(posfile, 'file') ~= 2
0089   error('(%s)cannot find posfile : %s\n', func_, posfile);
0090   % set empty fields
0091   info.Vcenter = [];
0092   info.Vradius = [];
0093   info.MRI_ID = '';
0094   posfile = []; 
0095 end
0096 return;
0097 %
0098 % --- end of inner_check_arguments()
0099 %
0100 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0101 
0102 % --- END OF FILE --- %

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