@@ -64,6 +64,15 @@ def __init__(self, raw, do_detrend=True, random_state=None):
64
64
self .ch_names_new = self .ch_names_original
65
65
self .channels_interpolate = self .original_channels
66
66
67
+ # Extra data for debugging
68
+ self ._extra_info = {
69
+ 'bad_by_deviation' : {},
70
+ 'bad_by_hf_noise' : {},
71
+ 'bad_by_correlation' : {},
72
+ 'bad_by_dropout' : {},
73
+ 'bad_by_ransac' : {}
74
+ }
75
+
67
76
# random_state
68
77
self .random_state = check_random_state (random_state )
69
78
@@ -207,6 +216,11 @@ def find_bad_by_deviation(self, deviation_threshold=5.0):
207
216
deviation_channels = self .channels_interpolate [deviation_channel_mask ]
208
217
for i in range (0 , len (deviation_channels )):
209
218
self .bad_by_deviation .append (self .ch_names_original [deviation_channels [i ]])
219
+ self ._extra_info ['bad_by_deviation' ].update ({
220
+ 'median_channel_deviation' : channel_deviationMedian ,
221
+ 'channel_deviation_sd' : channel_deviationSD ,
222
+ 'robust_channel_deviations' : robust_channel_deviation
223
+ })
210
224
211
225
def find_bad_by_hfnoise (self , HF_zscore_threshold = 5.0 ):
212
226
"""Determine noise of channel through high frequency ratio.
@@ -262,6 +276,11 @@ def find_bad_by_hfnoise(self, HF_zscore_threshold=5.0):
262
276
self .EEGData = np .transpose (EEG_filt )
263
277
for i in range (0 , len (HFNoise_channels )):
264
278
self .bad_by_hf_noise .append (self .ch_names_original [HFNoise_channels [i ]])
279
+ self ._extra_info ['bad_by_hf_noise' ].update ({
280
+ 'median_channel_noisiness' : noisiness_median ,
281
+ 'channel_noisiness_sd' : noiseSD ,
282
+ 'hf_noise_zscores' : zscore_HFNoise
283
+ })
265
284
266
285
def find_bad_by_correlation (
267
286
self , correlation_secs = 1.0 , correlation_threshold = 0.4 , frac_bad = 0.01
@@ -358,6 +377,17 @@ def find_bad_by_correlation(
358
377
dropout_channels_idx = np .argwhere (fraction_BadDropOutWindows > frac_bad )
359
378
dropout_channels_name = self .ch_names_original [dropout_channels_idx .astype (int )]
360
379
self .bad_by_dropout = [i [0 ] for i in dropout_channels_name ]
380
+ self ._extra_info ['bad_by_correlation' ] = {
381
+ 'max_correlations' : maximum_correlations ,
382
+ 'median_max_correlations' : np .median (maximum_correlations , axis = 1 ),
383
+ 'bad_window_fractions' : fraction_BadCorrelationWindows
384
+ }
385
+ self ._extra_info ['bad_by_dropout' ] = {
386
+ 'dropouts' : drop_out ,
387
+ 'bad_window_fractions' : fraction_BadDropOutWindows
388
+ }
389
+ self ._extra_info ['bad_by_deviation' ]['channel_deviations' ] = channel_deviations
390
+ self ._extra_info ['bad_by_hf_noise' ]['noise_levels' ] = noiselevels
361
391
362
392
def find_bad_by_SNR (self ):
363
393
"""Determine the channels that fail both by correlation and HF noise."""
@@ -426,7 +456,7 @@ def find_bad_by_ransac(
426
456
self .bad_by_deviation +
427
457
self .bad_by_dropout
428
458
)
429
- self .bad_by_ransac , _ = find_bad_by_ransac (
459
+ self .bad_by_ransac , ch_correlations = find_bad_by_ransac (
430
460
self .EEGData ,
431
461
self .sample_rate ,
432
462
self .signal_len ,
@@ -441,3 +471,7 @@ def find_bad_by_ransac(
441
471
channel_wise ,
442
472
self .random_state ,
443
473
)
474
+ self ._extra_info ['bad_by_ransac' ] = {
475
+ 'ransac_correlations' : ch_correlations ,
476
+ 'bad_window_fractions' : np .mean (ch_correlations < corr_thresh , axis = 0 )
477
+ }
0 commit comments