Hi Kurt,
Actually, I think this may be the problem, in the function
recordLocalFeatures. Try just changing the "if 0" to "if 1". I may have
just removed that derivative calculation and now it needs to be put back.
Code snippet:
file = open(voxelExamplesFilename, "w")
filteredVolume =
self.getPersistentObject(voxelTrainingImageNodePath)
sh = filteredVolume.shape
#originalVolume = self.getPersistentObject(originalVolumeNodePath)
print "learnLocalFeatures dimensions", sh
if 0:
self.calculateDerivatives(filteredVolume, 'training')
volume = numpy.zeros(sh)
#selected x, y, and z
# get point features at the arbitrary point borderWidthFeatures
# to get a list of feature names
dictionary = getPointFeaturesAt(inputVolumeDict, filteredVolume,
'training', self,
borderWidthForFeatures)
kurt weiss wrote:
> Hi Rick,
> I tried to comment in the eigenvalues and structure tensor in
> cytoseg_classify.py, but I'm getting a Node DoesNotExist error at this
> line:
>
> xGVolume = gui.getVolume('%s_0Gradient_blur%d' %\
> (derivativeVolumesIdentifier, i))
>
> I attempted a few changes like calling gui.getVolume_new instead of the
> deprecated function and commenting in the i=0 statement above
> xGVolume=..., and well messing around with a whole bunch of stuff in
> hopes of figuring it out myself, but no luck. Any suggestions?
> Here is a snippet of the error followed by a snippet of the code I
> changed. The full terminal output and cytoseg_classify.py files are
> attached.
> Thank You very much,
> Kurt
>
> ERROR:
> from 0 to 4, loading image index 4, stack has 72 images
> data/example/in/cropped input004.tif
> volume.shape (615, 551, 5)
> subvolume box.cornerA [0, 0, 0]
> subvolume box.cornerB [615, 551, 5]
> subvolume box.shape() [615 551 5]
> volume shape (615, 551)
> full array shape (615, 551)
> cropped array shape (615, 551)
> ../data_viewer.py:493: UserWarning: deprecated
> warnings.warn("deprecated")
> runClassifyVoxels
> self.numberOfLayersToProcess None
> ../data_viewer.py:446: UserWarning: deprecated
> warnings.warn("deprecated")
> ../data_viewer.py:391: UserWarning: deprecated: addVolume
> warnings.warn("deprecated: addVolume")
> recordLocalFeatures
> learnLocalFeatures dimensions (350, 350, 75)
> ../data_viewer.py:416: UserWarning: deprecated: getVolume
> warnings.warn("deprecated: getVolume")
> Traceback (most recent call last):
> File "run_pipeline_test.py", line 366, in <module>
> voxelStep('classifyVoxels')
> File "run_pipeline_test.py", line 101, in voxelStep
> voxelChunkSize)
> File "../batch_process.py", line 74, in batchProcessVoxels
> runSteps(**segmentationParams)
> File "../run_steps.py", line 152, in runSteps
> detector.run(steps)
> File "../segmentation_manager.py", line 115, in run
> self.componentDetector.runClassifyVoxels()
> File "../component_detector.py", line 1856, in runClassifyVoxels
> numberOfLayersToProcess=self.numberOfLayersToProcess)
> File "../component_detector.py", line 817, in classifyVoxels
> self.voxelWeightDict)
> File "../cytoseg_classify.py", line 531, in recordLocalFeatures
> 'training', self, borderWidthForFeatures)
> File "../cytoseg_classify.py", line 1285, in getPointFeaturesAt
> (derivativeVolumesIdentifier, i))
> File "../data_viewer.py", line 417, in getVolume
> node = getNode(self.mainDoc.dataRootNode, ('Volumes', name))
> File "../tree.py", line 295, in getNode
> currentNode = currentNode.getChild(name)
> File "../tree.py", line 140, in getChild
> raise NodeDoesNotExist, ("Tried to access node named %s but it
> wasn't there. (parent node name: %s) (parent node: %s)" % (name,
>
self.name <
http://self.name>, self))
> tree.NodeDoesNotExist: Tried to access node named
> training_0Gradient_blur0 but it wasn't there. (parent node name:
> Volumes) (parent node: Volumes( test volume 1() test volume 2()
> voxelTrainingImage() voxelTrainingLabel() default_testOriginalVolume()
> inputImage()))
>
> ********************************************************************************
> cytoseg_classify.py lines 1258 - 1331
>
> def getPointFeaturesAt(inputVolumeDict, volume,
> derivativeVolumesIdentifier, gui, point):
> """Get features (for classification) at a particular point"""
>
> # f is dictionary of features
>
> if not(isInsideVolumeWithBorder(volume, point,
> borderWidthForFeatures)):
> raise Exception, 'The point %s is not inside the volume enough.
> In needs to be away from the border by %d pixels for x, %d pixels for y,
> and %d pixels for z. Volume shape: %s' % (point,
> borderWidthForFeatures[0], borderWidthForFeatures[1],
> borderWidthForFeatures[2], str(volume.shape))
>
> f = odict()
>
>
> #sizeIdentifiers = ('3x3x3', '5x5x5', '7x7x7')
> sizeIdentifiers = ('(3)', '(5)', '(7)')
> v = [None, None, None]
>
> #for i in range(3):
> for i in range(1):
> size = i+1
> v =
> volume[point[0]-size:point[0]+size,point[1]-size:point[1]+size,point[2]-size:point[2]+size]
>
>
> # experimental features
> #if 0:
>
> #i = 0
> #todo: note that getVolume may be a slow operation
> xGVolume = gui.getVolume('%s_0Gradient_blur%d' %\
> (derivativeVolumesIdentifier, i))
> xG = at(xGVolume, point)
> yGVolume = gui.getVolume('%s_1Gradient_blur%d' %\
> (derivativeVolumesIdentifier, i))
> yG = at(yGVolume, point)
> zGVolume = gui.getVolume('%s_2Gradient_blur%d' %\
> (derivativeVolumesIdentifier, i))
> zG = at(zGVolume, point)
>
> # experimental features
> #if 0:
>
> if i == 0:
> f['grayValue'] = at(volume, point)
> #'differenceOfGaussian'
> f['gradientMagnitude'] = sqrt(pow(xG,2) + pow(yG,2) +
> pow(zG,2))
>
>
> # experimental features
> #if 0:
>
> stAtSelectedPoint = structureTensor(xG,yG,zG)
>
> sortedEigAtSelectedPoint = numpy.linalg.eigvals(stAtSelectedPoint)
> sortedEigAtSelectedPoint.sort()
>
> prefix = sizeIdentifiers[i] + '_'
>
> f[prefix + 'eig0'] = sortedEigAtSelectedPoint[0]
> f[prefix + 'eig1'] = sortedEigAtSelectedPoint[1]
> f[prefix + 'eig2'] = sortedEigAtSelectedPoint[2]
>
> values = v.flatten(1)
> #print "i", i, "values", values
>
> moments = statistics.moments(values)
> f[prefix + 'mean'] = moments[0]
> f[prefix + 'standardDeviation'] = moments[1]
> f[prefix + 'thirdMoment'] = moments[2]
> f[prefix + 'fourthMoment'] = moments[3]
>
> quantiles = statistics.sortAndReturnQuantiles(values)
> f[prefix + 'minimum'] = quantiles[0]
> f[prefix + '0.25-quantile'] = quantiles[1]
> f[prefix + 'median'] = quantiles[2]
> f[prefix + '0.75-quantile'] = quantiles[3]
> f[prefix + 'maximum'] = quantiles[4]
>