Let me know if you want to hit the links ๐๏ธโโ๏ธ
dave3d / dicom2stl Goto Github PK
View Code? Open in Web Editor NEWPython script to extract a STL surface from a DICOM image series.
Python script to extract a STL surface from a DICOM image series.
C:\Users\Suraj\Documents\GitHub\dicom2stl>vtkpython dicom2stl.py -t bone -o bone.stl dicom
Temp dir: C:\Users\Suraj\AppData\Local\Temp\tmp0axtfnc7
Tissue type: bone
Thresholds: [200.0, 800.0, 1300.0, 1500.0]
Traceback (most recent call last):
File "dicom2stl.py", line 277, in
img, modality = loadLargestSeries(fname[0])
NameError: name 'loadLargestSeries' is not defined
cannot figure out a way to resolve this
already installed vtk and SimpleITK
C:\Users\Suraj\Documents\GitHub\dicom2stl>pip install SimpleITK
Collecting SimpleITK
Downloading SimpleITK-1.2.4-cp37-cp37m-win_amd64.whl (28.0 MB)
|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 28.0 MB 930 kB/s
Installing collected packages: SimpleITK
Successfully installed SimpleITK-1.2.4
conda install -c anaconda vtk
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
C:\Windows\system32>pip install vtk
Requirement already satisfied: vtk in c:\users\suraj\anaconda3\lib\site-packages (-PKG-VERSION)
Hello,
Are there sample .DCM files on which this script works, please? I ask because it does not seem to work on any of our .DCM files (brain T1 images).
Thank you very much!
Thank you for making the dicom2stl.py
But I am facing some issues while converting entire dicom directory or zip file.
Single image is converting to stl format, but not entire directory.
Error:
Reading Dicom zip file: Dicom.zip
Error: no series foundctory.
Error:
Traceback (most recent call last):ctory.
Error:
File "dicom2stl.py", line 257, in
img, modality = loadZipDicom( fname[0] )
TypeError: 'NoneType' object is not iterable
How to load entire dicom directory (or) zip format for conversion.(Dicom to stl)? What is the commandline for this conversion?
Hi,
By using your code is it possible to remove clothing, patient bed etc. removal by changing HU threshold values or trying something else? I tried a few threshold value for skin extraction and soft tissue but could not get a clean stl.
Thanks in advance,
Kind regards
Gokce
Hello! I was trying to execute your file on my VMware Workstation, on Ubuntu and I encountered the following error -
My SimpleITK version is 1.2.4. My numpy version is 1.19.5 and my vtk version is 7.1.1
I ran the code on the DICOM images from the dicom folder provided in the repository. What could be the possible cause and a solution for the error? I appreciate the help!
The program stuck at line 174 in vtkutils.py
:
def reduceMesh(mymesh, reductionFactor):
"""Reduce the number of triangles in a mesh using VTK's QuadricDecimation
filter."""
try:
t = time.perf_counter()
deci = vtk.vtkQuadricDecimation()
deci.SetTargetReduction(reductionFactor)
if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
deci.SetInputData(mymesh)
else:
deci.SetInput(mymesh)
deci.Update()
# ......
I checked the official documentation, in the given example it uses vtk.vtkDecimatePro()
instead of vtk.vtkQuadricDecimation()
, and this fixes the problem.
My environment:
OS: Windows 10
CPU: AMD
VTK: 9.0.2 installed via pip
Python: 3.8.3
ไฝ ๅฅฝ๏ผๅฆๆๆๆณๅพๅฐไธๅๅฒ็3dๆจกๅ๏ผๅณ3dๆจกๅๅๆถๅ
ๅซ้ชจใ็ฎ่คใ่่ชใ่ฝฏ้ชจไปฅๅๅ
ถไป๏ผๆๅช็จไธ่พๅ
ฅ-tๅฐฑๅฏไปฅไบๅ๏ผ
Hello, if I want to get an unsegmented 3D model, that is, the 3D model contains bone, skin, fat, cartilage, and others, can I just enter -t without entering?
Does the threshold equal to the CT value? For example, the thresholds of bones are [200., 800., 1300., 1500.], but the CT value of a bone is often less than 1000. If not, how to get the threshold given the range of the CT value?
I have found this tool incredibly useful for extracting 3D meshes from different DICOM sources. However, the relative physical size of different meshes is sometimes different. While the STL file is dimensionless, is there a way to scale the resulting meshes such that their relative sizes reflect the real world?
I assume this should be possible since the DICOM files store pixels to real-world coordinate conversion but I am not too familiar with VTK.
C:\Users\Leiguan>easy_install SimpleITK
Searching for SimpleITK
Best match: SimpleITK 0.10.0
Adding SimpleITK 0.10.0 to easy-install.pth file
Using c:\users\leiguan\appdata\local\programs\python\python35-32\lib\site-packages
Processing dependencies for SimpleITK
Finished processing dependencies for SimpleITK
D:\dicom2stl>vtkpython dicom2stl.py -t bone -o bone.stl dicom.zip
Temp dir: c:\users\leiguan\appdata\local\temp\tmp5alcic
Tissue type: bone
Thresholds: [200.0, 800.0, 1300.0, 1500.0]
File names: ['dicom.zip']
Traceback (most recent call last):
File "dicom2stl.py", line 224, in
import SimpleITK as sitk
ImportError: No module named SimpleITK
C:\Users\User\Desktop\รmer\bionluk\dicom2stl-main>python dicom2stl.py dicomFiles/test/ --output test.stl
Temp dir: C:\Users\User\AppData\Local\Temp\tmpb92h54r6
Isovalue = 0.0
Error in loadLargestSeries. No files found.
dicomdir = dicomFiles/test/
Traceback (most recent call last):
File "C:\Users\User\Desktop\รmer\bionluk\dicom2stl-main\dicom2stl.py", line 160, in
img, modality = dicomutils.loadLargestSeries(fname[0])
TypeError: cannot unpack non-iterable NoneType object
Hello dave3d, above is the error message I get when I tried to use your script to turn an example dicom series intro stl.
I am not sure what that error means, but I also tried putting the files in a .zip file.
Thank you
Thank you so much for making dicom2stl.py
but i got some issues guys please help me solve this error
How to solve this error ? Not getting whats going wrong?Why this AttributeError is coming?
C:\Users\Admin\Desktop\sachin>python C:\Users\Admin\Desktop\sachin\dicom2stl.py dicom.zip
Temp dir: C:\Users\Admin\AppData\Local\Temp\tmpknar9hfu
Isovalue = 0
File names: ['dicom.zip']
Reading Dicom zip file: dicom.zip
1.76.380.18.10.5944.11594.2.1 C:\Users\Admin\AppData\Local\Temp\tmpknar9hfu\Dicomm 483
Loading series 1.76.380.18.10.5944.11594.2.1 in directory C:\Users\Admin\AppData\Local\Temp\tmpknar9hfu\Dicomm
Shrink factors: [2, 2, 2]
(498, 484, 483) -> (249, 242, 241)
0.093 seconds
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\sachin\dicom2stl.py", line 398, in
import sitk2vtk
File "C:\Users\Admin\Desktop\sachin\sitk2vtk.py", line 22, in
pixelmap = { sitk.sitkUInt8: vtk.VTK_UNSIGNED_CHAR, sitk.sitkInt8: vtk.VTK_CHAR,
AttributeError: 'module' object has no attribute 'VTK_UNSIGNED_CHAR'
Why this AttributeError is coming?
After mesh processed for small filtering, i dont see any mesh for smoothing or decimating, this was the debug info when i tried to process a bone using double threshold value:
Small parts cleaned
543624 polygons
0.803 seconds
2021-07-16 08:57:15.447 ( 165.217s) [ ]vtkDemandDrivenPipeline:668 ERR| vtkCompositeDataPipeline (000002096F2F9940): Input port 0 of algorithm vtkWindowedSincPolyDataFilter(000002096F270850) has 0 connections but is not optional.
Surface smoothed
0 polygons
34.068 seconds
2021-07-16 09:14:53.036 ( 267.172s) [ ]vtkQuadricDecimation.cx:208 ERR| vtkQuadricDecimation (000001F5757F3F20): Nothing to decimate
Note: i have set value of small filter to 0.05 for above, even default is having same issue.
Thanks
can i put this in an node server ?
make a post request
and download the data converted
many thanks
Hi,
I installed both vtk and simpleITK using pip and the versions of the same are shown below.
Name: vtk
Version: 8.1.2
Summary: VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization
Home-page: https://vtk.org/
Author: VTK Community
Author-email: [email protected]
License: BSD
Location: c:\users\vignesh\anaconda3\lib\site-packages
Requires:
Required-by:
Name: SimpleITK
Version: 1.2.4
Summary: SimpleITK is a simplified interface to the Insight Toolkit (ITK) for image registration and segmentation
Home-page: http://simpleitk.org/
Author: Insight Software Consortium
Author-email: [email protected]
License: Apache
Location: c:\users\vignesh\anaconda3\lib\site-packages
Requires:
Required-by:
But even then, "vtkpython dicom2stl.py -t bone -o bone.stl ct.zip" in the anaconda prompt in windows produces the error " 'vtkpython' is not recognized as an internal or external command, operable program or batch file. "
Assist needed. Thank you.
Thresholding method can't segment the dicom precisely, and I guess machine learning may do a good job. It seems that there's no well open sourced repository using machine learning to do the segmentation. It's not difficult to breakthrough and the repository will win much more stars if done this. I'm trying to do so.
Hi
im new to this field of segmenting various tissue types. Apologies if I'm wrong.
So If I choose skin as my tissue type then I see in the code it has thresholds = [-200., 0., 500., 1500.]
how do these threshold values are getting applied? all I see is ISOValue which is from default value it gets processed.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.