Esempio n. 1
0
def loaddata_old(dicomdata):
    indata = pydicom_series.read_files(dicomdata,showProgress=True)[0]  


    pixelsize =  float(indata.info["0028","0030"].value[0])

    array = indata.get_pixel_array()
    return pixelsize, array, indata
Esempio n. 2
0
def loaddata(dicomdata):
    indata = pydicom_series.read_files(dicomdata,showProgress=True)[0]  


    pixelsize =  float(indata.info["0028","0030"].value[0])
    
    rows = indata.info["0028","0010"].value
    cols = indata.info["0028","0011"].value

    newshape = (rows,cols)
    print "shape of dataslices: ", newshape
    
    bitdepth = indata.info["0028","0100"].value #bits allocated
    if bitdepth == 16:
        bv = np.int16
    elif bitdepth == 8:
        bv = np.int8    
    elif bitdepth == 32:
        bv = np.int32
    elif bitdepth == 64:
        bv = np.int64
    
    
    datlist = []

    sequence = indata.__dict__['_datasets']
    
    for i in range(len(sequence)):
       tmpkeys = sequence[i].keys()      
       datlist.append(np.reshape(np.fromstring(sequence[i][dicom.tag.Tag("7fe0","0010")].value,dtype=bv),newshape))
       

    array = np.array(datlist)
    print "loaddata complete"
    
    return pixelsize, array, indata