Giter VIP home page Giter VIP logo

dicom2stl's Introduction

Hey, what's up? ๐Ÿ‘‹

Let me know if you want to hit the links ๐ŸŒ๏ธโ€โ™‚๏ธ

Dave3d's GitHub stats

dicom2stl's People

Contributors

dave3d avatar jimmyjliu avatar paulin1c avatar pjaol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dicom2stl's Issues

'loadLargestSeries' is not defined

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)

Program stuck at decimation step

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

Segmentation Fault

Hello! I was trying to execute your file on my VMware Workstation, on Ubuntu and I encountered the following error -

image

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!

How to get an unsegmented 3D model

ไฝ ๅฅฝ๏ผŒๅฆ‚ๆžœๆˆ‘ๆƒณๅพ—ๅˆฐไธๅˆ†ๅ‰ฒ็š„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?

What is the threshold?

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?

how to solve this error?

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

TypeError: cannot unpack non-iterable NoneType object

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

Small filter Issue

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

image

Note: i have set value of small filter to 0.05 for above, even default is having same issue.

Thanks

Dicom to stl Conversion

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?

Threshold value

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

The output STL file is in the shape of a box

Hi!

I was able to successfully convert the dicom files to a 3d image (.stl) and I tried 2 datasets and I am getting a cube in the output STL file?

image
image

Why do you think this might be the case? And how can I fix this? Could this be because the dataset itself had a square outline?

Thanks in advance!

Dicom to stl Conversion #issue

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?

thresholding value for clothing and patient bed removal

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

Suggest: use machine learning to get more precise segmentation

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.

server side ?

can i put this in an node server ?
make a post request
and download the data converted

many thanks

'vtkpython' is not recognized as an internal or external command, operable program or batch file.

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.

Comparing physical sizes of different generated meshes

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.