.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_include_exclude.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_include_exclude.py: Exclude images from transform ============================= In this example we show how the kwargs ``include`` and ``exclude`` can be used to apply a transform to only some of the images within a subject. .. GENERATED FROM PYTHON SOURCE LINES 8-25 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_plot_include_exclude_001.png :alt: t1 (sagittal), t2 (sagittal), pd (sagittal), mask (sagittal), t1 (coronal), t2 (coronal), pd (coronal), mask (coronal), t1 (axial), t2 (axial), pd (axial), mask (axial) :srcset: /auto_examples/images/sphx_glr_plot_include_exclude_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_plot_include_exclude_002.png :alt: t1 (sagittal), t2 (sagittal), pd (sagittal), mask (sagittal), t1 (coronal), t2 (coronal), pd (coronal), mask (coronal), t1 (axial), t2 (axial), pd (axial), mask (axial) :srcset: /auto_examples/images/sphx_glr_plot_include_exclude_002.png :class: sphx-glr-multi-img .. code-block:: Python import torch import torchio as tio torch.manual_seed(0) subject = tio.datasets.Pediatric(years=(4.5, 8.5)) subject.plot() transform = tio.Compose( [ tio.RandomAffine(degrees=(20, 30), exclude=['t1']), tio.RandomBlur(std=(3, 4), include=['t2']), ] ) transformed = transform(subject) transformed.plot() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.573 seconds) .. _sphx_glr_download_auto_examples_plot_include_exclude.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_include_exclude.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_include_exclude.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_include_exclude.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_