def _remove_far_masked_data(self, mask, list_signals):
"""Remove unnecessary data which is masked
and far (> self.ordar) from the unmasked data.
"""
if mask is None:
return list_signals
selection = ~mask
# convolution with a delay kernel,
# so we keep the close points before the selection
kernel = np.ones(self.ordar * 2 + 1)
kernel[-self.ordar:] = 0.
delayed_selection = fftconvolve(selection, kernel[None, :],
mode='same')
# remove numerical error from fftconvolve
delayed_selection[np.abs(delayed_selection) < 1e-13] = 0.
time_selection = delayed_selection.sum(axis=0) != 0
epoch_selection = delayed_selection.sum(axis=1) != 0
if not np.any(time_selection) or not np.any(epoch_selection):
raise ValueError("The mask seems to hide everything.")
output_signals = []
for sig in list_signals:
if sig is not None:
sig = sig[..., epoch_selection, :]
sig = sig[..., :, time_selection]
output_signals.append(sig)
return output_signals
评论列表
文章目录