detect_artifacts

detect_artifacts(data, Fs, varargin)

DETECT_ARTIFACTS Detect and remove artifacts in time series data

Usage:

artifacts = detect_artifacts(data, Fs, varargin)

Input:

data: <number of samples> x 1 vector - time series data – required Fs: double - sampling frequency in Hz – required

Optional Input Arguments:

‘isexcluded’: logical vector - indicates excluded data points that will be set as artifact (default: logical([])) ‘exclude_mode’: string - ‘data’ or ‘artifact’, determines if isexcluded time are treated as data

that are not factored in for the theshold detection or artifacts (default: ‘data’)

‘zscore_method’: char - method for z-score calculation (‘standard’:mean and std or ‘robust’: median and MAD) (default: ‘standard’) ‘hf_crit’: numeric - high-frequency artifact detection criterion (default: 4.5) ‘hf_pass’: numeric - high-frequency artifact passband frequency in Hz (default: 35) ‘bb_crit’: numeric - broadband artifact detection criterion (default: 4.5) ‘bb_pass’: numeric - broadband artifact passband frequency in Hz (default: 0.1) ‘hf_detrend’: logical - apply detrending to high-frequency artifacts (default: true) ‘bb_detrend’: logical - apply detrending to broadband artifacts (default: true) ‘slope_test’: logical - enable slope test for artifacts (default: false) ‘slope_crit’: numeric - slope threshold for the slope test (default: -0.5) ‘smooth_duration’: numeric - duration for data smoothing in seconds (default: 2) ‘detrend_duration’: numeric - duration for detrending in seconds (default: 300) ‘buffer_duration’: numeric - duration for adding buffer around detected artifacts in seconds (default: 0) ‘verbose’: logical - enable verbose mode (default: false) ‘diagnostic_plot’: logical - enable diagnostic plots (default: false) ‘histogram_plot’: logical - enable histogram plot during artifact detection (default: false) ‘return_filts_only’: logical - return filter parameters only (default: false) ‘hpFilt_high’: [] - high-pass filter design (default: []) ‘hpFilt_broad’: [] - broadband high-pass filter design (default: [])

Output:

artifacts: logical vector - indicates artifact time points

Example: To detect and remove artifacts in EEG data:

Fs = 1000; % Sampling Frequency data = randn(10000, 1); % Example EEG data

artifact = detect_artifacts_dev(data,Fs);

%Old version artifacts_old = detect_artifacts_dev(data, Fs, ‘zscore_method’,’standard’,’hf_crit’, 4.5,’bb_crit’, 4.5,’slope_test’,false);

Copyright 2024 Michael J. Prerau Laboratory. - http://www.sleepEEG.org

See also: multitaper_spectrogram_mex, get_chunks, consecutive_runs