cm_MWB_channel_x_epoch_artifacts_20170922.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. function [index parm zval] = cm_MWB_channel_x_epoch_artifacts_20170922(cfg,data)
  2. % 20170922 JQK extended padding to 20
  3. %% defaults
  4. if ~isfield(cfg,'criterion'); criterion = 3; else criterion = cfg.criterion; end
  5. if ~isfield(cfg,'recursive'); recursive = 1; else recursive = strcmp(cfg.recursive,'yes'); end
  6. % clear cfg
  7. clear cfg
  8. %% calculate parameters
  9. %% - kurtosis
  10. cfg.method = 'kurt';
  11. kurt = MWB_artfdetec_kurt(cfg,data);
  12. % clear cfg
  13. clear cfg
  14. %% - low frequencies
  15. cfg.method = 'freq';
  16. cfg.foi = [0.5 2];
  17. cfg.pad = 20;
  18. fft_low = MWB_artfdetec_freq(cfg,data);
  19. % clear cfg
  20. clear cfg
  21. %% - high frequencies
  22. cfg.method = 'freq';
  23. cfg.foi = [30 100];
  24. cfg.pad = 20;
  25. fft_hi = MWB_artfdetec_freq(cfg,data);
  26. % clear cfg
  27. clear cfg
  28. %% calculate stats
  29. % channels
  30. parm.c_kurt = kurt.chan.mean;
  31. zval.c_kurt = kurt.chan.zscore;
  32. parm.c_low = fft_low.chan.mean;
  33. zval.c_low = fft_low.chan.zscore;
  34. parm.c_high = fft_hi.chan.mean;
  35. zval.c_high = fft_hi.chan.zscore;
  36. % trials
  37. parm.t_kurt = kurt.trial.mean;
  38. zval.t_kurt = kurt.trial.zscore;
  39. parm.t_low = fft_low.trial.mean;
  40. zval.t_low = fft_low.trial.zscore;
  41. parm.t_high = fft_hi.trial.mean;
  42. zval.t_high = fft_hi.trial.zscore;
  43. %% find outlier
  44. % temporary zscores
  45. tmp = parm;
  46. % kurtosis outlier
  47. tmp.c_kurt = cm_outlier2nan_20140311(tmp.c_kurt,'>',criterion,recursive);
  48. tmp.t_kurt = cm_outlier2nan_20140311(tmp.t_kurt,'>',criterion,recursive);
  49. % low frequency outlier
  50. tmp.c_low = cm_outlier2nan_20140311(tmp.c_low,'>',criterion,recursive);
  51. tmp.t_low = cm_outlier2nan_20140311(tmp.t_low,'>',criterion,recursive);
  52. % high frequency outlier
  53. tmp.c_high = cm_outlier2nan_20140311(tmp.c_high,'>',criterion,recursive);
  54. tmp.t_high = cm_outlier2nan_20140311(tmp.t_high,'>',criterion,recursive);
  55. %% mark outlier
  56. index.c = find( isnan(tmp.c_kurt) | isnan(tmp.c_low) | isnan(tmp.c_high) );
  57. index.t = find( isnan(tmp.t_kurt) | isnan(tmp.t_low) | isnan(tmp.t_high) );