Home > vbmeg > demo > test_scripts > vb_test_extract_emg.m

vb_test_extract_emg

PURPOSE ^

vb_test_extract_emg

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 vb_test_extract_emg
     ----- Trial onset extraction parameters for EMG ----- 
  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 = 'emg'
  parm.slope     = []
                    No meaning    if trig_type = 'voice' or 'emg'
  parm.condition : string describing condition
  parm.Pretrigger_ms : Pretrigger period   [msec]
  parm.Posttrigger_ms: Posttrigger period  [msec]

 --- Optional parameter for EMG onset                         [Default]
 parm.t_event  : minimum distance from previous onset event   [150 ms]
 parm.t_peak   : peak evaluation period for EMG peak value    []
 parm.status_level : level for 'ypeak'                        []
 --- Usually following parameters need not be changed
 parm.t_smooth : moving average window length                 [25 ms]
 parm.t_slope  : slope estimation period near onset           [25 ms]
                 if t_slope==0, zero cross point is not calculated
 parm.t_match  : time length for EMG and smoothed EMG match   [25 ms]
 parm.t_period : minimum period that smoothed EMG > threshold [50 ms]
 parm.p_val : P-value corresponding to the threshold          [0.0001, 0.0001]
              for [EMG, smooth(EMG)] 
 --- Condition for EMG onset
 1. Distance between EMG & smoothed EMG onset should be smaller than 't_match'
 2. Distance from previous onset should be larger than 't_event'
 3. Smoothed EMG should exceed threshold more than 't_period' length
 4. If 't_peak' is not empty,
    EMG should exceed 'ypeak' within 't_peak' period after onset
      ypeak = mean( local peak value > threshold)
    If 'status_level' is not empty,
      ypeak = max(y) * status_level 

 --- 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]

 2011-12-18  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_emg
0002 %     ----- Trial onset extraction parameters for EMG -----
0003 %  parm.data_file : Data file name         [string]
0004 %  parm.trig_file : Trial onset file name  [string]
0005 %  parm.status_ch : status channel name    [string]
0006 %  parm.trig_type = 'emg'
0007 %  parm.slope     = []
0008 %                    No meaning    if trig_type = 'voice' or 'emg'
0009 %  parm.condition : string describing condition
0010 %  parm.Pretrigger_ms : Pretrigger period   [msec]
0011 %  parm.Posttrigger_ms: Posttrigger period  [msec]
0012 %
0013 % --- Optional parameter for EMG onset                         [Default]
0014 % parm.t_event  : minimum distance from previous onset event   [150 ms]
0015 % parm.t_peak   : peak evaluation period for EMG peak value    []
0016 % parm.status_level : level for 'ypeak'                        []
0017 % --- Usually following parameters need not be changed
0018 % parm.t_smooth : moving average window length                 [25 ms]
0019 % parm.t_slope  : slope estimation period near onset           [25 ms]
0020 %                 if t_slope==0, zero cross point is not calculated
0021 % parm.t_match  : time length for EMG and smoothed EMG match   [25 ms]
0022 % parm.t_period : minimum period that smoothed EMG > threshold [50 ms]
0023 % parm.p_val : P-value corresponding to the threshold          [0.0001, 0.0001]
0024 %              for [EMG, smooth(EMG)]
0025 % --- Condition for EMG onset
0026 % 1. Distance between EMG & smoothed EMG onset should be smaller than 't_match'
0027 % 2. Distance from previous onset should be larger than 't_event'
0028 % 3. Smoothed EMG should exceed threshold more than 't_period' length
0029 % 4. If 't_peak' is not empty,
0030 %    EMG should exceed 'ypeak' within 't_peak' period after onset
0031 %      ypeak = mean( local peak value > threshold)
0032 %    If 'status_level' is not empty,
0033 %      ypeak = max(y) * status_level
0034 %
0035 % --- Save variables
0036 % status : status signal
0037 % status_val(m) = status value for m-th condition (m=1:Ncomdition)
0038 % trig(n)       : Onset time index for n-th trial
0039 % cond_id(n)    : Condition ID for n-th trial if there are multi condition
0040 % ix_trial(:,n) : Time index for n-th trial   [Tperiod x Ntrial]
0041 %                 Tperiod : # of time sample in one trial
0042 %                 Ntrial  : # of trials
0043 % parm : parameter setting
0044 % parm.fsamp : Sample Frequency [Hz]
0045 %
0046 % 2011-12-18  Masa-aki Sato
0047 %
0048 % Copyright (C) 2011, ATR All Rights Reserved.
0049 % License : New BSD License(see VBMEG_LICENSE.txt)
0050 
0051 clear all
0052 
0053 % --- root directry
0054 %root_dir  = [getenv('MATDATA') '/Finger_move/RH070222'];
0055 
0056 % --- data file names (base name without extension)
0057 data_id = 'RH070222a';
0058 
0059 % data file
0060 data_file  = [data_id '.mat'];
0061 
0062 parm.data_file  = [data_id '.meg.mat'];
0063 % Trial onset  file
0064 parm.trig_file  = [data_id '.trig.mat'];
0065 
0066 % --- Set condition list
0067 % EMG:226,227
0068 % 光 :240,241 (EMG-光は対応関係)
0069 parm.condition    = 'EMG';
0070 parm.status_ch    = '227';
0071 parm.trig_type    = 'emg';
0072 parm.slope        =  '' ;
0073 parm.Pretrigger_ms   = [ 100 ]; % [msec]
0074 parm.Posttrigger_ms  = [ 250 ]; % [msec]
0075 
0076 % --- Critical parameter (this value may be changed)
0077 parm.t_event  = 150;  % 150 ms
0078 parm.t_peak   = []; 
0079 parm.status_level = []; 
0080 
0081 % --- Default parameter for EMG onset
0082 %     Usually these parameters need not be changed
0083 parm.t_smooth = 25;  % 25 ms
0084 parm.t_slope  = 25;  % 25 ms
0085 parm.t_match  = 25;
0086 parm.t_period = 50;
0087 parm.p_val = [0.0001 0.0001];
0088 
0089 % --- Trial onset extraction
0090 if exist('root_dir') && ~isempty(root_dir)
0091     vb_job_trial_onset(root_dir,parm);
0092 else
0093     vb_test_job_trial_onset(data_file ,parm);
0094 end
0095 
0096 % --- Plot status signal and estimated onset
0097 plot_parm.mode  = 2; % = 1: plot all trial
0098                      % = 2: subplot for each trial
0099                      % = 3: multiple trials in one subplot
0100 plot_parm.NXmax = 2; % # of trial   in X-axis
0101 plot_parm.NYmax = 2; % # of subplot in Y-axis
0102 plot_parm.Ymax  = 0.4;
0103 plot_parm.Ymin  = 0;
0104 plot_parm.status= 1;
0105 
0106 plot_parm.Ntrial = []; % setting for plot all trials
0107 plot_parm.Ntrial = [3 8 20 24]; % # of trials for plot
0108 plot_parm.Ntrial = [2:2:16]; % # of trials for plot
0109 
0110 if exist('root_dir') && ~isempty(root_dir)
0111     fname = [root_dir '/' parm.trig_file ];
0112 else
0113     fname = [parm.trig_file ];
0114 end
0115 
0116 vb_plot_status(fname, plot_parm);

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