Visualise Data#
PyDicer’s visualise module will produce cross-sections of data objects and store them in .png
format within the data object directory. This is particularly useful for fast inspection of the data to ensure that nothing has gone wrong during conversion.
The visualise module can be run at any time after conversion. If you are using advanced features of PyDicer, such as auto-segmentation inference and object generation, you can run the visualise module following the generation of the new data objects to produce the cross-section .png
files.
[1]:
try:
from pydicer import PyDicer
except ImportError:
!pip install pydicer
from pydicer import PyDicer
from pathlib import Path
from pydicer.utils import fetch_converted_test_data
Setup PyDicer#
HNSCC data prepared for this example are downloaded and stored into a testdata_hnscc
directory. We will use this for our PyDicer working directory. We also initialise our PyDicer object.
[2]:
working_directory = fetch_converted_test_data("./testdata_hnscc", dataset="HNSCC")
pydicer = PyDicer(working_directory)
Working directory %s aready exists, won't download test data.
Visualise Data#
We simply call the visualise function of the visualise
module to produce the cross-sections.
Inspect some of the data object directories in testdata_hnscc/data
and look for the .png
cross-sections. The {hashed_uid}
in files named vis_{hashed_uid}.png
refers to a UID hash linking to the image being visualised. Visualisations are produced for: - Images - RT Structure Sets - RT Dose Grids
[3]:
pydicer.visualise.visualise()
17%|█▋ | 5/30 [00:39<03:03, 7.34s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
67%|██████▋ | 20/30 [01:40<00:24, 2.46s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
70%|███████ | 21/30 [01:40<00:16, 1.83s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
73%|███████▎ | 22/30 [01:40<00:10, 1.36s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
77%|███████▋ | 23/30 [01:40<00:07, 1.03s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
97%|█████████▋| 29/30 [02:07<00:04, 4.16s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
100%|██████████| 30/30 [02:07<00:00, 4.25s/objects, visualise]
Run for a single patient#
You can run the visualisation for only a single patient (or list of specific patients) by providing the patient
argument.
[4]:
pydicer.visualise.visualise(patient="HNSCC-01-0199")
83%|████████▎ | 5/6 [00:39<00:07, 7.36s/objects, visualise]/home/runner/.cache/pypoetry/virtualenvs/pydicer-pNPN9n62-py3.9/lib/python3.9/site-packages/pydicom/valuerep.py:443: UserWarning: Invalid value for VR DA: 'NaT'.
warnings.warn(msg)
100%|██████████| 6/6 [00:39<00:00, 6.64s/objects, visualise]
Avoid Re-generating Visualisation#
If you’ve added more data to your dataset, and want to avoid re-generating visualisations, set the force
argument to False
.
[5]:
pydicer.visualise.visualise(force=False)
100%|██████████| 30/30 [00:00<00:00, 394.89objects/s, visualise]
[ ]: