How to Run

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to Run

I found this code in github :
import dicom
import os
import numpy
import sys

dicomPath = "./../nn/"
lstFilesDCM = []  # create an empty list
for dirName, subdirList, fileList in os.walk(dicomPath): # file name should
be ordered correctly
    allInOne = ""

    for filename in fileList:
        if "".join(filename).endswith((".dcm", ".DCM")): # check whether the
file's DICOM
            path = dicomPath + "".join(filename)
            dataset = dicom.read_file(path)

            for n,val in enumerate(dataset.pixel_array.flat):
                dataset.pixel_array.flat[n] = val / 60
                if val < 0:
                    dataset.pixel_array.flat[n] = 0
            dataset.PixelData = numpy.uint8(dataset.pixel_array).tostring()
# convert int16 to int8
            allInOne += dataset.PixelData
            print "slice " + "".join(filename) + " done"

    newFile = open("./all_in_one.raw", "wb")

    print "RAW file generated"

But I can not run this code How it is work

Sent from:
Powered by

Visit other Kitware open-source projects at

Please keep messages on-topic and check the VTK FAQ at:

Search the list archives at:

Follow this link to subscribe/unsubscribe: