Skip to content

How to apply augmentation with parameters specific to each input image #885

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

You must be logged in to vote

Hi, @rhan93. You could create your own transform for this:

import torchio as tio

class ResampleZ:
    def __init__(self, sz):
        self.sz = sz
    def __call__(self, subject):
        sx, sy, _ = subject.spacing
        resample = tio.Resample((sx, sy, self.sz))
        resampled = resample(subject)
        return resampled

image = tio.datasets.FPG().t1
transforms = tio.RandomBlur(), ResampleZ(4)
transform = tio.Compose(transforms)
transformed = transform(image)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rhan93
Comment options

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