Coder Social home page Coder Social logo

danishm / mritopng Goto Github PK

View Code? Open in Web Editor NEW
136.0 2.0 48.0 1.02 MB

A simple python module to make it easy to batch convert DICOM files to PNG images.

License: MIT License

Python 98.80% Dockerfile 1.20%
python medical medical-images dicom dicom-images dicom-converter png

mritopng's People

Contributors

danishm avatar kshitij12345 avatar mellon85 avatar neheller 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

mritopng's Issues

can't convert dicom RT files

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

mammogram orientation

Hi there,
I am trying to convert mammogram to png.
however mammogram can be left or right, the right mammogram have the correct orientation but the left mammogram are reversed..
image
the breast should be to the left and the text should be LMLO but it is reversed
thanks.

mritopng command line won't convert

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?

Add Ability to Apply Auto Contrast

Goal

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.

Converting Mammogram to PNG file

Most viewers display mammograms(DICOM images) in the following format
Screenshot from 2019-10-29 18-06-58

But when its converted to png the image looks like this
0010

Am i missing something here like rescaling ?

No attribute convert_file/folder

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.

License issues

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...)?

Refactor To a Formal Python Library Project Structure

I am keen on refactoring this project into a more formal Python library structure for the following benefits

  1. To be installable easily through setuptools or pip
  2. Make the mritopng script formally available to the client through Python's scripts/ folder

Changes 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

How to use it in windows?

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')

and I got this error:

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\'

Light Grey issue

Hi, I have been looking around and tweaking your grey scale in init_.py for a while, but I cannot seem to get it right. Can you give me some advise on how to fix it? (Please refer to the attachment)
output

force=True in Windows 10

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?

confuse about your project?

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

Conversion works but...

Is there a way to increase the resolution or the conversion already happens in the best available from the file?

Conversion issue

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?

how install?

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

On the conversion of DICOM convert PNG the problem of error

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

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.