Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mritopng command line won't convert #17

Open
phrozendice opened this issue May 24, 2018 · 5 comments
Open

mritopng command line won't convert #17

phrozendice opened this issue May 24, 2018 · 5 comments
Assignees
Labels

Comments

@phrozendice
Copy link

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?

@danishm danishm self-assigned this May 25, 2018
@danishm danishm added the bug label May 25, 2018
@danishm
Copy link
Owner

danishm commented May 25, 2018

@phrozendice Would you be able to provide the file that causes this error?

@phrozendice
Copy link
Author

@danishm thank you for your prompt response, unfortunately I can’t provide the source file as it contains personal identifiable information. If there is anything else I can do to help you reproduce please let me know.

@danishm
Copy link
Owner

danishm commented May 27, 2018

@phrozendice That makes total sense! Yes, patient privacy is important. I've been developing on a cases by case basis using publicly available samples mostly. I have a few in this folder for testing in the project. Here is how you can help

Possible ways to help

  1. If you can figure out what's different between the sample files I have and the ones you have, that would help.
  2. If you're handy with jumping into python code, when you're processing your files, what does the variable image_2d_scaled look like on this line of code. I'm more interested in the shape rather than the data i.e. is it in fact a 2d array with some data inside it and what's it shape is.

@Binb1
Copy link

Binb1 commented Nov 8, 2019

@phrozendice Any news on this issue ?
I'm running in the same problem and I'm having a hard time figuring why because this tool always worked for me with my previous DICOM files (thanks @danishm!)

@Binb1
Copy link

Binb1 commented Nov 8, 2019

@danishm Here is what I have when i print the image_2d_scaled variable:

`mritopng IVA0\ (1) output.png
Arguments: %s Namespace(auto_contrast=False, dicom_path='IVA0 (1)', folder=False, png_path='output.png')
Removing existing output file output.png
[[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]

[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]

[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]

...

[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[99.23076923 99.23076923 99.23076923]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]

[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]

[[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]
...
[ 0. 0. 0. ]
[ 0. 0. 0. ]
[ 0. 0. 0. ]]]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/png.py", line 795, in write_passes
extend(row)
TypeError: only size-1 arrays can be converted to Python scalars

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/mritopng", line 11, in
load_entry_point('mritopng==2.2', 'console_scripts', 'mritopng')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mritopng-2.2-py3.6.egg/mritopng/main.py", line 21, in main
convert_file(args.dicom_path, args.png_path, args.auto_contrast)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mritopng-2.2-py3.6.egg/mritopng/init.py", line 60, in convert_file
mri_to_png(mri_file, png_file, auto_contrast)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mritopng-2.2-py3.6.egg/mritopng/init.py", line 22, in mri_to_png
w.write(png_file, image_2d.image)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/png.py", line 656, in write
nrows = self.write_passes(outfile, rows)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/png.py", line 805, in write_passes
extend(row)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/png.py", line 802, in
return lambda sl: f(list(map(int, sl)))
TypeError: only size-1 arrays can be converted to Python scalars`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants