@@ -238,13 +238,11 @@ def _plot_ica_properties(
238238
239239 # image and erp
240240 # we create a new epoch with dropped rows
241- epoch_data = epochs_src .get_data (copy = False )
242- epoch_data = np .insert (
243- arr = epoch_data ,
244- obj = (dropped_indices - np .arange (len (dropped_indices ))).astype (int ),
245- values = 0.0 ,
246- axis = 0 ,
247- )
241+ src_data = epochs_src .get_data (copy = False )
242+ n = len (src_data ) + len (dropped_indices )
243+ epoch_data = np .zeros ((n ,) + (src_data .shape [1 :]), dtype = src_data .dtype )
244+ use_idx = np .setdiff1d (np .arange (n ), dropped_indices )
245+ epoch_data [use_idx ] = src_data
248246 from ..epochs import EpochsArray
249247
250248 epochs_src = EpochsArray (
@@ -283,9 +281,11 @@ def _plot_ica_properties(
283281 range (len (epoch_var )), epoch_var , alpha = 0.5 , facecolor = [0 , 0 , 0 ], lw = 0
284282 )
285283 # rejected epochs in red
284+ # TODO: This can't be right as the variance is computed on the good/remaining
285+ # epochs, so these are by necessity zero
286286 var_ax .scatter (
287287 dropped_indices ,
288- epoch_var [ dropped_indices ] ,
288+ 0 ,
289289 alpha = 1.0 ,
290290 facecolor = [1 , 0 , 0 ],
291291 lw = 0 ,
@@ -610,7 +610,6 @@ def _fast_plot_ica_properties(
610610 )
611611 del reject
612612 ica_data = np .swapaxes (data [:, picks , :], 0 , 1 )
613- dropped_src = ica_data
614613
615614 # spectrum
616615 Nyquist = inst .info ["sfreq" ] / 2.0
@@ -656,16 +655,6 @@ def set_title_and_labels(ax, title, xlab, ylab):
656655
657656 # we reconstruct an epoch_variance with 0 where indexes where dropped
658657 epoch_var = np .var (ica_data [idx ], axis = 1 )
659- drop_var = np .var (dropped_src [idx ], axis = 1 )
660- drop_indices_corrected = (
661- dropped_indices - np .arange (len (dropped_indices ))
662- ).astype (int )
663- epoch_var = np .insert (
664- arr = epoch_var ,
665- obj = drop_indices_corrected ,
666- values = drop_var [dropped_indices ],
667- axis = 0 ,
668- )
669658
670659 # the actual plot
671660 fig = _plot_ica_properties (
@@ -772,7 +761,7 @@ def _prepare_data_ica_properties(inst, ica, reject_by_annotation=True, reject="a
772761 )
773762 # getting dropped epochs indexes
774763 if drop_inds is not None :
775- dropped_indices = [(d [0 ] // len (epochs_src .times )) + 1 for d in drop_inds ]
764+ dropped_indices = [(d [0 ] // len (epochs_src .times )) for d in drop_inds ]
776765 kind = "Segment"
777766 else :
778767 drop_inds = None
0 commit comments