What is the best way to load niftii images (.nii) using pytorch dataloader?

Save the nib file to h5 file. Create a list with [(h5_file_name,slice_no),(h5_file_name,slice_no)]. Iterate this using dataloader, during runtime read the h5 file again and take out the slice. Let me know if you understand this, else i will share the pseudocode.