Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Path type option for Resample target argument (Issue #132) #134

Merged
merged 3 commits into from
Apr 27, 2020

Conversation

GFabien
Copy link
Contributor

@GFabien GFabien commented Apr 24, 2020

Change Resample transform to accept an external reference image as a Path object. Convenient when all samples have to be resampled to a given template. (see #132)

Usage:

from pathlib import Path
import torchio
from torchio.transforms import Resample

transform = Resample(Path('template.nii.gz'))
subject = torchio.Subject(t1=torchio.Image('t1.nii.gz', torchio.INTENSITY))
dataset = torchio.ImagesDataset([subject], transform=transform)

Change Resample to accept an external reference image as a Path object.
Update docstring.
Add test.
@fepegar
Copy link
Owner

fepegar commented Apr 24, 2020

Hi again, @GFabien. I think it's not a good idea to make a decision based on whether the argument is of type str or Path, as paths are still most often given as strings nowadays.

I think the way to go is passing a key name to the transform (as I suggested here). If the value for that key is an Image, that is the reference. If it's a str/Path, that image will be loaded and used as reference.

What do you think?

@GFabien
Copy link
Contributor Author

GFabien commented Apr 27, 2020

Ok I think I misunderstood your point. I totally agree with you, here is my new suggestion.

@fepegar fepegar merged commit 4c38812 into fepegar:master Apr 27, 2020
@fepegar
Copy link
Owner

fepegar commented Apr 27, 2020

Thanks again @GFabien!

@GFabien GFabien deleted the resample_with_external_reference branch April 27, 2020 13:12
@fepegar
Copy link
Owner

fepegar commented May 15, 2020

@all-contributors please add @GFabien for code

@allcontributors
Copy link
Contributor

@fepegar

I've put up a pull request to add @GFabien! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants