danishm / mritopng

A simple python module to make it easy to batch convert DICOM files to PNG images.
MIT License
137 stars 48 forks source link

How to use it in windows? #18

Closed Salight closed 5 years ago

Salight commented 6 years ago

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\\'
danishm commented 6 years ago

@Salight Fun Fact: I incepted this project in Windows and I still use a Windows box as my primary development box for it. Hence, it should definitely work in Windows.

Here are a couple of things you can try:

1. Try a new folder as the destination folder

Try some folder other than E:\convert\CT300081485\ and see if you get the same error. I believe the code's been written to not override anything existing to not accidentally delete anything.

2. Use proper slash in Windows

I don't know what your code looks like, but in windows, for string literals representing paths, you need to use \\ instead of \ since \ is an escape character in Python

For Example: Instead of:

mritopng.convert_folder('E:\PE-detection\PE-hospital\ITA\CT300081485\420182','E:\convert\CT300081485')

Try:

mritopng.convert_folder('E:\\PE-detection\\PE-hospital\\ITA\\CT300081485\\420182','E:\\convert\\CT300081485')
Salight commented 6 years ago

@danishm Thank you.I have tried but neither works. So I turned to Linux and everything is fine.

danishm commented 6 years ago

@Salight Glad to know you've been able to make progress. I will double check on Windows before closing this out.