I am working with the MNIBITE 41 dataset which contains magnetic resonance (MR) and ultra sound (US) images of human brains.
Because the US only covers a small portion of the MR image I want to apply a sliding window (e.g. skimage.util.view_as_windows 69) over the 466x394 US and MR images so that I can remove empty patches from training.
I would now like to know where would be the best place to implement this type of preprocessing?

I can’t put this into the torch.utils.data.Dataset instance as __getitem__ would then return n-patches.
I can’t put this into the training loop as it the batch size would vary.

It may be best to put it somewhere right before the torch.utils.data.DataLoader but I don’t see how. Any suggestions?