Size is (121,512,512). Error is coming as : IndexError: index 152 is out of bounds for axis 0 with size 121.

0 votes
def nodule_detect(nodules,j,numpyImage, numpyOrigin, numpySpacing):
    #g = "input/subset"+str(k)+"/"+j
    #numpyImage, numpyOrigin, numpySpacing = load_itk_image(j)
    #jj = j.split("/")
    #jj = jj[-1]
    numpyImage = normalize(numpyImage)
    print("Inside nodule-detect",numpyImage)
    for i in range(len(nodules)):
        vals = nodules.loc[i]
        #print(j)
        #print("In nodule-detect")
        jj = j.split("/")
        jj = jj[-1]
        if(vals['seriesuid'] == (jj.replace(".mhd",""))):
            print("Inside the nodule")
            worldCoord = np.asarray([float(vals["coordX"]),float(vals["coordY"]),float(vals["coordZ"])])
            print(worldCoord)
            voxelCoord = worldToVoxelCoord(worldCoord, numpyOrigin, numpySpacing)
            print(voxelCoord)
            voxelCoord = voxelCoord
            voxelWidth = 65
            print("VoxelCoord :",voxelCoord[0])
            print("Welcome")
            patch = numpyImage[int(voxelCoord[0]),int(voxelCoord[1])- int(voxelWidth/2):int(voxelCoord[1])+int(voxelWidth/2),int(voxelCoord[2])-int(voxelWidth/2):int(voxelCoord[2])+int(voxelWidth/2)]
            patch = normalizePlanes(patch)
            print (worldCoord)
            print (voxelCoord)
            print (patch)
            outputDir = 'patches/'
            plt.imshow(patch, cmap='gray')
            plt.show()
            #outputDir = 'patches/'
            plt.savefig('patch'+".png")
            Image.fromarray(patch*255).convert('L').save(os.path.join(outputDir,'patch_'+ str(worldCoord[0]) + '_' + str(worldCoord[1]) + '_' + str(worldCoord[2]) +'.tiff'))
Jan 28 in Python by anonymous
• 150 points
642 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
0 answers

Python error "IndexError: list index out of range"

I am trying to execute the following ...READ MORE

Jun 17, 2019 in Python by Alok
5,180 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,760 points
238 views
0 votes
3 answers

What is the python keyword “with” used for?

The with statement in Python simplifies exception ...READ MORE

answered Jul 19, 2019 in Python by rahul
• 320 points
161 views
+1 vote
3 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The error message invalid literal for int() ...READ MORE

answered Apr 29 in Python by warrenfelsh
• 140 points
74,586 views
0 votes
3 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 939 views
0 votes
0 answers