Home > vbmeg > demo > test_scripts > vb_test_extract_trial_voice.m

vb_test_extract_trial_voice

PURPOSE ^

vb_test_extract_trial_voice

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 vb_test_extract_trial_voice
     ----- 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 = 'integer' or 'analog' or 'voice' or 'emg'
  parm.slope = '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','emg'
  parm.condition : string describing condition [string or cell array]
  parm.status_level : status level      [1 x Ncomdition]
  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_voice
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 = 'integer' or 'analog' or 'voice' or 'emg'
0008 %  parm.slope = 'const_start' or 'const_end'    if trig_type = 'integer'
0009 %               'low_to_high' or 'high_to_low'  if trig_type = 'analog'
0010 %               No meaning                      if trig_type = 'voice','emg'
0011 %  parm.condition : string describing condition [string or cell array]
0012 %  parm.status_level : status level      [1 x Ncomdition]
0013 %  parm.Pretrigger_ms : Pretrigger period   [msec]
0014 %  parm.Posttrigger_ms: Posttrigger period  [msec]
0015 % --- Save variables
0016 % status : status signal
0017 % status_val(m) = status value for m-th condition (m=1:Ncomdition)
0018 % trig(n)       : Onset time index for n-th trial
0019 % cond_id(n)    : Condition ID for n-th trial if there are multi condition
0020 % ix_trial(:,n) : Time index for n-th trial   [Tperiod x Ntrial]
0021 %                 Tperiod : # of time sample in one trial
0022 %                 Ntrial  : # of trials
0023 % parm : parameter setting
0024 % parm.fsamp : Sample Frequency [Hz]
0025 %
0026 % 2009-6-14  Masa-aki Sato
0027 %
0028 % Copyright (C) 2011, ATR All Rights Reserved.
0029 % License : New BSD License(see VBMEG_LICENSE.txt)
0030 
0031 clear all
0032 
0033 % --- root directry
0034 root_dir  = [getenv('MATHOME') '/Sekiyama'];
0035 % --- List of data file names (base name without extension)
0036 data_file = {'AM090311a'};
0037 % data file extension
0038 ext = '.meg.mat';
0039 
0040 plot_parm.mode  = 1; % = 1: plot all trial
0041                      % = 2: subplot for each trial
0042                      % = 3: multiple trials in one subplot
0043 plot_parm.NXmax = 4; % # of trial   in X-axis
0044 plot_parm.NYmax = 4; % # of subplot in Y-axis
0045 
0046 % --- Set condition list
0047 % 432; ボタン押し 4 (Ba)
0048 % 434; ボタン押し 2 (Ga)
0049 % 435; 刺激提示 mik_B (movieの開始で立ち上がる)
0050 % 436; 刺激提示 mik_G
0051 % 437; 刺激提示 ter_B
0052 % 438; 刺激提示 ter_G
0053 % 442; 音声
0054 condition    = {'voice', 'mik_B', 'mik_G', 'ter_B', 'ter_G' };
0055 status_ch    = { '442',  '435',   '436',   '437',   '438'   };
0056 trig_type    = {'voice', 'analog','analog','analog','analog'};
0057 slope        = {'','low_to_high','low_to_high','low_to_high','low_to_high'};
0058 status_level = [ 0.02, 0.5 ,  0.5 ,  0.5 ,  0.5 ] ;
0059 Pretrigger_ms   = [ 500 ,    0,    0,    0,    0]; % [msec]
0060 Posttrigger_ms  = [ 500 ,  500,  500,  500,  500]; % [msec]
0061 
0062 Nfile = length(data_file);
0063 Ncond = length(condition);
0064 Ncond = 2;
0065 
0066 % --- Trial onset extraction start
0067 for n=1:Nfile
0068     % MEG mat file
0069     parm.data_file  = [data_file{n} ext];
0070     
0071     for m=1:Ncond
0072         % m-th condition
0073         parm.condition    = condition{m};
0074         parm.status_ch    = status_ch{m};
0075         parm.trig_type    = trig_type{m};
0076         parm.slope        = slope{m};
0077         
0078         parm.status_level = status_level(m);
0079         parm.Pretrigger_ms   = Pretrigger_ms(m);
0080         parm.Posttrigger_ms  = Posttrigger_ms(m);
0081         
0082         % Trial onset  file
0083         parm.trig_file  = [data_file{n} '_' condition{m} '.trig.mat'];
0084         
0085         % Get time index for each trial by checking status channel
0086         vb_job_trial_onset(root_dir,parm);
0087         
0088         if plot_parm.mode > 0,
0089             % png file name
0090             fpng = [root_dir '/' data_file{n} '_' condition{m} ];
0091             %plot_parm.png = fpng;
0092             
0093             vb_plot_status([root_dir '/' parm.trig_file ], plot_parm);
0094         end
0095     end
0096 end
0097 
0098 % --- Extract intersection of 'voice' and 'movie' condition
0099 for n=1:Nfile
0100     for m=2:Ncond
0101         % Trial onset  file
0102         fname1 = [root_dir '/' data_file{n} '_' condition{1} ];
0103         fname2 = [root_dir '/' data_file{n} '_' condition{m} '.trig.mat'];
0104         fout   = [fname1 '_' condition{m} '.trig.mat'];
0105         fname1 = [fname1 '.trig.mat'];
0106 
0107         % Extract trials of file1 which are also included in trials of file2
0108         vb_extract_trial_cond(fname1,fname2,fout);
0109         
0110         if plot_parm.mode > 0,
0111             % png file name
0112             fpng = [fname1 '_' condition{m} ];
0113             plot_parm.png = fpng;
0114             
0115             vb_plot_status(fout, plot_parm);
0116         end
0117     end
0118 end

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