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, 2020 in Python by anonymous
• 150 points
4,232 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
7,402 views
0 votes
1 answer
0 votes
0 answers

iloc giving 'IndexError: single positional indexer is out-of-bounds'

I was trying to encode some information ...READ MORE

May 23, 2022 in Python by Kichu
• 19,040 points
1,596 views
0 votes
1 answer

how to solve this IndexError: list index out of range in python and streamlit?

Hi,  @Erick, To solve the “index error: list ...READ MORE

answered Sep 25, 2020 in Python by Roshni
• 10,480 points
28,482 views
0 votes
2 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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,468 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP