crop_and_resize
- selfeeg.augmentation.functional.crop_and_resize(x: ArrayLike, segments: int = 10, N_cut: int = 1, batch_equal: bool = True) ArrayLike[source]
crops some segments of the ArrayLike object.
Function is applied along the last dimension of the input ArrayLike object and is resized to its original dimension. To do that, crop_and_resize:
divides the last dimension of x into N segments
selects at random a subset segments
removes the selected segments from x
creates a new cropped version of x
resamples the new cropped version to the original dimension. For this part pchip interpolation with a uniform virtual grid is used.
- Parameters:
x (ArrayLike) – the input Tensor or Array. The last two dimensions must refer to the EEG recording (Channels x Samples).
segments (int, optional) –
The number of segments to consider when dividing the last dimension of x. This is not the number of segments to cut, but the number of segments in which the signal is partitioned (a subset of these segments will be removed based on N_cut).
Default = 10
N_cut (int, optional) –
The number of segments to cut, i.e. the number of segments to remove.
Default = 1
batch_equal (bool, optional) –
Whether to apply the same crop to all EEG record or not.
Default = True
- Returns:
x (ArrayLike) – The augmented version of the input Tensor or Array.
Example
>>> import torch >>> import selfeeg.augmentation as aug >>> x = torch.zeros(16,32,1024) + torch.sin(torch.linspace(0, 8*torch.pi,1024)) >>> xaug = aug.crop_and_resize(x,32, 15)