Package: pyplastimatch
PyPlastimatchPyPlastimatch is a python wrapper forPlastimatch, an ITK-based open source software designed for volumetric medical image processing and radiation therapy applications.The main reason behing the development of PyPlastimatch is being able to use the Plastimatch functions within python scripts without having to code usingos.systemorsubprocessall the time. Also, we are working on making the output of some of the functions Plastimatch implements for evaluation (e.g., Dice Coefficient and Hausdorff Distance) more pythonic/easily usable in python-based data analysis pipelines.Together with the wrapping functions, we are also developing simple but handy functions that can be used for quick data exploration (e.g., simple widgets based on ipywidgets) in ipython notebooks and JupyterLab.PyPlastimatch is completely independent from the main software Plastimatch, and it is being developed mainly for internal use. For this reason, most of the Plastimatch functions might be missing. If you would like to see something added or point out how we could improve anything in the wrapper, you are very welcome toopen an issue at the issue page.Table of ContentsInstall Via pipDependenciesPythonPlastimatchdcmqiUsage ExampleRun in a Docker ContainerFurther ReadingInstall ViapipPyPlastimatch can be installed via pip:pip install pyplastimatchDependenciesPythonIf you decide to clone the PyPlastimatch repository and not to install it withpip, in order to run the code as intended, all the python libraries found inrequirements.txtmust be installed. This can be done running the command:pip3 install -r requirements.txtPlastimatchSince PyPlastimatch is a python wrapper and doesn't include any processing code, Plastimatch must be installed on the machine separately.Ubuntu 20.04 LTSFor users running Ubuntu 20.04 LTS (and distributions that fetch the same packages), Plastimatch can be installed simply by running:sudo apt install plastimatchUbuntu 22.04 LTSUsers running Ubuntu 22.04 LTS will unfortunately not be able to install Plastimatch viaapt(seethis Issue on the official Plastimatch GitLab). To remedy this, we compiled a binary file for Ubuntu 22.04 LTS that you can findin our releasesand you can download running the following once PyPlastimatch is installed (from a Python3 shell):from pyplastimatch.utils.install import install_precompiled_binaries
install_precompiled_binaries()and, of course, its equivalent from CLI:RUN python3 -c 'from pyplastimatch.utils.install import install_precompiled_binaries; install_precompiled_binaries()'The plastimatch binary we provide was compiled dinamically, so it will not work without installing some dependencies (itkviapip, and some system dependencies that theinstall_precompiled_binaries()function takes care of automatically). Depending on the python version you are using and your environment (i.e., packages already installed), you might need to installitkviapipbefore installingpyplastimatch.In the future, we might support binaries pre-compiled statically, and for other distributions/OSs.Other OSsFor Windows users, Plastimatch can be installed followingthe guide at this webpage.Building from SourcePlastimatch can also be build from source followingthe guide at this webpage. The guide could be slightly outdated, but it should be enough to get you started.DCMQISome functions might be based on theDICOM for Quantitative Imaging (dcmqi) library, that must be installed separately (e.g., under Linux, download the latest release, move the content of thebinfolder underusr/local/bin, and make the files executable).Usage ExampleYou can try PyPlastimatch on Google Colab without installing anything. To open the Colab notebook, click here:Since Plastimatch and this wrapper are being used for the development of AI-base medical image analysis pipelines on theNIH CRDC Imaging Data Commonsplatform, some example notebooks using PyPlastimatch can be found at theIDC-Examples/notebooksrepository as well.Note: provided you have a Google Cloud Platform project correctly set up, you will be able to run this and all the other notebooks for free, entirely on the cloud. Should you find any issues with the notebooks or would like to learn more, you can get in touch here, on the IDC repositories, or theIDC forum.Ubuntu 22.04 LTS Plastimatch Docker ContainerIf you want to test Plastimatch for Ubuntu 22.04 LTS, you can use the Docker image we shared for this purpose underdockerfiles.Build the Docker ContainerTo build the Ubuntu 22.04 LTS Platimatch Docker container, run the following commands from the root of the PyPlastimatch repository:cd dockerfiles/

docker build --tag pypla_22.04 . --no-cacheRun the Docker ContainerAssuming the data you want to convert/manipulate with Plastimatch is stored at/home/dennis/Desktop/sample_data/, the Docker command to run will look like the followingdocker run --rm -it --entrypoint bash -v /home/dennis/Desktop/sample_data/:/app/data pypla_22.04This will mount the data directory to the container's/app/datadirectory, and you can then run Plastimatch commands from within the container. For example, if/home/dennis/Desktop/sample_data/is structured as follows:(base) dennis@W2-S1:~$ tree /home/dennis/Desktop/sample_data/ -L 1
/home/dennis/Desktop/sample_data/
└── dicomThen, once inside the container, you can run the following command to convert the DICOM files to a volume saved in the NRRD format:cd /app/data

plastimatch convert --input input_dcm/ --output-img test.nrrdFurther ReadingPaolo Zaffino's (un)"official" wrapper.Further discussion about the python-wrapping of Plastimatch can be found atthis discourse.slicer thread.