Home > vbmeg > demo > test_scripts > yokogawa_readfunc > vb_read_yokogawa_data.m

vb_read_yokogawa_data

PURPOSE ^

This function reads yokogawa data file and returns meg and eeg data.

SYNOPSIS ^

function [bexp, eeg, meg_info] = vb_read_yokogawa_data(fid, meg_info)

DESCRIPTION ^

 This function reads yokogawa data file and returns meg and eeg data.
 eeg data format is defined here.

 Usage : [bexp, eeg, meg_info] = vb_read_yokogawa_data(fid, meg_info);

 [IN]
    fid : file id
    meg_info : yokogawa data header infomation

 [OUT]
    bexp(NChannel, Tsample, Nrepeat)  : measured fields [A/D value]
    eeg(Nchannel, Tsample, Nrepeat)   : measured EEG data
    meg_info
         .EEGinfo  % This structure includes channel name and 'eeg' data index
            .all_ch_name       : all channel name
            .all_ch_ix         :  -  data index
            .eeg_ch_name       : eeg channel name
            .eeg_ch_ix         :  -  data index
            .null_ch_name      : null channel name
            .null_ch_ix        :  -  data index
            .etc_ch_name       : etc channel name
            .etc_ch_ix         :  -  data index
            .trigger_ch_name   : trigger channel name
            .trigger_ch_ix     :    -    data index
            .ecg_ch_name       : ecg channel name
            .ecg_ch_ix         :  -  data index
            .refmg_ch_name     : refference magnetometer channel name
            .refmg_ch_ix       :                 -  data index

 2006/11/30 rhayashi : modified EEGinfo.*_ch_name(use yokogawa channel name).
                       added refmg field.

 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:

SOURCE CODE ^

0001 function [bexp, eeg, meg_info] = vb_read_yokogawa_data(fid, meg_info)
0002 % This function reads yokogawa data file and returns meg and eeg data.
0003 % eeg data format is defined here.
0004 %
0005 % Usage : [bexp, eeg, meg_info] = vb_read_yokogawa_data(fid, meg_info);
0006 %
0007 % [IN]
0008 %    fid : file id
0009 %    meg_info : yokogawa data header infomation
0010 %
0011 % [OUT]
0012 %    bexp(NChannel, Tsample, Nrepeat)  : measured fields [A/D value]
0013 %    eeg(Nchannel, Tsample, Nrepeat)   : measured EEG data
0014 %    meg_info
0015 %         .EEGinfo  % This structure includes channel name and 'eeg' data index
0016 %            .all_ch_name       : all channel name
0017 %            .all_ch_ix         :  -  data index
0018 %            .eeg_ch_name       : eeg channel name
0019 %            .eeg_ch_ix         :  -  data index
0020 %            .null_ch_name      : null channel name
0021 %            .null_ch_ix        :  -  data index
0022 %            .etc_ch_name       : etc channel name
0023 %            .etc_ch_ix         :  -  data index
0024 %            .trigger_ch_name   : trigger channel name
0025 %            .trigger_ch_ix     :    -    data index
0026 %            .ecg_ch_name       : ecg channel name
0027 %            .ecg_ch_ix         :  -  data index
0028 %            .refmg_ch_name     : refference magnetometer channel name
0029 %            .refmg_ch_ix       :                 -  data index
0030 %
0031 % 2006/11/30 rhayashi : modified EEGinfo.*_ch_name(use yokogawa channel name).
0032 %                       added refmg field.
0033 %
0034 % Copyright (C) 2011, ATR All Rights Reserved.
0035 % License : New BSD License(see VBMEG_LICENSE.txt)
0036 
0037 
0038 % --- modifying 2007-04-20 (Sako) ---------------------------------------------
0039 % sako_test = true;
0040 sako_test = false;
0041 
0042 if sako_test
0043   % --- read MEG
0044   save_spec = [];
0045   bexp = acqdata_read(fid, meg_info, save_spec);
0046 
0047   % --- read EEG in MEG
0048   Nsample    = meg_info.Nsample;
0049   Nrepeat    = meg_info.Nrepeat; % number of trial
0050   
0051   eeg_ch_name = meg_info.EEGinfo.all_ch_name;
0052   Neeg_ch = length(eeg_ch_name);
0053 
0054   % allocate
0055   eeg = zeros(Neeg_ch, Nsample+1, Nrepeat); % +1 is for channel name
0056 
0057   % search eeg data index in bexp
0058   eeg_data_ix_in_bexp  = [];
0059   for k=1:Neeg_ch
0060     eeg_data_ix_in_bexp = ...
0061      [eeg_data_ix_in_bexp; find( bexp(:, 1, 1) == eeg_ch_name(k) )];
0062   end
0063 
0064   % eeg data from bexp
0065   eeg(meg_info.EEGinfo.all_ch_ix, :, :) = bexp(eeg_data_ix_in_bexp, :, :);
0066                         
0067   bexp = bexp(meg_info.MEGch_id, :, :); % remove except MEG channel
0068   meg_info.MEGch_id = [1:length(meg_info.MEGch_id)]';
0069 
0070   bexp(:, 1, :) = []; % remove channel name
0071   eeg(:, 1, :) = []; % remove channel name
0072 
0073 else
0074 
0075 Nchannel   = meg_info.nch0;
0076 Nsample    = meg_info.Nsample;
0077 Nrepeat    = meg_info.Nrepeat; % number of trial
0078 SampleFreq = meg_info.SampleFreq;
0079 
0080 %
0081 % --- Read MEG data
0082 %
0083 bexp = zeros(Nchannel, Nsample+1, Nrepeat); % +1 is for channel name
0084 
0085 switch(meg_info.acq_type)
0086     case 'Continuous_Raw'
0087         % 1:continuous raw data
0088         bexp(:, :, 1) = GetMeg160ContinuousRawDataM(fid, 0, Nsample);
0089     case 'Evoked_Ave'
0090         % 2:evoked averaged data
0091         for trialN=1:Nrepeat
0092             bexp(:, :, trialN) = GetMeg160EvokedAverageDataM(fid, 0, Nsample);
0093         end
0094     case 'Evoked_Raw'
0095         % 3:evoked raw data
0096         for trialN=1:Nrepeat
0097             bexp(:, :, trialN) = GetMeg160EvokedRawDataM(fid, trialN-1, 1);
0098         end
0099 end
0100 %
0101 % --- Read EEG data
0102 %
0103 eeg_ch_name = meg_info.EEGinfo.all_ch_name;
0104 Neeg_ch = length(eeg_ch_name);
0105 
0106 % allocate
0107 eeg = zeros(Neeg_ch, Nsample+1, Nrepeat); % +1 is for channel name
0108 
0109 % search eeg data index in bexp
0110 eeg_data_ix_in_bexp  = [];
0111 for k=1:Neeg_ch
0112     eeg_data_ix_in_bexp = ...
0113         [eeg_data_ix_in_bexp; find( bexp(:, 1, 1) == eeg_ch_name(k) )];
0114 end
0115 
0116 % eeg data from bexp
0117 eeg(meg_info.EEGinfo.all_ch_ix, :, :) = bexp(eeg_data_ix_in_bexp, :, :);
0118                         
0119 bexp = bexp(meg_info.MEGch_id, :, :); % remove except MEG channel
0120 meg_info.MEGch_id = [1:length(meg_info.MEGch_id)]';
0121 
0122 bexp(:, 1, :) = []; % remove channel name
0123 eeg(:, 1, :) = []; % remove channel name
0124 
0125 end % sako_test

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