I am trying to extract nodule patches from CT images based on the co-ordinates given in a CSV file. i keep getting this error msg at the worldcoord line :could not convert string to float(CordZ). I am not quite sure how to do that.
I have this so far:
def readCSV(filename):
def readCSV(filename): lines = []
with open(filename, 'r') as f:
csvreader = csv.reader(f)
for line in csvreader:
lines.append(line)
return lines
cands = readCSV(cand_path)
for cand in cands:
worldCoord = np.asarray([float(cand[3]),float(cand[2]),float(cand[1])])
voxelCoord = worldToVoxelCoord(worldCoord, numpyOrigin, numpySpacing)
voxelWidth = 65
patch = numpyImage[voxelCoord[0],voxelCoord[1]-voxelWidth/2:voxelCoord[1]+voxelWidth/2,voxelCoord[2]-voxelWidth/2:voxelCoord[2]+voxelWidth/2]
patch = normalizePlanes(patch)
print ('data')
print (worldCoord)
print (voxelCoord)