lescientifik/open_brats2020

Question with get_dataset function

jerofad opened this issue · 1 comments

Thanks for open sourcing your solution. I have a question regarding the get_dataset function here.

return train_dataset, bench_dataset

I see this returns the full train dataset with the images, labels and Ids. My question is regarding the patterns. How do I access the individual patterns. t1, t2 ... from the returned dataset. They seem to be all merged together .

Take a look at this code for instance,

trainset, bench_dataset = get_datasets(seed = 2345, debug=True, full=True)

train_loader = torch.utils.data.DataLoader(trainset, batch_size = 1, shuffle=True,
                                           num_workers=4)

batch = next(iter(train_loader)) 

targets = batch["label"]#.cuda(non_blocking=True)
real_images = batch["image"]#.cuda()
patient_id = batch["patient_id"]      #returns ['BraTS20_Training_001']
real_images.shape                    #returns ([1, 4, 128, 128, 128])
targets.shape                          # returns ([1, 3, 128, 128, 128])

I am interested in getting the (real_images, targets) for each particular scans (patterns). How to get that?

TIA

Each channel contains one of the IRM modality.

Looking at the source code, you can see that:
self.patterns = ["_t1", "_t1ce", "_t2", "_flair"]

For label:
patient_label = np.stack([et, tc, wt])

Channels should be in this order.

Anyway, if you really want to access the real_images, targets; you can just read it directly from disk