简体   繁体   中英

"AttributeError: 'numpy.ndarray' object has no attribute 'values'

Here's a snippet of my code:

#code sample
for i in range(1, number_of_segments + 1):
    I1 = (dcm_pixel_array["array" + str(3 + (i - 1))]) * 2
    I8 = (dcm_pixel_array["array" + str(3 + (7*int((number_of_segments+2)/8)) + (i-1) + 2)]) * 2
    for j in range(I1.ndim):
        for k in range(I1.ndim):
            if (3.03 - (17.85 + 14.87)) / (math.log((I8[j].values[k]) / (I1[j].values[k]))) < 0:
                T2_map = np.zeros(shape = (j, k, i))
            elif (3.03-(17.85+14.87))/(math.log((I8[j].values[k]) / (I1[j].values[k]))) > 100:
                T2_map = np.full((i,j,k), 100)
# end of sample

I am getting the error on the line with the first if statement. It says: "AttributeError: 'numpy.ndarray' object has no attribute 'values'". Any recommendations as to what I should do to correct the error?

Clarifications: "dcm_pixel_array" is a dictionary of arrays (binary masks) that have been read from dicom files. The number of segments is 286. I am trying to access the information in the jth row of the kth column of the I8 and I1 arrays.

Thank you!

Since the given dataset is already an array, values won't work. Call the array using I8[j][k]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM