Home > vbmeg > functions > common > loadfunc > subdirectory > vb_load_measurement_info.m

vb_load_measurement_info

PURPOSE ^

load measurement info data (MEGinfo or EEGinfo)

SYNOPSIS ^

function [info, info_type] = vb_load_measurement_info(acq_file, info_type)

DESCRIPTION ^

 load measurement info data (MEGinfo or EEGinfo)
 [usage]
   [info, info_type] = vb_load_measurement_info(acq_file, info_type)
 [input]
    acq_file : <required> measurement file MEG-MAT or EEG-MAT file
   info_type : <optional> ('EEGINFO' or 'MEGINFO') ['<original type>']
             :  type of returned information struct (case-insensitive)
             :  if this is empty, return MEGinfo from MEG-MAT
             :  and EEGinfo from EEG-MAT
 [output]
        info : data the format of which is ...
             :  MEGinfo (info_type == 'MEGinfo') or
             :  EEGinfo (info_type == 'EEGinfo')
   info_type : used info_type
 [note]
   @see inner function : inner_convert_EEGinfo2MEGinfo(EEGinfo)
      <<MEGinfo>>       <<EEGinfo>>
     Nchannel      <-- Nchannel
     Nsample       <-- Nsample
     Pretrigger    <-- Pretrigger
     SampleFreq    <-- SampleFrequency
     Nrepeat       <-- Nrepeat
     Trial         <-- Trial
     Vcenter       <-- Vcenter
     Vradius       <-- Vradius
     MRI_ID        <-- MRI_ID
     MEGch_name    <-- ChannelName
     MEGch_id      <-- ChannelID
     ActiveChanel  <-- ActiveChannel
     ActiveTrial   <-- ActiveTrial
     device        <-- Device
     Measurement   <-- Measurement
     ChannelInfo   <-- ChannelInfo
     ExtraChannelInfo <-- ExtraChannelInfo
     saveman       <-- File (partially)
 [history]
   2006-12-13 (Sako) initial version
   2008-04-15 (Sako) thoroughly rewrote according to new specification
   2009-08-03 (Sako) added device field when EEG->MEG converting
   2009-08-10 (Sako) changed how to load MEGinfo, not to use vb_load_meg_info.m
   2011-05-30 (Sako) modified according to the new data format
   2011-08-19 (Sako) added checking empty 'File' field before EEG setting

 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, info_type] = vb_load_measurement_info(acq_file, info_type)
0002 % load measurement info data (MEGinfo or EEGinfo)
0003 % [usage]
0004 %   [info, info_type] = vb_load_measurement_info(acq_file, info_type)
0005 % [input]
0006 %    acq_file : <required> measurement file MEG-MAT or EEG-MAT file
0007 %   info_type : <optional> ('EEGINFO' or 'MEGINFO') ['<original type>']
0008 %             :  type of returned information struct (case-insensitive)
0009 %             :  if this is empty, return MEGinfo from MEG-MAT
0010 %             :  and EEGinfo from EEG-MAT
0011 % [output]
0012 %        info : data the format of which is ...
0013 %             :  MEGinfo (info_type == 'MEGinfo') or
0014 %             :  EEGinfo (info_type == 'EEGinfo')
0015 %   info_type : used info_type
0016 % [note]
0017 %   @see inner function : inner_convert_EEGinfo2MEGinfo(EEGinfo)
0018 %      <<MEGinfo>>       <<EEGinfo>>
0019 %     Nchannel      <-- Nchannel
0020 %     Nsample       <-- Nsample
0021 %     Pretrigger    <-- Pretrigger
0022 %     SampleFreq    <-- SampleFrequency
0023 %     Nrepeat       <-- Nrepeat
0024 %     Trial         <-- Trial
0025 %     Vcenter       <-- Vcenter
0026 %     Vradius       <-- Vradius
0027 %     MRI_ID        <-- MRI_ID
0028 %     MEGch_name    <-- ChannelName
0029 %     MEGch_id      <-- ChannelID
0030 %     ActiveChanel  <-- ActiveChannel
0031 %     ActiveTrial   <-- ActiveTrial
0032 %     device        <-- Device
0033 %     Measurement   <-- Measurement
0034 %     ChannelInfo   <-- ChannelInfo
0035 %     ExtraChannelInfo <-- ExtraChannelInfo
0036 %     saveman       <-- File (partially)
0037 % [history]
0038 %   2006-12-13 (Sako) initial version
0039 %   2008-04-15 (Sako) thoroughly rewrote according to new specification
0040 %   2009-08-03 (Sako) added device field when EEG->MEG converting
0041 %   2009-08-10 (Sako) changed how to load MEGinfo, not to use vb_load_meg_info.m
0042 %   2011-05-30 (Sako) modified according to the new data format
0043 %   2011-08-19 (Sako) added checking empty 'File' field before EEG setting
0044 %
0045 % Copyright (C) 2011, ATR All Rights Reserved.
0046 % License : New BSD License(see VBMEG_LICENSE.txt)
0047 
0048 % --- CHECK ARGUMENTS --- %
0049 if ~exist('acq_file', 'var'), acq_file = ''; end
0050 if ~exist('info_type', 'var'), info_type = ''; end
0051 [acq_file, info_type] = inner_check_arguments(acq_file, info_type);
0052 
0053 % --- MAIN PROCEDURE --------------------------------------------------------- %
0054 %
0055 func_ = mfilename;
0056 info = [];
0057 
0058 % ----- constants
0059 TYPE_EEGINFO = 'EEGINFO';
0060 TYPE_MEGINFO = 'MEGINFO';
0061 
0062 [measurement] = vb_load_device(acq_file);
0063 Measurement = upper(measurement);
0064 
0065 switch Measurement
0066   case  'MEG'
0067     load(acq_file, 'MEGinfo');
0068     
0069     if ~isfield(MEGinfo, 'Measurement')
0070       MEGinfo.Measurement = Measurement;
0071     end
0072     info = MEGinfo;
0073 
0074     switch  info_type
0075       case  TYPE_EEGINFO
0076         % not be implemented yet
0077         warning('not be implemented yet (MEGinfo-->EEGinfo)');
0078         return;
0079       case  TYPE_MEGINFO
0080         % nothing to do
0081         return;
0082       otherwise
0083         error('(%s)unknown info_type: %s', func_, info_type);
0084     end
0085 
0086   case  'EEG'
0087     load(acq_file, 'EEGinfo');
0088     if isempty(EEGinfo)
0089       error('invalid acq_file - no EEGinfo : %s', acq_file);
0090     end
0091 
0092     switch info_type
0093       case  TYPE_EEGINFO
0094         info = EEGinfo;
0095         return;
0096 
0097       case  TYPE_MEGINFO
0098         info = inner_convert_EEGinfo2MEGinfo(EEGinfo);
0099         return;
0100 
0101       otherwise
0102         error('(%s)unknown info_type: %s', func_, info_type);
0103     end
0104     
0105   case  'INFO'
0106     load(acq_file, 'fileinfo');
0107     info = vb_load_measurement_info(fileinfo.filename{1}, info_type);
0108     
0109   otherwise
0110     error('unknown Measurement : %s - maybe invalid measurement_file: %s', ...
0111       Measurement, measurement_file);
0112 end
0113 
0114 % --- INNER FUNCTIONS -------------------------------------------------------- %
0115 %
0116 % --- inner_convert_EEGinfo2MEGinfo()
0117 %
0118 %   returned fields of MEGinfo :
0119 %     Nchannel         <-- Nchannel
0120 %     Nsample          <-- Nsample
0121 %     Pretrigger       <-- Pretrigger
0122 %     SampleFreq       <-- SampleFrequency
0123 %     Nrepeat          <-- Nrepeat
0124 %     Trial            <-- Trial
0125 %     Vcenter          <-- Vcenter
0126 %     Vradius          <-- Vradius
0127 %     MRI_ID           <-- MRI_ID
0128 %     MEGch_name       <-- ChannelName
0129 %     MEGch_id         <-- ChannelID
0130 %     ActiveChannel    <-- ActiveChannel
0131 %     ActiveTrial      <-- ActiveTrial
0132 %     device           <-- Device
0133 %     Measurement      <-- Measurement
0134 %     ChannelInfo      <-- ChannelInfo
0135 %     ExtraChannelInfo <-- ExtraChannelInfo
0136 %     (saveman)        <-- File & DataType
0137 function MEGinfo = inner_convert_EEGinfo2MEGinfo(EEGinfo)
0138   if ~isfield(EEGinfo, 'Nchannel'),        EEGinfo.Nchannel = []; end
0139   if ~isfield(EEGinfo, 'Nsample'),         EEGinfo.Nsample = []; end
0140   if ~isfield(EEGinfo, 'Pretrigger'),      EEGinfo.Pretrigger = []; end
0141   if ~isfield(EEGinfo, 'SampleFrequency'), EEGinfo.SampleFrequency = []; end
0142   if ~isfield(EEGinfo, 'Nrepeat'),         EEGinfo.Nrepeat = []; end
0143   if ~isfield(EEGinfo, 'Trial'),           EEGinfo.Trial = []; end
0144   if ~isfield(EEGinfo, 'Vcenter'),         EEGinfo.Vcenter = []; end
0145   if ~isfield(EEGinfo, 'Vradius'),         EEGinfo.Vradius = []; end
0146   if ~isfield(EEGinfo, 'ChannelName'),     EEGinfo.ChannelName = []; end
0147   if ~isfield(EEGinfo, 'ChannelID'),       EEGinfo.ChannelID = []; end
0148   if ~isfield(EEGinfo, 'ActiveChannel'),   EEGinfo.ActiveChannel = []; end
0149   if ~isfield(EEGinfo, 'ActiveTrial'),     EEGinfo.ActiveTrial = []; end
0150   if ~isfield(EEGinfo, 'Device'),          EEGinfo.Device = []; end
0151   if ~isfield(EEGinfo, 'Measurement'),     EEGinfo.Measurement = []; end
0152   if ~isfield(EEGinfo, 'MRI_ID'),          EEGinfo.MRI_ID = []; end
0153   if ~isfield(EEGinfo, 'ChannelInfo'),     EEGinfo.ChannelInfo = []; end
0154   if ~isfield(EEGinfo, 'ExtraChannelInfo'),EEGinfo.ExtraChannelInfo = []; end
0155   if ~isfield(EEGinfo, 'File'),            EEGinfo.File = []; end
0156   if ~isfield(EEGinfo, 'DataType'),        EEGinfo.DataType = []; end
0157 
0158   MEGinfo.Nchannel      = EEGinfo.Nchannel;
0159   MEGinfo.Nsample       = EEGinfo.Nsample;
0160   MEGinfo.Pretrigger    = EEGinfo.Pretrigger;
0161   MEGinfo.SampleFreq    = EEGinfo.SampleFrequency;
0162   MEGinfo.Nrepeat       = EEGinfo.Nrepeat;
0163   MEGinfo.Trial         = EEGinfo.Trial;
0164   if isfield(EEGinfo, 'cond_id')
0165       MEGinfo.cond_id   = EEGinfo.cond_id;
0166   end
0167   MEGinfo.Vcenter       = EEGinfo.Vcenter;
0168   MEGinfo.Vradius       = EEGinfo.Vradius;
0169   MEGinfo.MEGch_name    = EEGinfo.ChannelName;
0170   MEGinfo.MEGch_id      = EEGinfo.ChannelID;
0171   MEGinfo.ActiveChannel = EEGinfo.ActiveChannel;
0172   MEGinfo.ActiveTrial   = EEGinfo.ActiveTrial;
0173   MEGinfo.device        = EEGinfo.Device;
0174   MEGinfo.Measurement   = EEGinfo.Measurement;
0175   MEGinfo.MRI_ID        = EEGinfo.MRI_ID;
0176   MEGinfo.ChannelInfo   = EEGinfo.ChannelInfo;
0177   MEGinfo.ExtraChannelInfo = EEGinfo.ExtraChannelInfo;
0178   if ~isempty(EEGinfo.File)
0179     MEGinfo.saveman.data_dir = ...
0180       [EEGinfo.File.OutputDir '/' EEGinfo.File.DataDir];
0181   else
0182     MEGinfo.saveman.data_dir = '';
0183   end
0184   
0185   if ~isempty(EEGinfo.DataType)
0186     MEGinfo.saveman.precision = EEGinfo.DataType(1);
0187   else
0188     MEGinfo.saveman.precision = '';
0189   end
0190   return;
0191 %
0192 % --- end of inner_convert_EEGinfo2MEGinfo()
0193 
0194 % --- inner_check_arguments()
0195 %
0196 function [acq_file, info_type] = inner_check_arguments(acq_file, info_type)
0197 func_ = mfilename;
0198 if isempty(acq_file)
0199   error('(%s)acq_file is a required parameter', func_);
0200 end
0201 
0202 if isempty(info_type)
0203   [measurement] = vb_load_device(acq_file);
0204   Measurement = upper(measurement);
0205   
0206   switch Measurement
0207     case 'MEG'
0208       info_type = 'MEGINFO';
0209     case 'EEG'
0210       info_type = 'EEGINFO';
0211     case  'INFO'
0212       load(acq_file, 'fileinfo');
0213       [Measurement2] = vb_load_device(fileinfo.filename{1});
0214       switch Measurement2
0215         case 'MEG'
0216           info_type = 'MEGINFO';
0217         case 'EEG'
0218           info_type = 'EEGINFO';
0219       end
0220     otherwise
0221       error('(%s)unexpected Measurement : %s', func_, Measurement);
0222   end
0223 else
0224   info_type = upper(info_type);
0225 end
0226 return;
0227 %
0228 % --- end of inner_check_arguments()
0229 
0230 % --- END OF FILE --- %

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