.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_single_image.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_single_image.py: Plot a 3D image =============== This example shows how to plot a single 3D image. .. GENERATED FROM PYTHON SOURCE LINES 9-11 Download the images ------------------- .. GENERATED FROM PYTHON SOURCE LINES 11-36 .. code-block:: Python import tarfile import urllib.request from pathlib import Path url = "https://aramislab.paris.inria.fr/clinicadl/files/handbook_2023/data_oasis/BIDS_example.tar.gz" data_path = Path("data") data_path.mkdir(exist_ok=True) download_path = data_path / "BIDS_example.tar.gz" urllib.request.urlretrieve(url, download_path) with tarfile.open(download_path, "r:gz") as tar: tar.extractall(path=data_path) image_path = ( data_path / "data_oasis" / "BIDS_example" / "sub-OASIS10016" / "ses-M000" / "anat" / "sub-OASIS10016_ses-M000_T1w.nii.gz" ) image_path.exists() .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/tuto-doc/tuto-doc/examples/plot_single_image.py:23: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior. tar.extractall(path=data_path) True .. GENERATED FROM PYTHON SOURCE LINES 37-41 Plot the raw image ------------------ Let's plot the sagittal and coronal axes of the image: .. GENERATED FROM PYTHON SOURCE LINES 41-47 .. code-block:: Python from neuroplot.plot.single import SinglePlot plotter = SinglePlot(axes=[0, 1]) plotter.plot(img_path=image_path) .. image-sg:: /auto_examples/images/sphx_glr_plot_single_image_001.png :alt: plot single image :srcset: /auto_examples/images/sphx_glr_plot_single_image_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 48-52 Add transforms --------------- Let's add some noise to the image: .. GENERATED FROM PYTHON SOURCE LINES 52-57 .. code-block:: Python from neuroplot.transforms import Noise plotter = SinglePlot(axes=[0, 1], transforms=[Noise(std=200)]) plotter.plot(img_path=image_path) .. image-sg:: /auto_examples/images/sphx_glr_plot_single_image_002.png :alt: plot single image :srcset: /auto_examples/images/sphx_glr_plot_single_image_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.421 seconds) .. _sphx_glr_download_auto_examples_plot_single_image.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_single_image.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_single_image.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_single_image.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_