Home > vbmeg > demo > test_scripts > vb_test_extract_trial_bit.m

vb_test_extract_trial_bit

PURPOSE ^

vb_test_extract_trial_bit.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 vb_test_extract_trial_bit.m    
 ----- Trial onset extraction ----- 
 --- Input
  parm.data_file : Data file name         [string]
  parm.trig_file : Trial onset file name  [string]
  parm.status_ch : status channel name    [string]
  parm.trig_type : trigger signal type    [string]
                 = 'integer' or 'analog' or 'voice' or 'bit' or 'emg'
  parm.slope : type of signal change  [string]
             = 'const_start' or 'const_end'    if trig_type = 'integer'
               'low_to_high' or 'high_to_low'  if trig_type = 'analog'/'bit'
                    No meaning                 if trig_type = 'voice'/'emg'
  parm.condition : string describing condition [string or cell array]
  parm.status_level : status level      [1 x Ncomdition]
                    = 2^n : n-th bit is checked, if trig_type = 'bit'
  parm.status_mask  : binary mask pattern for status signal [string]
                    = '11111111'; bit mask pattern to get integer
                    = '0000000011111111' : get lower 8 bit (high->low) 
  parm.status_offset  : offset value of status signal [double]
                      = - 6751232; biosemi offset value
  parm.Pretrigger_ms : Pretrigger period   [msec]
  parm.Posttrigger_ms: Posttrigger period  [msec]
 --- Save variables
 status : status signal
 status_val(m) = status value for m-th condition (m=1:Ncomdition)
 trig(n)       : Onset time index for n-th trial 
 cond_id(n)    : Condition ID for n-th trial if there are multi condition
 ix_trial(:,n) : Time index for n-th trial   [Tperiod x Ntrial]
                 Tperiod : # of time sample in one trial
                 Ntrial  : # of trials
 parm : parameter setting
 parm.fsamp : Sample Frequency [Hz]

 2009-6-14  Masa-aki Sato

 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 % vb_test_extract_trial_bit.m
0002 % ----- Trial onset extraction -----
0003 % --- Input
0004 %  parm.data_file : Data file name         [string]
0005 %  parm.trig_file : Trial onset file name  [string]
0006 %  parm.status_ch : status channel name    [string]
0007 %  parm.trig_type : trigger signal type    [string]
0008 %                 = 'integer' or 'analog' or 'voice' or 'bit' or 'emg'
0009 %  parm.slope : type of signal change  [string]
0010 %             = 'const_start' or 'const_end'    if trig_type = 'integer'
0011 %               'low_to_high' or 'high_to_low'  if trig_type = 'analog'/'bit'
0012 %                    No meaning                 if trig_type = 'voice'/'emg'
0013 %  parm.condition : string describing condition [string or cell array]
0014 %  parm.status_level : status level      [1 x Ncomdition]
0015 %                    = 2^n : n-th bit is checked, if trig_type = 'bit'
0016 %  parm.status_mask  : binary mask pattern for status signal [string]
0017 %                    = '11111111'; bit mask pattern to get integer
0018 %                    = '0000000011111111' : get lower 8 bit (high->low)
0019 %  parm.status_offset  : offset value of status signal [double]
0020 %                      = - 6751232; biosemi offset value
0021 %  parm.Pretrigger_ms : Pretrigger period   [msec]
0022 %  parm.Posttrigger_ms: Posttrigger period  [msec]
0023 % --- Save variables
0024 % status : status signal
0025 % status_val(m) = status value for m-th condition (m=1:Ncomdition)
0026 % trig(n)       : Onset time index for n-th trial
0027 % cond_id(n)    : Condition ID for n-th trial if there are multi condition
0028 % ix_trial(:,n) : Time index for n-th trial   [Tperiod x Ntrial]
0029 %                 Tperiod : # of time sample in one trial
0030 %                 Ntrial  : # of trials
0031 % parm : parameter setting
0032 % parm.fsamp : Sample Frequency [Hz]
0033 %
0034 % 2009-6-14  Masa-aki Sato
0035 %
0036 % Copyright (C) 2011, ATR All Rights Reserved.
0037 % License : New BSD License(see VBMEG_LICENSE.txt)
0038 
0039 clear all
0040 
0041 plot_parm.mode  = 1; % = 1: plot all trial
0042                      % = 2: subplot for each trial
0043                      % = 3: multiple trials in one subplot
0044 plot_parm.NXmax = 4; % # of trial   in X-axis
0045 plot_parm.NYmax = 4; % # of subplot in Y-axis
0046 
0047 % --- root directry
0048 root_dir  = [getenv('MATHOME') '/BCI_Tmp/eeg_data'];
0049 % --- data file names (base name without extension)
0050 data_file = {'Sako_20080903_1' , 'Sako_20080903_2'};
0051 % data file extension
0052 ext = '.eeg.mat';
0053 % onset file sufix
0054 onset_name = 'bit';
0055 
0056 % --- Set condition list
0057 parm.trig_type   = 'bit';
0058 parm.slope       = 'low_to_high';
0059 parm.condition   = { 'bit'};
0060 parm.status_level = [ 2^4] ; % check 4-th bit
0061 
0062 parm.status_ch   = {'Status'};
0063 parm.status_mask = '11111111'; % (high->low) bit mask pattern to get status
0064                                % = '0000000011111111' : get lower 8 bit
0065 parm.status_offset = - 6751232;% biosemi offset value
0066 
0067 parm.Pretrigger_ms  = 1000; % before trigger [msec]
0068 parm.Posttrigger_ms = 9000; % after trigger [msec]
0069 
0070 
0071 Nfile = length(data_file);
0072 
0073 % --- Trial onset extraction start
0074 for n=1:Nfile
0075     % MEG mat file
0076     parm.data_file  = [data_file{n} ext];
0077     
0078     % Trial onset  file
0079     parm.trig_file  = [data_file{n} '_' onset_name '.trig.mat'];
0080     
0081     % Get time index for each trial by checking status channel
0082     vb_job_trial_onset(root_dir,parm);
0083     
0084     if plot_parm.mode > 0,
0085         % png file name
0086         fpng = [root_dir '/' data_file{n} '_' onset_name ];
0087         plot_parm.png = []; %fpng;
0088         
0089         vb_plot_status([root_dir '/' parm.trig_file ], plot_parm);
0090     end
0091     
0092 end
0093 
0094 return

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