From 1d7e56c8e4ab07995ddd678178a460862be27cd0 Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Wed, 28 Feb 2024 22:52:37 -0500 Subject: [PATCH] Update to use PyPI installed dicom2stl --- README.md | 35 ++++++++++++++--------------------- examples/Isosurface.ipynb | 11 ++++++----- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 8f2191b..9db8dfd 100755 --- a/README.md +++ b/README.md @@ -17,22 +17,15 @@ Getting Started =============== The script is written in Python and uses 4 external packages, [SimpleITK](https://simpleitk.readthedocs.io/en/master/), [SimpleITKUtilities](https://github.com/SimpleITK/SimpleITKUtilities), [VTK](https://vtk.org), and [pydicom](https://pydicom.github.io/). -Clone the repository to your local machine: +dicom2stl and its dependencies can be installed using pip: -> git clone https://github.com/dave3d/dicom2stl.git +> pip install dicom2stl -Then navigate into it: - -> cd dicom2stl - -Now install the dependencies using `pip` (ensure terminal has administrator privileges): -> pip install -r requirements.txt - -The options for the main script, **dicom2stl.py**, can be seen by running it: -> python dicom2stl.py --help +The options for the main script, **dicom2stl**, can be seen by running it: +> dicom2stl --help Once you have a DICOM image series zip you can run your first script (Ensure that the ".zip" file is in the dicom2stl directory): -> python dicom2stl.py -t tissue -o output.stl dicom.zip +> dicom2stl -t tissue -o output.stl dicom.zip This will create a .stl file named "output.stl" that extracted tissue from the DICOM image series. @@ -73,7 +66,7 @@ few DICOM test sets, so the values might not work as well on other images. The volume is shrunk to 256 cubed or less for speed and polygon count reasons. After all the image processing is finished, the volume is converted to a VTK -image using sitk2vtk.py. +image using sitk2vtk from SimpleITKUtilities. Then the following VTK pipeline is executed: * [Extract a surface mesh](https://vtk.org/doc/nightly/html/classvtkContourFilter.html) @@ -92,34 +85,34 @@ vertices is reduced by 90%. Basic Usage & Options ======== ``` -usage: dicom2stl.py [-h] [--verbose] [--debug] [--output OUTPUT] [--meta META] [--ct] [--clean] [--temp TEMP] [--search SEARCH] +usage: dicom2stl [-h] [--verbose] [--debug] [--output OUTPUT] [--meta META] [--ct] [--clean] [--temp TEMP] [--search SEARCH] [--type {skin,bone,soft_tissue,fat}] [--anisotropic] [--isovalue ISOVALUE] [--double DOUBLE_THRESHOLD] [--largest] [--rotaxis {X,Y,Z}] [--rotangle ROTANGLE] [--smooth SMOOTH] [--reduce REDUCE] [--clean-small SMALL] [--enable {anisotropic,shrink,median,largest,rotation}] [--disable {anisotropic,shrink,median,largest,rotation}] [filenames ...] ``` For a definitive list of options, run: -> python dicom2stl.py --help +> dicom2stl --help Examples ======== To extract the type "bone" from a zip of dicom images to an output file "bone.stl": -> python dicom2stl.py -t bone -o bone.stl dicom.zip +> dicom2stl -t bone -o bone.stl dicom.zip To extract the skin from a NRRD volume: -> python dicom2stl.py -t skin -o skin.stl volume.nrrd +> dicom2stl -t skin -o skin.stl volume.nrrd To extract a specific iso-value (128) from a VTK volume: -> python dicom2stl.py -i 128 -o iso.stl volume.vtk +> dicom2stl -i 128 -o iso.stl volume.vtk To extract soft tissue from a dicom series in directory and apply a 180 degree Y axis rotation: -> python dicom2stl.py --enable rotation -t soft_tissue -o soft.stl dicom_dir +> dicom2stl --enable rotation -t soft_tissue -o soft.stl dicom_dir The options for the script can be seen by running it: -> python dicom2stl.py --help +> dicom2stl --help You can try out an interactive Jupyter notebook via Binder: -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dave3d/dicom2stl/main?filepath=examples%2FIsosurface.ipynb) \ No newline at end of file +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dave3d/dicom2stl/main?filepath=examples%2FIsosurface.ipynb) diff --git a/examples/Isosurface.ipynb b/examples/Isosurface.ipynb index 5739e56..295137b 100644 --- a/examples/Isosurface.ipynb +++ b/examples/Isosurface.ipynb @@ -4,14 +4,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Using dicom2stl.py to extract an iso-surface from a volume" + "# Using dicom2stl to extract an iso-surface from a volume" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook gives a basic introduction to using the `'dicom2stl.py'` script to extract an iso-surface from a volume image." + "This notebook gives a basic introduction to using the `'dicom2stl'` script to extract an iso-surface from a volume image." ] }, { @@ -35,6 +35,7 @@ "!{sys.executable} -m pip install vtk\n", "!{sys.executable} -m pip install itkwidgets\n", "!{sys.executable} -m pip install pydicom\n" + "!{sys.executable} -m pip install dicom2stl\n" ] }, { @@ -100,7 +101,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Show the command line options for dicom2stl.py" + "## Show the command line options for dicom2stl" ] }, { @@ -109,7 +110,7 @@ "metadata": {}, "outputs": [], "source": [ - "!{'./dicom2stl/dicom2stl.py -h'}" + "!{'dicom2stl -h'}" ] }, { @@ -126,7 +127,7 @@ "metadata": {}, "outputs": [], "source": [ - "!{'./dicom2stl/dicom2stl.py -i 150 -o tetra.stl tetra.nii.gz'}" + "!{'dicom2stl -i 150 -o tetra.stl tetra.nii.gz'}" ] }, {