Home > vbmeg > functions > device > eeg > biosemi > vb_eeg_make_light_info.m

vb_eeg_make_light_info

PURPOSE ^

make eeg_light_info struct from acquisition files

SYNOPSIS ^

function [eeg_light_info] = vb_eeg_make_light_info(bdf_spec)

DESCRIPTION ^

 make eeg_light_info struct from acquisition files
 [usage]
   [eeg_light_info] = vb_eeg_make_light_info(bdf_spec)
 [input]
   bdf_spec : <required> <<struct>> light version of bdf_spec struct
            :  .bdf_file   <required> *.BDF file
            :  .digit_file <required> *.digit file
            :  .face_file  <required> *.face file
 [output]
   eeg_light_info : <struct>
     : Measurement           : measurement type 'EEG'
     : header                : Biosemi header informatons
     : ChannelLabel_hardware : channel label list of hardware
     : ChannelLabel_standard : standard channel label list
     : Nchannel              : number of channel of original data
     : SampleFrequency       : sample rate of original data [Hz]
     : RecordTime            : record time of original data [sec]
     : Nsample               : total number of sample
     :                               :  SampleFrequency * RecordTime
     : Coord                 : position coordinates of sensor [n_sensor x 3]
     : CoodType              : coordinates' information
 [note]
 
 [history]
   2007-08-31 (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 [eeg_light_info] = vb_eeg_make_light_info(bdf_spec)
0002 % make eeg_light_info struct from acquisition files
0003 % [usage]
0004 %   [eeg_light_info] = vb_eeg_make_light_info(bdf_spec)
0005 % [input]
0006 %   bdf_spec : <required> <<struct>> light version of bdf_spec struct
0007 %            :  .bdf_file   <required> *.BDF file
0008 %            :  .digit_file <required> *.digit file
0009 %            :  .face_file  <required> *.face file
0010 % [output]
0011 %   eeg_light_info : <struct>
0012 %     : Measurement           : measurement type 'EEG'
0013 %     : header                : Biosemi header informatons
0014 %     : ChannelLabel_hardware : channel label list of hardware
0015 %     : ChannelLabel_standard : standard channel label list
0016 %     : Nchannel              : number of channel of original data
0017 %     : SampleFrequency       : sample rate of original data [Hz]
0018 %     : RecordTime            : record time of original data [sec]
0019 %     : Nsample               : total number of sample
0020 %     :                               :  SampleFrequency * RecordTime
0021 %     : Coord                 : position coordinates of sensor [n_sensor x 3]
0022 %     : CoodType              : coordinates' information
0023 % [note]
0024 %
0025 % [history]
0026 %   2007-08-31 (Sako) initial version
0027 %
0028 % Copyright (C) 2011, ATR All Rights Reserved.
0029 % License : New BSD License(see VBMEG_LICENSE.txt)
0030 
0031 % --- CHECK ARGUMENTS --- %
0032 [bdf_file, digit_file, face_file, Vcenter] = inner_read_bdf_spec(bdf_spec);
0033 
0034 
0035 % --- MAIN PROCEDURE --------------------------------------------------------- %
0036 %
0037 [header, RecordTime, Nch, SampleRate, ChannelLabel_hardware] = ...
0038   inner_get_local_var_bdf_file(bdf_file);
0039 
0040 [SensorPosition, CoordType, ChannelLabel_standard] ...
0041   = inner_get_info_digit_file(digit_file);
0042 [Vcenter] = inner_get_info_face_file(face_file)
0043 
0044 
0045 eeg_light_info.measurement           = 'EEG';
0046 eeg_light_info.version               = 'LIGHT'
0047 eeg_light_info.header                = header;
0048 eeg_light_info.device                = 'BIOSEMI';
0049 eeg_light_info.ChannelLabel_hardware = ChannelLabel_hardware;
0050 eeg_light_info.Nchannel              = Nch;
0051 eeg_light_info.SampleFrequency       = SampleRate;
0052 eeg_light_info.RecordTime            = RecordTime;
0053 eeg_light_info.Nsample               = RecordTime * SampleRate;
0054 eeg_light_info.ChannelLabel_standard = ChannelLabel_standard;
0055 eeg_light_info = vb_eeginfo_set_sensor_position(eeg_light_info, SensorPosition);
0056 eeg_light_info.CoordType             = CoordType;
0057 eeg_light_info.Vcenter               = Vcenter;
0058 
0059 return;
0060 %
0061 % --- END OF MAIN PROCEDURE -------------------------------------------------- %
0062 
0063 % --- INNER FUNCTIONS -------------------------------------------------------- %
0064 %
0065 % --- inner_read_bdf_spec()
0066 %
0067 function [bdf_file, digit_file, face_file, Vcenter] = ...
0068   inner_read_bdf_spec(bdf_spec)
0069 
0070 vb_define_device;
0071 
0072 func_ = mfilename;
0073 
0074 %
0075 % --- BDF FILE
0076 %
0077 if ~isfield(bdf_spec, 'bdf_file') || isempty(bdf_spec.bdf_file)
0078   error('(%s)bdf_file is a required parameter of bdf_spec', func_);
0079 end
0080 
0081 bdf_file = bdf_spec.bdf_file;
0082 
0083 if exist(bdf_file, 'file') ~= 2
0084   error('(%s)cannot read bdf_file : %s', func_, bdf_file);
0085 end
0086 
0087 %
0088 % --- DIGIT FILE
0089 %
0090 if ~isfield(bdf_spec, 'digit_file') || isempty(bdf_spec.digit_file)
0091   error('(%s)digit_file is a required parameter of bdf_spec', func_);
0092 end
0093 
0094 digit_file = bdf_spec.digit_file;
0095 
0096 if exist(digit_file, 'file') ~= 2
0097   error('(%s)cannot read digit_file : %s', func_, digit_file);
0098 end
0099 
0100 %
0101 % --- FACE FILE
0102 %
0103 Vcenter = [];
0104 face_file = [];
0105 if ~isfield(bdf_spec, 'face_file') || isempty(bdf_spec.face_file)
0106   Vcenter = [0 0 0];
0107 else
0108   face_file = bdf_spec.face_file;
0109 
0110   if exist(digit_file, 'file') ~= 2
0111     warning('(%s)cannot read digit_file : %s', func_, digit_file);
0112     Vcenter = [0 0 0];
0113   end
0114 end
0115 %
0116 % --- end of inner_check_argument()
0117 
0118 % --- inner_get_local_var_bdf_file()
0119 %
0120 function [header, RecordTime, Nch, SampleRate, ChannelLabel_hardware] = ...
0121   inner_get_local_var_bdf_file(bdf_file)
0122 
0123 [DAT,H1] = vb_openbdf(bdf_file);
0124 
0125 % procedure parameters
0126 header     = DAT.Head;
0127 RecordTime = DAT.Head.NRec;
0128 Nch        = DAT.Head.NS;
0129 SampleRate = max(DAT.Head.SampleRate);
0130 
0131 ChannelLabel_hardware = cell(1,Nch);
0132 
0133 % get channel label for hardware
0134 for ch = 1:Nch
0135   ChannelLabel_hardware{ch} = deblank(DAT.Head.Label(ch,:));
0136 end
0137 %
0138 % --- end of inner_get_local_var_bdf_file()
0139 
0140 % --- inner_get_info_digit_file()
0141 %
0142 function [SensorPosition, CoordType, ChannelLabel] ...
0143   = inner_get_info_digit_file(digit_file)
0144 
0145 eeg_sensor = [];
0146 SensorPosition = [];
0147 CoordType = [];
0148 ChannelLabel = [];
0149 
0150 load(digit_file, 'eeg_sensor');
0151 
0152 if isempty(eeg_sensor)
0153   error('invalid digit_file:%s - cannot find eeg_sensor field', digit_file);
0154 end;
0155 if ~isfield(eeg_sensor, 'mri')
0156   error('invalid digit_file:%s - cannot find ''mri'' field', digit_file);
0157 end
0158 if ~isfield(eeg_sensor, 'name') 
0159   error('invalid digit_file:%s - cannot find ''name'' field', digit_file);
0160 end
0161 if ~isfield(eeg_sensor, 'coord_type_mri')
0162   error('invalid digit_file:%s - cannot find ''coord_type_mri'' field', digit_file);
0163 end
0164   
0165 SensorPosition = eeg_sensor.mri;
0166 CoordType = eeg_sensor.coord_type_mri;
0167   
0168 % eeg_sensor.name is [n_channel x 1];
0169 ChannelLabel = vb_util_arrange_list(eeg_sensor.name);
0170 return;
0171 %
0172 % --- end of inner_get_info_digit_file()
0173 
0174 % --- inner_get_info_face_file()
0175 %
0176 function [Vcenter] = inner_get_info_face_file(face_file)
0177 subject = [];
0178 load(face_file, 'subject');
0179 if isempty(subject)
0180   error('invalid face_file:%s - cannot find subject field', face_file);
0181 end
0182 if ~isfield(subject, 'spherical_head')
0183   error('invalid face_file:%s - cannot find spherical_head field', face_file);
0184 end
0185   
0186 if ~isfield(subject.spherical_head, 'Vcenter')
0187   error('invalid face_file:%s - cannot find Vcenter field', face_file);
0188 end
0189   
0190 Vcenter = subject.spherical_head.Vcenter;
0191 return;
0192 %
0193 % --- end of inner_get_info_face_file()
0194 
0195 %%% END OF FILE %%%

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