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.

Revisions

  1. javathunderman created this gist Mar 10, 2019.
    14 changes: 14 additions & 0 deletions convert.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # 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"))