def TrivialClippedVolume(self): ms = microstructure.getMicrostructure('microstructure') skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject() for plane in planes: v0 = skel.clipVSBVol(0, plane) v1 = skel.clipVSBVol(0, plane.reversed()) self.assertAlmostEqual(v0 + v1, 64.)
def All2x2x2(self): ms = microstructure.getMicrostructure('microstructure') skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject() # The non-trivial combinations of voxels correspond to voxel # signatures between 1 and 255. Signature 0 has no voxels in # it, and would be equivalent to the Trivial test, above. sigs = range(1, 256) for sig in sigs: nvox = self.selectSig(sig) sigstr = voxelsetboundary.printSig(sig) print "Selected voxels:", sigstr, "(sig=%d)" % sig self.assertEqual(nvox, self.selectionSize()) OOF.PixelGroup.AddSelection(microstructure='microstructure', group='pixelgroup') self.assertEqual(ms.nCategories(), 2) # triggers categorization unselectedCat = ms.category(Point(0, 0, 0)) selectedCat = 1 - unselectedCat print "selectedCat=", selectedCat, "unselectedCat=",\ unselectedCat skel.dumpVSB(selectedCat, "selected.dat") skel.dumpVSB(unselectedCat, "unselected.dat") # ms.dumpVSBLines(selectedCat, "selected_"+sigstr+".lines") # ms.dumpVSBLines(unselectedCat, "unselected_"+sigstr+".lines") selectedVol = ms.volumeOfCategory(selectedCat) unselectedVol = ms.volumeOfCategory(unselectedCat) print "selectedVol=", selectedVol, \ "unselectedVol=", unselectedVol print "Checking connectivity for selected voxels, category",\ selectedCat self.assert_(skel.checkVSB(selectedCat)) print "Checking connectivity for unselected voxels, category",\ unselectedCat self.assert_(skel.checkVSB(unselectedCat)) self.assertAlmostEqual(selectedVol, nvox) self.assertAlmostEqual(unselectedVol, 64 - nvox) # Check that the saved VSB graphs are correct sigstr = sigstr.replace('|', '-') self.assert_( file_utils.fp_file_compare( "selected.dat", os.path.join("vsb_data", "selected_" + sigstr + ".dat"), 1.e-9)) self.assert_( file_utils.fp_file_compare( "unselected.dat", os.path.join("vsb_data", "unselected_" + sigstr + ".dat"), 1.e-9)) print "-------" file_utils.remove("selected.dat") file_utils.remove("unselected.dat")
def ClippedShape(self): # Check that a few carefully selected sets of voxels are # clipped properly by a single plane sigs = ( vox000, vox111, vox000 | vox100, vox000 | vox110, vox010 | vox100, vox000 | vox100 | vox010 | vox111, ) ms = microstructure.getMicrostructure('microstructure') skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject() for sig in sigs: sigstr = voxelsetboundary.printSig(sig) print "Selecting voxels", sigstr sigstr = sigstr.replace('|', '-') nvox = self.selectSig(sig) OOF.PixelGroup.AddSelection(microstructure='microstructure', group='pixelgroup') unselectedCat = ms.category(Point(0, 0, 0)) selectedCat = 1 - unselectedCat for i, plane in enumerate(planes): # saveClippedVSB writes filename.dat and filename.lines skel.saveClippedVSB(selectedCat, plane, 'selected') skel.saveClippedVSB(unselectedCat, plane, 'unselected') fnamebase = "clipped_%s_p%02d" % (sigstr, i) self.assert_( file_utils.fp_file_compare( 'selected.dat', os.path.join("vsb_data", 's' + fnamebase + '.dat'), 1.e-9)) self.assert_( file_utils.fp_file_compare( 'unselected.dat', os.path.join("vsb_data", 'u' + fnamebase + '.dat'), 1.e-9)) self.assert_( file_utils.fp_file_compare( 'selected.lines', os.path.join("vsb_data", 's' + fnamebase + '.lines'), 1.e-9)) self.assert_( file_utils.fp_file_compare( 'unselected.lines', os.path.join("vsb_data", 'u' + fnamebase + '.lines'), 1.e-9)) file_utils.remove('selected.dat') file_utils.remove('unselected.dat') file_utils.remove('selected.lines') file_utils.remove('unselected.lines')
def ClippedVolume(self): ms = microstructure.getMicrostructure('microstructure') skel = skeletoncontext.getSkeleton(ms, "skeleton").getObject() sigs = range(1, 256) #sigs = (105,) for sig in sigs: print "voxels=%s" % voxelsetboundary.printSig(sig) nvox = self.selectSig(sig) OOF.PixelGroup.AddSelection(microstructure='microstructure', group='pixelgroup') unselectedCat = ms.category(Point(0, 0, 0)) selectedCat = 1 - unselectedCat for plane in planes: print "plane=%s" % plane v00 = skel.clipVSBVol(selectedCat, plane) v10 = skel.clipVSBVol(unselectedCat, plane) opposite = plane.reversed() v01 = skel.clipVSBVol(selectedCat, opposite) v11 = skel.clipVSBVol(unselectedCat, opposite) self.assertAlmostEqual(nvox, v00 + v01) self.assertAlmostEqual(64 - nvox, v10 + v11) self.assertAlmostEqual(v00 + v01 + v10 + v11, 64)
def currentSkeleton(self): ms = self.currentMS() meshname = self.currentSkeletonName() if meshname: return skeletoncontext.getSkeleton(ms, meshname)
def currentSkeleton(self): ms = self.currentMS() meshname = self.currentSkeletonName() if meshname: return skeletoncontext.getSkeleton(ms, meshname)