Home > vbmeg > demo > test_scripts > vb_test_extract_trial_integer.m

vb_test_extract_trial_integer

PURPOSE ^

vb_test_extract_trial_integer

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

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

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