Home > functions > device > meg > vb_megfile_get_internal_data_ext.m

vb_megfile_get_internal_data_ext

PURPOSE ^

return extra data which is internally stored in megfile

SYNOPSIS ^

function [ext_data] = vb_megfile_get_internal_data_ext(megfile, ext_type)

DESCRIPTION ^

 return extra data which is internally stored in megfile
 [usage]
   [ext_data] = vb_megfile_get_internal_data_ext(megfile, ex_type)
 [input]
    megfile : <required> <<file>> MEG-MAT file
   ext_type : <optional> extra type [1]
            :  1) all the extra channels
            :  this type depend on MEGinfo.ExtraChannelInfo.Channel_type
            :  the case of YOKOGAWA data is as follows
            :    0) NULL CHANNEL
            :   -1) TRIGGER CHANNEL
            :   -2) EEG CHANNEL
            :   -3) ECG CHANNEL
            :   -4) ETC CHANNEL
 [output]
   ext_data : extra channel data which is stored in 'bexp_ext' field
            : [Nchannel x Nsample x Ntrial]
 [note]
   MEG-MAT file must have bexp_ext and MEGinfo.ExtraChannelInfo fields.
   This function does not provide data which is selected in sample and trial
 [history]
   2008-02-15 (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 [ext_data] = vb_megfile_get_internal_data_ext(megfile, ext_type)
0002 % return extra data which is internally stored in megfile
0003 % [usage]
0004 %   [ext_data] = vb_megfile_get_internal_data_ext(megfile, ex_type)
0005 % [input]
0006 %    megfile : <required> <<file>> MEG-MAT file
0007 %   ext_type : <optional> extra type [1]
0008 %            :  1) all the extra channels
0009 %            :  this type depend on MEGinfo.ExtraChannelInfo.Channel_type
0010 %            :  the case of YOKOGAWA data is as follows
0011 %            :    0) NULL CHANNEL
0012 %            :   -1) TRIGGER CHANNEL
0013 %            :   -2) EEG CHANNEL
0014 %            :   -3) ECG CHANNEL
0015 %            :   -4) ETC CHANNEL
0016 % [output]
0017 %   ext_data : extra channel data which is stored in 'bexp_ext' field
0018 %            : [Nchannel x Nsample x Ntrial]
0019 % [note]
0020 %   MEG-MAT file must have bexp_ext and MEGinfo.ExtraChannelInfo fields.
0021 %   This function does not provide data which is selected in sample and trial
0022 % [history]
0023 %   2008-02-15 (Sako) initial version
0024 %
0025 % Copyright (C) 2011, ATR All Rights Reserved.
0026 % License : New BSD License(see VBMEG_LICENSE.txt)
0027 
0028 % --- CHECK ARGUMENTS --- %
0029 if ~exist('megfile', 'var'), megfile = []; end
0030 if ~exist('ext_type', 'var'), ext_type = []; end
0031 [megfile, ext_type] = inner_check_arguments(megfile, ext_type);
0032 
0033 % --- MAIN PROCEDURE --------------------------------------------------------- %
0034 %
0035 func_ = mfilename;
0036 
0037 load(megfile, 'bexp_ext');
0038 if ~exist('bexp_ext', 'var')
0039   warning('(%s)megfile (%s) does not have bexp_ext field\n', func_, megfile);
0040   bexp_ext = [];
0041 end
0042 
0043 % initially set all the data
0044 ext_data = bexp_ext;
0045 
0046 if isempty(bexp_ext)
0047   % return as is
0048   return;
0049 end
0050 
0051 if ext_type == 0
0052   % return all the channels - not be extracted
0053   return;
0054 end
0055 
0056 meginfo = vb_megfile_load_meginfo(megfile);
0057 
0058 % conditional requirement
0059 if ~isfield(meginfo, 'ExtraChannelInfo')
0060   warning('(%s)meginfo must have ExtraChannelInfo field', func_);
0061   warning('(%s)return not be extracted data', func_);
0062   return;
0063 end
0064 
0065 % --- normal procedure
0066 
0067 ext_idx = vb_meginfo_get_channel_index_extra(meginfo, ext_type);
0068 ext_data = bexp_ext(ext_idx, :, :);
0069 return;
0070 %
0071 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0072 
0073 % --- INNER FUNCTIONS -------------------------------------------------------- %
0074 %
0075 % --- inner_check_arguments()
0076 %
0077 function [megfile, ext_type] = inner_check_arguments(megfile, ext_type)
0078 func_ = mfilename;
0079 
0080 if isempty(megfile)
0081   error('(%s)megfile is a required parameter', func_);
0082 end
0083 
0084 if exist(megfile, 'file') ~= 2
0085   error('(%s)cannot find megfile : %s', func_, megfile);
0086 end
0087 
0088 if isempty(ext_type)
0089   ext_type = 0;
0090 end
0091 return;
0092 %
0093 % --- end of inner_check_arguments()
0094 %
0095 % --- END OF INNER FUNCTIONS ------------------------------------------------- %
0096 
0097 %%% END OF FILE %%%

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005