Custom DataLoader using .mat file

Hello, I am trying to segment medical image and i need help on creating a DataLoader to take into a CNN .mat images. My main image and mask are saved in a same mat file. So, I need help to create custom dataloader to read the main image and mask from the same mat file. Thank you

Hi, please have a look at our tutorial and let us know what you have tried.

Thanks for your reply.
I have around 4000 mat files. Each mat file contains main image and mask which is shown in the following image. I have to make custom dataloader for this dataset to train the model.

Writing a custom Dataset as mentioned by @nivek sounds like the right approach and you could use e.g. to load each .mat file.