You can create your own dataset class by subclassing a dataset like so (minimal example):
class Lazy_Dataset(torch.utils.data.Dataset):

    def __init__(self, path):
        self.steps = [function that figures out the size of your dataset located in the path]
        self.path = path

    def __len__(self):
        return self.steps
    
    def __getitem__(self, idx):
        array = [function that loads your nifti file as a numpy array]
        data = torch.Tensor(array)
        label = [function that figures out your label]
        return data, label, idx

You can later create an instance of that dataset (and a dataloader) by calling:
mydataset = Lazy_Dataset(mypath)
mydataloader = torch.utils.data.DataLoader(mydataset, batch_size=24, shuffle=True)