Skip to content

Can I inverse image after using 'tio.SubjectsDataset' and 'torch.utils.data.DataLoader'? #743

Answered by fepegar
Bigsealion asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @Bigsealion. That's a good question.

That feature is currently not implemented, but I will commit a patch in a second. After that, your code should work with a slight modification: use collate_fn=tio.utils.history_collate for the DataLoader.

import torchio as tio
from torch.utils.data import DataLoader

subject_a = tio.datasets.Colin27()
subjects_list = [subject_a]

# transform
onehot = tio.OneHot()
pad = tio.CropOrPad((96, 112, 96))
transforms = [onehot, pad]
transform = tio.Compose(transforms)

# load data by torch
subjects_dataset = tio.SubjectsDataset(subjects_list, transform=transform)
training_loader = DataLoader(
    subjects_dataset,
    collate_fn=tio.utils.history_collate,
)

Replies: 3 comments 12 replies

Comment options

You must be logged in to vote
3 replies
@fepegar
Comment options

@romainVala
Comment options

@fepegar
Comment options

Comment options

You must be logged in to vote
6 replies
@Bigsealion
Comment options

@fepegar
Comment options

@Bigsealion
Comment options

@fepegar
Comment options

@Bigsealion
Comment options

Answer selected by Bigsealion
Comment options

You must be logged in to vote
3 replies
@fepegar
Comment options

@fepegar
Comment options

@Bigsealion
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants