我正在尝试根据 CSV 文件中给出的坐标从 CT 图像中提取结节斑块。我在世界坐标行不断收到此错误消息:无法将字符串转换为浮点数(CordZ)。我不太确定该怎么做。
到目前为止我有这个:
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)