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

vb_load_device

PURPOSE ^

load measurement file and get 'Measurement' and 'Device' information

SYNOPSIS ^

function [Measurement, Device] = vb_load_device(measurement_file)

DESCRIPTION ^

 load measurement file and get 'Measurement' and 'Device' information

 [usage]
   [Measurement, Device] = vb_load_device(measurement_file)

 [input]
   measurement_file : measurement file (e.g. meg_file)

 [output]
   Measurement : measurement
        Device : device

 [note]

 [history]
   2006-09-01 (Sako) initial version
   2007-02-21 (Sako) supported NIRS
   2011-06-01 (Sako) modified to return values without converting to upper case
   2012-07-13 (Sako) fixed an error in the case that MEG-MAT file does not
                     have 'Measurement' field properly.

 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 [Measurement, Device] = vb_load_device(measurement_file)
0002 % load measurement file and get 'Measurement' and 'Device' information
0003 %
0004 % [usage]
0005 %   [Measurement, Device] = vb_load_device(measurement_file)
0006 %
0007 % [input]
0008 %   measurement_file : measurement file (e.g. meg_file)
0009 %
0010 % [output]
0011 %   Measurement : measurement
0012 %        Device : device
0013 %
0014 % [note]
0015 %
0016 % [history]
0017 %   2006-09-01 (Sako) initial version
0018 %   2007-02-21 (Sako) supported NIRS
0019 %   2011-06-01 (Sako) modified to return values without converting to upper case
0020 %   2012-07-13 (Sako) fixed an error in the case that MEG-MAT file does not
0021 %                     have 'Measurement' field properly.
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 % --- CHECK ARGUMENTS --- %
0027 if ~exist('measurement_file', 'var'), measurement_file = ''; end
0028 if isempty(measurement_file)
0029   error('(%s) measurement_file is a required parameter', mfilename);
0030 end
0031 
0032 % initialize
0033 Measurement = '';
0034 
0035 [state, const] = ...
0036   vb_util_check_variable_in_matfile(measurement_file, 'Measurement');
0037 if state == const.VALID
0038   load(measurement_file, 'Measurement');
0039 end
0040 
0041 % load(measurement_file, 'M*');
0042 %
0043 % --- You can expect that 'Measurement' and 'MEGinfo' are loaded here.
0044 %
0045 
0046 % if ~exist('Measurement', 'var')
0047 if isempty(Measurement)
0048   % only old MEG-MAT files do not have 'Measurement' field.
0049   Measurement = 'MEG';
0050   load(measurement_file, 'MEGinfo');
0051   Device = inner_get_device_meg(MEGinfo);
0052   return;
0053 
0054 else
0055   measurement = upper(Measurement);
0056 
0057   switch measurement
0058     case  'MEG'
0059       meginfo = vb_megfile_load_meginfo(measurement_file);
0060       Device = inner_get_device_meg(meginfo);
0061       return;
0062             
0063     case  'EEG'
0064       eeginfo = vb_eegfile_load_eeginfo(measurement_file);
0065       Device = vb_eeginfo_get_device(eeginfo);
0066       return;
0067 
0068     case  'NIRS'
0069       load(measurement_file, 'device');
0070       Device = device;
0071       return;
0072       
0073     case  'INFO'
0074       %load(measurement_file,'fileinfo');
0075       Device = 'INFO';
0076       
0077     otherwise
0078       error('ERROR: unknown measurement is set : %s\n', measurement);
0079   end
0080 end
0081 return;
0082 
0083 % --- inner_get_device_meg()
0084 %
0085 function [device] = inner_get_device_meg(meginfo)
0086 device = vb_meginfo_get_device(meginfo);
0087 if isempty(device)
0088   % old fashioned
0089   device = 'SBI';
0090 end
0091 return;
0092 %
0093 % --- end of inner_get_device_meg()
0094 
0095 % --- END OF FILE --- %

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