Autoscore

The autoscore function was originally based on  Delorme, Makeig, Sejnowski "Automatic Artifact Rejection for EEG Data Using High-Order Statistics and Independent Component Analysis" available with the EEG-LAB Matlab software which can be downloaded from www.cnl.salk.edu/arno/eeglab.html.  However, their joint probability method proved to be very computationally intensive and to remove much more data than hand scoring so this method is not recommended and the default value for JP_SIG_LEVEL has been set to -1 so that it will not normally be run.  Instead, autoscore currently uses simple straightforward maximum value and maximum slope thresholds to decide whether a trial segment (TRIAL_LENGTH seconds of data [default 0.5 sec]) is good or bad.  If either threshold is exceeded then the whole trial segment is marked as bad (and if MASK_ALL is set to 1 then that trial segment is marked bad for all channels).  Autoscore estimates the vertical EOG signal from default combinations of channels for either the 128 or 256 channel nets if MASK_BLINKS is set to 1 and if this signal exceeds MAX_VALUE_BLINKS in any trial segment then this trial is marked bad for all channels.  MAX_VAR and MIN_VAR thresholds can be set to detect bad (noisy) or flatlined channels.  KURT_Z_LEVEL can be used to set a threshold level for the Kurtosis which is an estimate of the peakyness of the data and thus an indicator of strong transient muscle activity.

 

 

function autoscore(dirname,datFileName,p1,v1,p2,v2,p3,v3,p4,v4,p5,v5,p6,v6,p7,v7,p8,v8,p9,v9,p10,v10,p11,v11, ...
p12,v12,p13,v13,p14,v14,p15,v15,p16,v16)
%
%function autoscore(dirname,datFileName,p1,v1,p2,v2,p3,v3,p4,v4,p5,v5,p6,v6,p7,v7,p8,v8,p9,v9,p10,v10,p11,v11, ...
% p12,v12,p13,v13,p14,v14,p15,v15,p16,v16)
% This function autoscores datFileName using the joint probability function method described
% in Delorme, Makeig, Sejnowski "Automatic Artifact Rejection for EEG Data Using High-Order
% Statistics and ICA. autoscore does not remove any scoring from the MASK file that is read in
% and writes out a new MASK file with _AS appended
% The following default parameters are used:
% TRIAL_LENGTH = 0.5; % length of trial in seconds
% TRIAL_FRACTION = 0.2;% use TRIAL_FRACTION largest absolute values to compute joint probability
% MAX_VAR = 4000.0; % threshold variance for bad channel
% MIN_VAR = 0.25; % low threshold for flatlined channel
% JP_SIG_LEVEL = 0.001; % Joint probability for trial must be < JP_SIG_LEVEL to be bad based on Poisson dist.
% set to -1 to skip this check
% KURT_Z_LEVEL = -1; % Z level for Kurtosis; set to -1 to skip Kurtosis check
% DEV_THRESHOLD = -1; % number of stdev from mean for bad trial; set to -1 to skip this check
% MAX_VALUE = -1; % simple maximum value threshold for bad trial
% MAX_SLOPE = -1; % simple maximum slope value threshold for bad trial
% MASK_ALL = -1; % if set to 1 (or any value >0) any bad channel data marks all channels bad
% MASK_BLINKS = -1; % if set to 1 (or any value >0) finds trials with values >MAX_VALUE_BLINKS
% on LVEOG = 26-127 or RVEOG = 8-126
% and marks all channels bad for bad trials found on L/RVEOG
% if some of these channels are bad it will try to get by on remaining good
% channels and revert to channels 3 and 24 if all of 8,26,126,127 are bad
% MAX_VALUE_BLINKS = 80.0; % threshold for blinks
% CHANNELS = []; % list of channels to do autoscoring on; useful if EKG channels present
% or if MASK_ALL = 1;
% LOWPASS = 0; % set to 1 to pass data through a 20 Hz lowpass filter prior to autoscoring
% HIGHPASS = 0; % set to 1 to pass data through a 0.5 Hz highpass filter prior to autoscoring
% MAX_STEP_OFFSET % set to positve value in microvolts to remove trials where difference between
% % consecutive 100 msec means (i.e. data step) is greater than MAX_STEP_OFFSET
%
%any of these parameters can be changed by calling autoscore with the parameter and its new value as arguments
%for example: autoscore('.','LIF029EO1_NO60.DAT','TRIAL_LENGTH',0.2) will set TRIAL_LENGTH to 0.2 seconds
%leaving datFileName empty will cause autoscore to process all the .DAT files in a directory:
% autoscore('.','','TRIAL_LENGTH',0.2)


% default parameters
TRIAL_LENGTH = 0.5; % length of trial in seconds
TRIAL_FRACTION = 0.2; % use TRIAL_FRACTION largest absolute values to compute joint probability
MAX_VAR = 4000.0; % threshold variance for bad channel
MIN_VAR = 0.25; % low threshold for flatlined channel
JP_SIG_LEVEL = -1; % Joint probability for trial must be < JP_SIG_LEVEL to be bad based on Poisson dist.
KURT_Z_LEVEL = -1; % Z level for Kurtosis
DEV_THRESHOLD = -1; % number of stdev from mean for bad trial
MAX_VALUE = -1; % simple maximum value threshold for bad trial
MAX_SLOPE = -1; % simple maximum slope value threshold for bad trial
MASK_ALL = -1; % if set to 1 (or any value >0) any bad channel data marks all channels bad
MASK_BLINKS = -1; % if set to 1 (or any value >0) finds trials with values >MAX_VALUE_BLINKS
% on LVEOG = 26-127 or RVEOG = 8-126
% and marks all channels bad for bad trials found on L/RVEOG
% if some of these channels are bad it will try to get by on remaining good
% channels and revert to channels 3 and 24 if all of 8,26,126,127 are bad
MAX_VALUE_BLINKS = 80.0; % threshold for blinks
CHANNELS = []; % list of channels to score; default = all
LOWPASS = 0; % default: no 20 Hz lowpass filter
HIGHPASS = 0; % default: no 0.5 Hz highpass filter
MAX_STEP_OFFSET = -1; % default: no check for step offsets
function autoscore(dirname,datFileName,p1,v1,p2,v2,p3,v3,p4,v4,p5,v5,p6,v6,p7,v7,p8,v8,p9,v9,p10,v10,p11,v11, ...
p12,v12,p13,v13,p14,v14,p15,v15,p16,v16)
%
%function autoscore(dirname,datFileName,p1,v1,p2,v2,p3,v3,p4,v4,p5,v5,p6,v6,p7,v7,p8,v8,p9,v9,p10,v10,p11,v11, ...
% p12,v12,p13,v13,p14,v14,p15,v15,p16,v16)
% This function autoscores datFileName using the joint probability function method described
% in Delorme, Makeig, Sejnowski "Automatic Artifact Rejection for EEG Data Using High-Order
% Statistics and ICA. autoscore does not remove any scoring from the MASK file that is read in
% and writes out a new MASK file with _AS appended
% The following default parameters are used:
% TRIAL_LENGTH = 0.5; % length of trial in seconds
% TRIAL_FRACTION = 0.2;% use TRIAL_FRACTION largest absolute values to compute joint probability
% MAX_VAR = 4000.0; % threshold variance for bad channel
% MIN_VAR = 0.25; % low threshold for flatlined channel
% JP_SIG_LEVEL = 0.001; % Joint probability for trial must be < JP_SIG_LEVEL to be bad based on Poisson dist.
% set to -1 to skip this check
% KURT_Z_LEVEL = -1; % Z level for Kurtosis; set to -1 to skip Kurtosis check
% DEV_THRESHOLD = -1; % number of stdev from mean for bad trial; set to -1 to skip this check
% MAX_VALUE = -1; % simple maximum value threshold for bad trial
% MAX_SLOPE = -1; % simple maximum slope value threshold for bad trial
% MASK_ALL = -1; % if set to 1 (or any value >0) any bad channel data marks all channels bad
% MASK_BLINKS = -1; % if set to 1 (or any value >0) finds trials with values >MAX_VALUE_BLINKS
% on LVEOG = 26-127 or RVEOG = 8-126
% and marks all channels bad for bad trials found on L/RVEOG
% if some of these channels are bad it will try to get by on remaining good
% channels and revert to channels 3 and 24 if all of 8,26,126,127 are bad
% MAX_VALUE_BLINKS = 80.0; % threshold for blinks
% CHANNELS = []; % list of channels to do autoscoring on; useful if EKG channels present
% or if MASK_ALL = 1;
% LOWPASS = 0; % set to 1 to pass data through a 20 Hz lowpass filter prior to autoscoring
% HIGHPASS = 0; % set to 1 to pass data through a 0.5 Hz highpass filter prior to autoscoring
% MAX_STEP_OFFSET % set to positve value in microvolts to remove trials where difference between
% % consecutive 100 msec means (i.e. data step) is greater than MAX_STEP_OFFSET
%
%any of these parameters can be changed by calling autoscore with the parameter and its new value as arguments
%for example: autoscore('.','LIF029EO1_NO60.DAT','TRIAL_LENGTH',0.2) will set TRIAL_LENGTH to 0.2 seconds
%leaving datFileName empty will cause autoscore to process all the .DAT files in a directory:
% autoscore('.','','TRIAL_LENGTH',0.2)

 

An example call to autoscore for the RESMRI baseline data is shown below:

autoscore('/exp/resmri/data/eeg/RES###A','RES###EC1_NO60.DAT','MAX_VALUE',75.0,'MAX_SLOPE',12.5,'MASK_BLINKS',1,'MAX_VALUE_BLINKS',75.0)


June 2004: Added parameter CHANNELS so that autoscoring can be limited to selected channels. This parameter is particularly useful when there are EKG or other non-EEG channels which do not need to be scored and  MASK_ALL is set to 1.

July 2004:  Added parameters LOWPASS and HIGHPASS so that  20 Hz lowpass or  0.5 Hz highpass filters can be applied to the data before autoscoring

August 2004:  Added parameter MAX_STEP_OFFSET which searches for step offsets in data greater than this value.  It does this by computing the mean value for the 100 ms ending on the sample to be tested and the mean for the next 100 ms.  If the difference between these means for any of the samples in trial epoch is greater than the MAX_STEP_OFFSET value then the epoch is marked as bad.

October 2005:  Added parameter VEOG_CHANNEL and changed to using varargin.  If VEOG_CHANNEL is set to dedicated VEOG channel then trials with values that exceed MAX_VALUE_BLINKS on this channel will cause all channels to be scored as bad for that trial.