Skip to content

Instantly share code, notes, and snippets.

@javathunderman
Created March 10, 2019 14:55
Show Gist options
  • Save javathunderman/a3250eef2fa3d2f77cd79b576f34f053 to your computer and use it in GitHub Desktop.
Save javathunderman/a3250eef2fa3d2f77cd79b576f34f053 to your computer and use it in GitHub Desktop.
Script for quickly converting DICOM images to ordered JPG images for machine learning.
# Script for quickly converting DICOM images to ordered JPG images for machine learning.
import os
for fileName in os.listdir("."):
noe = os.path.splitext(fileName)[0]
if(noe == "convert"):
continue
os.system("convert " + fileName + " " + noe + ".jpg")
os.remove(noe+".dcm")
for fileName1 in os.listdir("."):
noe1 = os.path.splitext(fileName1)[0]
if(noe1 == "convert"):
continue
os.rename(fileName1, fileName1.replace(fileName1, noe1+"-whatever.jpg"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment