{"id":13812681,"url":"https://github.com/dave3d/dicom2stl","last_synced_at":"2025-04-05T18:11:51.057Z","repository":{"id":15936303,"uuid":"18678396","full_name":"dave3d/dicom2stl","owner":"dave3d","description":"Python script to extract a STL surface from a DICOM image series.","archived":false,"fork":false,"pushed_at":"2024-02-29T04:37:29.000Z","size":12164,"stargazers_count":187,"open_issues_count":7,"forks_count":65,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-04-27T09:16:17.731Z","etag":null,"topics":["dicom","dicom-series","isosurface","itk","simpleitk","stl","stl-surface","surface-mesh","volume","vtk"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dave3d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-11T15:15:01.000Z","updated_at":"2024-06-24T01:01:43.117Z","dependencies_parsed_at":"2024-02-27T21:30:08.840Z","dependency_job_id":"525eae71-b004-4f2b-b023-c6d7e9cd9507","html_url":"https://github.com/dave3d/dicom2stl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave3d%2Fdicom2stl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave3d%2Fdicom2stl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave3d%2Fdicom2stl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave3d%2Fdicom2stl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dave3d","download_url":"https://codeload.github.com/dave3d/dicom2stl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378152,"owners_count":20929297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dicom","dicom-series","isosurface","itk","simpleitk","stl","stl-surface","surface-mesh","volume","vtk"],"created_at":"2024-08-04T04:00:54.429Z","updated_at":"2025-04-05T18:11:51.013Z","avatar_url":"https://github.com/dave3d.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Python"],"readme":"dicom2stl\n=========\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dave3d/dicom2stl/main?filepath=examples%2FIsosurface.ipynb)\n![Python application](https://github.com/dave3d/dicom2stl/workflows/Python%20application/badge.svg)\n\nTutorial: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dave3d/dicom2stl/main?filepath=examples%2FTutorial.ipynb)\n\ndicom2stl is a script that takes a [Dicom](https://www.dicomstandard.org/about/)\nseries and generates a STL surface mesh.\n\nWritten by David T. Chen from the National Institute of Allergy \u0026 Infectious Diseases (NIAID),\ndchen@mail.nih.gov It is covered by the Apache License, Version 2.0:\n\u003e http://www.apache.org/licenses/LICENSE-2.0\n\nGetting Started\n===============\nThe 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/).\n\ndicom2stl and its dependencies can be installed using pip:\n\n\u003e pip install dicom2stl\n\nThe options for the main script, **dicom2stl**, can be seen by running it:\n\u003e dicom2stl --help\n\nOnce you have a DICOM image series zip you can run your first script (Ensure that the \".zip\" file is in the dicom2stl directory):\n\u003e dicom2stl -t tissue -o output.stl dicom.zip\n\nThis will create a .stl file named \"output.stl\" that extracted tissue from the DICOM image series.\n\nHow dicom2stl works\n======================\nThe script starts by reading in a series of 2-d images or a simple 3-d image.\nIt can read any format supported by ITK.  If the input name is a zip file or\na directory name, the script expects a single series of DCM images, all with\nthe \".dcm\" suffix.\n\nNote: if this script is run with the individual Dicom slices provided on the\ncommand line, the slices might not be ordered in the correct order.  It is\nbetter to provide a zip file or a directory, so ITK can determine the proper\nslice ordering.  Dicom slices are not necessarily ordered the same\nalphabetically as they are physically.  In the case of a zip file or directory,\nthe script loads using the\n[SimpleITK ImageSeriesReader](https://simpleitk.readthedocs.io/en/master/Examples/DicomSeriesReader/Documentation.html)\nclass, which orders the slices by their physical layout, not their alphabetical\nnames.\n\nThe primary image processing pipeline is as follows:\n* [Shrink](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1ShrinkImageFilter.html)\n...the volume to 256 max dim (enabled by default)\n* [Anisotropic smoothing](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1CurvatureAnisotropicDiffusionImageFilter.html)\n...(disabled by default)\n* [Double threshold filter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1DoubleThresholdImageFilter.html)\n...(enabled when tissue types are used)\n* [Median filter](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1MedianImageFilter.html)\n...(enabled for 'soft' and 'fat' tissue types)\n* [Pad](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1ConstantPadImageFilter.html)\n...the volume\n\nThe script has built in double threshold values for the 4 different tissue\ntypes (bone, skin, muscle, soft).  These values assume the input is DICOM with\nstandard CT Hounsfield units.  I determined these values experimentally on a\nfew DICOM test sets, so the values might not work as well on other images.\n\nThe volume is shrunk to 256 cubed or less for speed and polygon count reasons.\n\nAfter all the image processing is finished, the volume is converted to a VTK\nimage using sitk2vtk from SimpleITKUtilities.\n\nThen the following VTK pipeline is executed:\n* [Extract a surface mesh](https://vtk.org/doc/nightly/html/classvtkContourFilter.html)\n...from the VTK image\n* Apply the [clean mesh filter](https://vtk.org/doc/nightly/html/classvtkCleanPolyData.html)\n* [Remove small parts](https://vtk.org/doc/nightly/html/classvtkPolyDataConnectivityFilter.html)\n...which connect to little other parts\n* Apply the [smooth mesh filter](https://vtk.org/doc/nightly/html/classvtkSmoothPolyDataFilter.html)\n* Apply the [reduce mesh filter](https://vtk.org/doc/nightly/html/classvtkQuadricDecimation.html)\n* [Write out an STL file](https://vtk.org/doc/nightly/html/classvtkSTLWriter.html)\n\nThe amount of smoothing and mesh reduction can be adjusted via command line\noptions.  By default 25 iterations of smoothing is applied and the number of\nvertices is reduced by 90%.\n\nBasic Usage \u0026 Options\n========\n```\nusage: dicom2stl [-h] [--verbose] [--debug] [--output OUTPUT] [--meta META] [--ct] [--clean] [--temp TEMP] [--search SEARCH]\n                    [--type {skin,bone,soft_tissue,fat}] [--anisotropic] [--isovalue ISOVALUE] [--double DOUBLE_THRESHOLD] [--largest]\n                    [--rotaxis {X,Y,Z}] [--rotangle ROTANGLE] [--smooth SMOOTH] [--reduce REDUCE] [--clean-small SMALL]\n                    [--enable {anisotropic,shrink,median,largest,rotation}] [--disable {anisotropic,shrink,median,largest,rotation}]\n                    [filenames ...]\n```\nFor a definitive list of options, run:\n\u003e dicom2stl --help\n\n\nExamples\n========\n\nTo extract the type \"bone\" from a zip of dicom images to an output file \"bone.stl\":\n\u003e dicom2stl -t bone -o bone.stl dicom.zip\n\nTo extract the skin from a NRRD volume:\n\u003e dicom2stl -t skin -o skin.stl volume.nrrd\n\nTo extract a specific iso-value (128) from a VTK volume:\n\u003e dicom2stl -i 128 -o iso.stl volume.vtk\n\nTo extract soft tissue from a dicom series in directory and\napply a 180 degree Y axis rotation:\n\u003e dicom2stl --enable rotation -t soft_tissue -o soft.stl dicom_dir\n\nThe options for the script can be seen by running it:\n\u003e dicom2stl --help\n\nYou can try out an interactive Jupyter notebook via Binder:\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dave3d/dicom2stl/main?filepath=examples%2FIsosurface.ipynb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave3d%2Fdicom2stl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdave3d%2Fdicom2stl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave3d%2Fdicom2stl/lists"}