Only getting "0" and "NAN" values in array?

I am trying to make a T2 map (array) from some dicom images, but my code is only producing a T2 map of "NAN" and "0" values. Here is the block of code I am currently working with:

# T2 Calculations
T2_map = np.empty((number_of_segments, number_of_segments, number_of_segments))
for i in range(1, number_of_slices + 1):
    if 3 + (i - 1) <= number_of_segments:
        I1 = (dcm_pixel_array["array" + str(3 + (i - 1))]) * 2
    else:
        I1 = (dcm_pixel_array["array" + str(number_of_segments)]) * 2
    if 3 + ((7 * number_of_slices) + (i - 1)) <= number_of_segments:
        I8 = (dcm_pixel_array["array" + str(3 + ((7*number_of_slices) + (i-1)))]) * 2
    else:
        I8 = (dcm_pixel_array["array" + str(number_of_segments)]) * 2
    print("I1:", I1)
    print("I8:", I8)
    print("")
    for j in range(I1.ndim):
        for k in range(I1[0].ndim):
            if (I1[j][k]) == 0 or (I8[j][k]/I1[j][k]) <= 0 or (np.log((I8[j][k]) / (I1[j][k]))) == 0:
                T2_map[j, k, i] = "NAN"
            elif (3.03 - (17.85 + 14.87)) / (np.log(I8[j][k] / I1[j][k])) < 0:
                T2_map[j,k,i] = 0
            elif (3.03-(17.85+14.87))/(np.log(I8[j][k] / I1[j][k])) > 100:
                T2_map[j,k,i] = 100
            else:
                T2_map[j,k,i] = ((3.03-(17.85+14.87))/(np.log(I8[j][k] / I1[j][k])))
print()
print("T2 map:", T2_map)
print()

The values in I1 and I8 range from 0 to 16, so this code should technically produce actual numeric values. Any recommendations as to how I should proceed with troubleshooting this problem?

Clarifications: number_of_segments = 288, number_of_slices = 36

Thank you! :)