Skip to content

Commit

Permalink
Use import torchio as tio in some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Nov 23, 2020
1 parent 7a322b9 commit 20e40a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
29 changes: 14 additions & 15 deletions torchio/data/dataset.py
Expand Up @@ -22,35 +22,34 @@ class SubjectsDataset(Dataset):
:class:`torchio.data.subject.Subject`.
Args:
subjects: Sequence of instances of
subjects: List of instances of
:class:`~torchio.data.subject.Subject`.
transform: An instance of :class:`torchio.transforms.Transform`
that will be applied to each subject.
Example:
>>> from torchio import SubjectsDataset, ScalarImage, LabelMap, Subject
>>> from torchio.transforms import RescaleIntensity, RandomAffine, Compose
>>> subject_a = Subject(
... t1=ScalarImage('t1.nrrd',),
... t2=ScalarImage('t2.mha',),
... label=LabelMap('t1_seg.nii.gz'),
>>> import torchio as tio
>>> subject_a = tio.Subject(
... t1=tio.ScalarImage('t1.nrrd',),
... t2=tio.ScalarImage('t2.mha',),
... label=tio.LabelMap('t1_seg.nii.gz'),
... age=31,
... name='Fernando Perez',
... )
>>> subject_b = Subject(
... t1=ScalarImage('colin27_t1_tal_lin.minc',),
... t2=ScalarImage('colin27_t2_tal_lin_dicom',),
... label=LabelMap('colin27_seg1.nii.gz'),
>>> subject_b = tio.Subject(
... t1=tio.ScalarImage('colin27_t1_tal_lin.minc',),
... t2=tio.ScalarImage('colin27_t2_tal_lin_dicom',),
... label=tio.LabelMap('colin27_seg1.nii.gz'),
... age=56,
... name='Colin Holmes',
... )
>>> subjects_list = [subject_a, subject_b]
>>> transforms = [
... RescaleIntensity((0, 1)),
... RandomAffine(),
... tio.RescaleIntensity((0, 1)),
... tio.RandomAffine(),
... ]
>>> transform = Compose(transforms)
>>> subjects_dataset = SubjectsDataset(subjects_list, transform=transform)
>>> transform = tio.Compose(transforms)
>>> subjects_dataset = tio.SubjectsDataset(subjects_list, transform=transform)
>>> subject = subjects_dataset[0]
.. _NiBabel: https://nipy.org/nibabel/#nibabel
Expand Down
14 changes: 7 additions & 7 deletions torchio/data/subject.py
Expand Up @@ -15,24 +15,24 @@ class Subject(dict):
Example:
>>> from torchio import ScalarImage, LabelMap, Subject
>>> import torchio as tio
>>> # One way:
>>> subject = Subject(
... one_image=ScalarImage('path_to_image.nii.gz'),
... a_segmentation=LabelMap('path_to_seg.nii.gz'),
>>> subject = tio.Subject(
... one_image=tio.ScalarImage('path_to_image.nii.gz'),
... a_segmentation=tio.LabelMap('path_to_seg.nii.gz'),
... age=45,
... name='John Doe',
... hospital='Hospital Juan Negrín',
... )
>>> # If you want to create the mapping before, or have spaces in the keys:
>>> subject_dict = {
... 'one image': ScalarImage('path_to_image.nii.gz'),
... 'a segmentation': LabelMap('path_to_seg.nii.gz'),
... 'one image': tio.ScalarImage('path_to_image.nii.gz'),
... 'a segmentation': tio.LabelMap('path_to_seg.nii.gz'),
... 'age': 45,
... 'name': 'John Doe',
... 'hospital': 'Hospital Juan Negrín',
... }
>>> Subject(subject_dict)
>>> subject = tio.Subject(subject_dict)
"""

Expand Down

0 comments on commit 20e40a2

Please sign in to comment.