Example #1
0
def ExtractGeometry(centerlines):

    #centerlines=EquispacedSpline(centerlines.Centerlines,0.05) # every 0.5mm
    centerlineResampling = vmtkscripts.vmtkCenterlineResampling()
    centerlineResampling.Centerlines = centerlines.Centerlines
    centerlineResampling.Length = 0.05
    centerlineResampling.Execute()

    centerlineGeometry = vmtkscripts.vmtkCenterlineGeometry()
    centerlineGeometry.Centerlines = centerlineResampling.Centerlines
    centerlineGeometry.SmoothingFactor = 0.4
    centerlineGeometry.FrenetTangentArrayName = 'FrenetTangent'
    centerlineGeometry.FrenetNormalArrayName = 'FrenetNormal'
    centerlineGeometry.FrenetBinormalArrayName = 'FrenetBinormal'
    centerlineGeometry.Execute()

    centerlineAttributes = vmtkscripts.vmtkCenterlineAttributes()
    centerlineAttributes.Centerlines = centerlineGeometry.Centerlines
    centerlineAttributes.Execute()

    branchExtractor = vmtkscripts.vmtkBranchExtractor()
    branchExtractor.Centerlines = centerlineAttributes.Centerlines
    branchExtractor.GroupIdsArrayName = 'GroupIds'
    branchExtractor.RadiusArrayName = 'MaximumInscribedSphereRadius'
    branchExtractor.CenterlineIdsArrayName = 'CenterlineIds'
    branchExtractor.BlankingArrayName = 'Blanking'
    branchExtractor.Execute()

    return branchExtractor
Example #2
0
def vmtk_compute_centerline_attributes(centerlines):
    """ Wrapper for centerline attributes.

    Args:
        centerlines (vtkPolyData): Line to investigate.

    Returns:
        line (vtkPolyData): Line with centerline atributes.
    """
    attributes = vmtkscripts.vmtkCenterlineAttributes()
    attributes.Centerlines = centerlines
    attributes.NormalsArrayName = parallelTransportNormalsArrayName
    attributes.AbscissaArrayName = abscissasArrayName
    attributes.Execute()
    centerlines = attributes.Centerlines

    return centerlines
Example #3
0
def vmtkcenterlineattributes(centerlines):
    """Compute centerline attributes.

    Args:
        centerlines: Centerlines.

    Returns:
        Centerlines with attributes.
        Pointdata:
            MaximumInscribedSphereRadius: If the point on the centerline is the
                center of a sphere, this is the radius of the largest possible
                sphere that does not intersect the surface.
            Abscissas: Position along the centerlines. By default, the abscissa
                is measured from the start of the centerlines.
            ParallelTransportNormals: 'Normal' of the centerlines (perpendicular
                to centerline direction).

    """
    clattributes = vmtkscripts.vmtkCenterlineAttributes()
    clattributes.Centerlines = centerlines
    clattributes.Execute()
    return clattributes.Centerlines
Example #4
0
def vmtkcenterlineattributes(centerlines):
    """Compute centerline attributes.

    Args:
        centerlines: Centerlines.

    Returns:
        Centerlines with attributes.
        Pointdata:
            MaximumInscribedSphereRadius: If the point on the centerline is the
                center of a sphere, this is the radius of the largest possible
                sphere that does not intersect the surface.
            Abscissas: Position along the centerlines. By default, the abscissa
                is measured from the start of the centerlines.
            ParallelTransportNormals: 'Normal' of the centerlines (perpendicular
                to centerline direction).

    """
    clattributes = vmtkscripts.vmtkCenterlineAttributes()
    clattributes.Centerlines = centerlines
    clattributes.Execute()
    return clattributes.Centerlines
Example #5
0
    def Execute(self):
        print("Compute VC orientation")
        self.ctrliner = vmtkscripts.vmtkCenterlines()
        self.ctrliner.Surface = self.Surface
        self.ctrliner.Execute()
        self.Centerlines = self.ctrliner.Centerlines
        cc = self.Centerlines

        ptCoord = []

        for c in xrange(cc.GetNumberOfPoints()):
            ptCoord.append(cc.GetPoints().GetPoint(c))

        ptCoord = np.array(ptCoord)
        datamean = ptCoord.mean(axis=0)
        uu, dd, vv = np.linalg.svd(ptCoord - datamean)
        # vector of the general direction of the VC
        # print(vv[0], datamean, datamean+10*vv[0])
        VCvect = vv[0]

        if self.ComputeCenterlines:
            # print(self.Surface)
            self.ctrliner = vmtkscripts.vmtkCenterlines()
            self.ctrliner.Surface = self.Surface
            # self.ctrliner.SeedSelector = 'openprofiles'
            self.ctrliner.Execute()
            self.Centerlines = self.ctrliner.Centerlines
            # self.Surface = self.Centerlines
        else:
            self.Centerlines = self.Surface

        # if self.Centerlines == None:
        #     self.PrintError('DUMBASS')

        self.vmtkReader = vmtkscripts.vmtkSurfaceReader()

        self.vmtkRenderer = vmtkscripts.vmtkRenderer()
        self.vmtkRenderer.Initialize()
        self.SurfaceViewer = vmtkscripts.vmtkSurfaceViewer()

        # self.Surface = self.Centerlines
        self.SurfaceViewer.Surface = self.Surface
        self.SurfaceViewer.Execute()

        self.myattr = vmtkscripts.vmtkCenterlineAttributes()
        self.myattr.Centerlines = self.Centerlines
        self.myattr.Execute()

        self.mybranchextractor = vmtkscripts.vmtkBranchExtractor()
        self.mybranchextractor.Centerlines = self.myattr.Centerlines
        self.mybranchextractor.RadiusArrayName = self.RadiusArrayName
        self.mybranchextractor.Execute()

        self.ctrl = self.mybranchextractor.Centerlines

        self.mywriter = vmtkscripts.vmtkSurfaceWriter()
        self.mywriter.Surface = self.mybranchextractor.Centerlines
        self.mywriter.OutputFileName = '/home/florian/liverSim/morpho_analysis/test_surf_open_small_ctrlTESTbranc1.vtp'
        self.mywriter.Execute()

        self.mybifref = vmtkscripts.vmtkBifurcationReferenceSystems()
        self.mybifref.Centerlines = self.ctrl
        self.mybifref.RadiusArrayName = self.RadiusArrayName
        self.mybifref.BlankingArrayName = self.BlankingArrayName
        self.mybifref.GroupIdsArrayName = self.GroupIdsArrayName
        self.mybifref.CenterlineIdsArrayName = self.CenterlineIdsArrayName
        self.mybifref.TractIdsArrayName = self.TractIdsArrayName
        self.mybifref.Execute()

        self.myvect = vmtkscripts.vmtkBifurcationVectors()
        self.myvect.Centerlines = self.ctrl
        self.myvect.ReferenceSystems = self.mybifref.ReferenceSystems
        self.myvect.RadiusArrayName = self.RadiusArrayName
        self.myvect.BlankingArrayName = self.BlankingArrayName
        self.myvect.GroupIdsArrayName = self.GroupIdsArrayName
        self.myvect.TractIdsArrayName = self.TractIdsArrayName
        self.myvect.CenterlineIdsArrayName = self.CenterlineIdsArrayName
        self.myvect.ReferenceSystemsNormalArrayName = self.mybifref.ReferenceSystemsNormalArrayName
        self.myvect.ReferenceSystemsUpNormalArrayName = self.mybifref.ReferenceSystemsUpNormalArrayName
        self.myvect.Execute()

        '''TEMP'''
        self.mywriter = vmtkscripts.vmtkSurfaceWriter()
        self.mywriter.Surface = self.myvect.BifurcationVectors
        self.mywriter.OutputFileName = '/home/florian/liverSim/morpho_analysis/test_surf_open_small_bifvect.vtp'
        self.mywriter.Execute()

        self.mywriter.Surface = self.ctrl
        self.mywriter.OutputFileName = '/home/florian/liverSim/morpho_analysis/test_surf_open_small_ctrl.vtp'
        self.mywriter.Execute()
        '''/TEMP'''



        self.numpytator = vmtksurfacetonumpy.vmtkSurfaceToNumpy()
        self.numpytator.Surface = self.myvect.BifurcationVectors
        self.numpytator.Execute()
        vectData = self.numpytator.ArrayDict.values()

        cprint(figlet_format('Results!', font='bubble'))
        print('\n InPlaneBifurcationVectors angle:')
        print(np.degrees(self.angle_between(vectData[0]["InPlaneBifurcationVectors"][1, :],
                                            vectData[0]["InPlaneBifurcationVectors"][2, :])))
        # print('\n OutOfPlaneBifurcationVectors angle:')
        # print(np.degrees(self.angle_between(vectData[0]["OutOfPlaneBifurcationVectors"][1, :],
        #                                     vectData[0]["OutOfPlaneBifurcationVectors"][2, :])))
        print('\n bifurcation angle with the VC:')
        print(np.degrees(self.angle_between(vectData[0]["OutOfPlaneBifurcationVectors"][0, :],
                                            VCvect)))
        '''
        weighted average vector between the vectors pointing from the second 
        to the first reference point on each centerline
        '''
        print('\n global direction of the birfurcation:')
        print(vectData[0]["BifurcationVectors"][0, :])
        '''
        the origin of the bifurcation is defined as the barycenter of the four reference points
         weighted by the surface of the maximum inscribed sphere defined on the reference points. 
         The reason of the weighting is that small branches have less impact on the position of 
         the bifurcation origin
        '''
        print('\n Origin of the bifurcation:')
        print(vectData[1][0])
        pass
Example #6
0
          time.asctime(time.localtime(time.time())))
    exit()

start_time = time()

args = "vmtksurfacereader -ifile " + surfaceFile
myPype = pypes.PypeRun(args)
mySurface = myPype.GetScriptObject('vmtksurfacereader', '0').Surface

myctrl = vmtkscripts.vmtkCenterlines()
myctrl.Surface = mySurface
myctrl.SeedSelectorName = 'openprofiles'
# myctrl.Centerlines = centerlinesFile
myctrl.Execute()

myattr = vmtkscripts.vmtkCenterlineAttributes()
myattr.Centerlines = myctrl.Centerlines
myattr.Execute()

mybranchextractor = vmtkscripts.vmtkBranchExtractor()
mybranchextractor.Centerlines = myattr.Centerlines
mybranchextractor.RadiusArrayName = 'MaximumInscribedSphereRadius'
mybranchextractor.Execute()

# mywriter = vmtkscripts.vmtkSurfaceWriter()
# mywriter.Surface = mybranchextractor.Centerlines
# mywriter.OutputFileName = centerlinesFileName
# mywriter.Execute()

mybifref = vmtkscripts.vmtkBoundaryReferenceSystems()
mybifref.Surface = mybranchextractor.Centerlines
Example #7
0
def vmtkcenterlineattributes(centerline):
    computer = vmtkscripts.vmtkCenterlineAttributes()
    computer.Centerlines = centerline
    computer.Execute()
    return computer.Centerlines
def vmtkcenterlineattributes(centerline):
    computer = vmtkscripts.vmtkCenterlineAttributes()
    computer.Centerlines = centerline
    computer.Execute()
    return computer.Centerlines