FilterBank
- class selfeeg.models.layers.FilterBank(Fs, Bands=9, Range=4, Type='Cheby2', StopRipple=30, PassRipple=3, RangeTol=2, SkipFirst=True)[source]
Filter bank layer of the FBCNet model.
Pytorch implementation of the Filter Bank layer used in the FBCNet model The layer applies a sequence of filters with different bandwidth; then, it concatenates each generated signal in the convolutional channel dimension. The expected input is a 3D tensor with size (Batch x Channels x Samples). The generated output is a a 4D tensor with size (Batch x Filters x Channels x Samples).
See the original paper for more info
- Parameters:
Fs (int or float) – The EEG sampling rate.
Bands (int, optional) –
The number of filters to apply to the original signal.
Default = 9
Range (int or float, optional) –
The passband of each filter, given in Hz.
Default = 4
Type (str, optional) –
The type of filter to use. Allowed arguments are the same as described in the get_filter_coeff() function of the selfeeg.augmentation.functional submodule (‘butter’, ‘ellip’, ‘cheby1’, ‘cheby2’)
Default = ‘cheby1’
StopRipple (int or float, optional) –
Ripple at stopband in decibel.
Default = 30
PassRipple (int or float, optional) –
Ripple at passband in decibel.
Default = 3
RangeTol (int or float, optional) –
The filter transition bandwidth in Hz.
Default = 2
SkipFirst (bool, optional) –
If True, skips the first filter with passband equal to [0, Range] Hz. The number of filters specified in Bands will still be preserved.
Default = True
Warning
Do not use too strict filter specs (e.g. narrow transition bandwidths, high stopband ripple, low passband ripple) as this can generate undesired outputs (nan values or incredibly high values).
Example
>>> from selfeeg.models import FilterBank >>> import torch >>> x = torch.randn(4, 8, 512) >>> mdl = FilterBank(128) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 9, 8, 512]) >>> print(torch.isnan(out).sum()) # shoud return 0