neurodsp.filt.utils.remove_filter_edges

neurodsp.filt.utils.remove_filter_edges(sig, filt_len)[source]

Drop the edges, by making NaN, from a filtered signal, to avoid edge artifacts.

Parameters
sig1d array

Filtered signal to have edge artifacts removed from.

filt_lenint

Length of the filter that was applied.

Returns
sig1d array

Filter signal with edge artifacts switched to NaNs.

Examples

Apply a filter and remove the filter edges of the filtered signal:

>>> from neurodsp.filt.fir import design_fir_filter, apply_fir_filter
>>> from neurodsp.sim import sim_combined
>>> sig = sim_combined(n_seconds=10, fs=500,
...                    components={'sim_powerlaw': {}, 'sim_oscillation' : {'freq': 10}})
>>> filter_coefs = design_fir_filter(fs=500, pass_type='bandpass', f_range=(1, 25))
>>> filt_sig = apply_fir_filter(sig, filter_coefs)
>>> filt_sig_no_edges = remove_filter_edges(filt_sig, filt_len=len(filter_coefs))