danishm / mritopng Goto Github PK
View Code? Open in Web Editor NEWA simple python module to make it easy to batch convert DICOM files to PNG images.
License: MIT License
A simple python module to make it easy to batch convert DICOM files to PNG images.
License: MIT License
can't convert dicom RT files
eg:
RD.1.2.246.352.71.7.1204427109.705164.20160620144721.dcm
RP.1.2.246.352.71.5.1204427109.381290.20160620140435.dcm
RS.1.2.246.352.71.4.1204427109.33491.20160621101405.dcm
Actual: When converting a folder structure, a failed conversion still produces an empty png file.
Expected: There should be no png file for failed conversions
If this is not the original intention, i will fix it.
Hi There,
Tried to convert a .dcm file to png, using the command line on Mac OS X with Python 2.7.12 here is the output:
mritopng ~/file1.dcm ~/file1.png
Traceback (most recent call last):
File "/usr/local/bin/mritopng", line 11, in
load_entry_point('mritopng==2.1', 'console_scripts', 'mritopng')()
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mritopng-2.1-py2.7.egg/mritopng/main.py", line 19, in main
convert_file(args.dicom_path, args.png_path)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mritopng-2.1-py2.7.egg/mritopng/init.py", line 50, in convert_file
mri_to_png(mri_file, png_file)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mritopng-2.1-py2.7.egg/mritopng/init.py", line 28, in mri_to_png
w.write(png_file, image_2d_scaled)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/png.py", line 655, in write
nrows = self.write_passes(outfile, rows)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/png.py", line 804, in write_passes
extend(row)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/png.py", line 801, in
return lambda sl: f(map(int, sl))
TypeError: only size-1 arrays can be converted to Python scalars
Any ideas?
The library currently takes the raw values of the readings in the dicom
file and simply scales it to be between 0..255
.
We want to add the ability for mritopng
to be able to enhance the contrast of a low contrast image as well.
After I installed the package successfully I'm able to import mritopng into python but when I try to run
mritopng.convert_folder('/Users/rakshith/Desktop/Internship Task/Training Data/Lean M10', '/Users/rakshith/Desktop/Internship Task/Training Data/Lean M10/PNG')
I get mritopng doesn't have convert_folder attribute. I tried it for a single file and it didn't work too.
Hi, when read your code in function auto_contrast and also the link you posted:
https://stackoverflow.com/questions/9744255/instagram-lux-effect/9761841#9761841
it says: ap5+b=0 and ap95+b=255
Therefore,
b=- ap5
ap95+(- a*p5)=255
and:
a = 255/(p95-p5)
In the current implementation:
line36: a = 255.0/(p95 + p5)
So I think it should be:
a = 255.0/(p95 - p5)
I wanna fork your project and republish with some additional components, but I don't know your project's license.
Would you like to tell us what license you follow or how much cover reusability of your library (e.g. research purpose, profit purpose...)?
I am keen on refactoring this project into a more formal Python library structure for the following benefits
setuptools
or pip
mritopng
script formally available to the client through Python's scripts/
folderChanges will introduce a new folder structure etc. You can see the details in this PR.
If anyone has any concerns or thoughts, please let me know.
@avraamisvi @DanielGutmann @dennyglee @diahpitaloka15 @GregTarr @jasonlo0509 @jskDr @MagnetonBora @mbonazzoli @NewtonsLadle @Snakeflute @sudarshanReddykurri
I have installed,but failed when converting folder.
I use it like this,
mritopng.convert_folder('E:\PE-detection\PE-hospital\ITA\CT300081485\420182','E:\convert\CT300081485')
WindowsError Traceback (most recent call last)
in ()
1 dirs = []
----> 2 mritopng.convert_folder('E:\PE-detection\PE-hospital\ITA\CT300081485\420182\','E:\convert\CT300081485\')
C:\Users\Salight\Anaconda2\lib\site-packages\mritopng-2.1-py2.7.egg\mritopng_init_.pyc in convert_folder(mri_folder, png_folder)
59
60 # Create the folder for the pnd directory structure
---> 61 os.makedirs(png_folder)
62
63 # Recursively traverse all sub-folders in the path
C:\Users\Salight\Anaconda2\lib\os.pyc in makedirs(name, mode)
155 if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
156 return
--> 157 mkdir(name, mode)
158
159 def removedirs(name):
WindowsError: [Error 183] : 'E:\convert\CT300081485\'
Hi,
I tried the following command:
mritopng --auto-contrast -f vol_000-0 vol0_0
And I get the following result:
FAIL: vol_000-0\000.mri --> vol0_0.\000.mri.png : File is missing DICOM File Meta Information header or the 'DICM' prefix is missing from the header. Use force=True to force reading.
How do I set this force=true in cmd?
hello sir
as you named it mritopng it means that this repo will convert all mri images wheater its in nifty, or nii or nii.gz extension will convertible??
I have images from ADNI and I want to convert it to a series of png or tiff or jog and than pass through my modal so kindly guide me please in this situation if I am using wrong repo than please correct me thanks and jazakAllah
Is there a way to increase the resolution or the conversion already happens in the best available from the file?
After running the code on a folder consisting of the DICOM images, the DICOM images get converted into a format of .dcm.png. Is it not possible to get the image in only .png form?
Does mritopng need a C Library?
Can you provide a Installation tutorials?
this is my error:
RuntimeError: Broken toolchain: cannot link a simple C program
Solved it - thanks!
Hello, I am Leon.
I am lucky with you in GitHub upload on DICOM convert PNG code.
And the success of a part of the DICOM file convert PNG file. But there is a part of the DICOM file cannot be converted to PNG files, the error code is as follows:
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000013.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000013.dcm.png : unsigned byte integer is less than minimum
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000017.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000017.dcm.png : unsigned byte integer is less than minimum
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000012.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000012.dcm.png : unsigned byte integer is less than minimum
SUCCESS: /home/imi/Downloads/caffe-master/examples/luna/test_images/000002.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000002.dcm.png
At the same time we also show:plan.pixel_array code
[[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
...,
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]]
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000013.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000013.dcm.png : unsigned byte integer is less than minimum
[[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
...,
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]
[-1024 -1024 -1024 ..., -1024 -1024 -1024]]
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000017.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000017.dcm.png : unsigned byte integer is less than minimum
[[-2000 -2000 -2000 ..., -2000 -2000 -2000]
[-2000 -2000 -2000 ..., -2000 -2000 -2000]
[-2000 -2000 -2000 ..., -2000 -2000 -2000]
...,
[-2000 -2000 -2000 ..., -2000 -2000 -2000]
[-2000 -2000 -2000 ..., -2000 -2000 -2000]
[-2000 -2000 -2000 ..., -2000 -2000 -2000]]
FAIL: /home/imi/Downloads/caffe-master/examples/luna/test_images/000012.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000012.dcm.png : unsigned byte integer is less than minimum
[[18 33 13 ..., 23 22 20]
[18 41 25 ..., 6 18 21]
[ 4 12 35 ..., 17 24 29]
...,
[34 17 15 ..., 13 10 17]
[44 18 14 ..., 16 15 15]
[28 23 20 ..., 17 5 18]]
SUCCESS: /home/imi/Downloads/caffe-master/examples/luna/test_images/000002.dcm --> /home/imi/Downloads/caffe-master/examples/luna/xxx2/./000002.dcm.png
We cannot find the relevant information on the Internet, so I hope to get your help.
Thank you
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.