Esempio n. 1
0
    def loadFiducialsXml(self, volumeNode, fileName):
        """ Load from disk a list of fiducials for a particular volume node
        :param volumeNode: Volume (scalar node)
        :param fileName: full path of the file to load the fiducials where
        """
        with open(fileName, "r") as f:
            xml = f.read()

        self.currentGeometryTopologyData = gtd.GeometryTopologyData.from_xml(
            xml)
        for point in self.currentGeometryTopologyData.points:
            # Activate the current fiducials list based on the type list
            typesList = self.getTypesListFromXmlPoint(point)
            fidListNode = self.setActiveFiducialsListNode(
                volumeNode, typesList)
            # Check if the coordinate system is RAS (and make the corresponding transform otherwise)
            if self.currentGeometryTopologyData.coordinate_system == self.currentGeometryTopologyData.LPS:
                coord = Util.lps_to_ras(point.coordinate)
            elif self.currentGeometryTopologyData.coordinate_system == self.currentGeometryTopologyData.IJK:
                coord = Util.ijk_to_ras(volumeNode, point.coordinate)
            else:
                # Try default mode (RAS)
                coord = point.coordinate
            # Add the fiducial
            fidListNode.AddFiducial(coord[0], coord[1], coord[2],
                                    self.getMarkupLabel(typesList))
Esempio n. 2
0
    def loadFiducialsXml(self, volumeNode, fileName):
        """ Load from disk a list of fiducials for a particular volume node
        :param volumeNode: Volume (scalar node)
        :param fileName: full path of the file to load the fiducials where
        """
        with open(fileName, "r") as f:
            xml = f.read()

        self.currentGeometryTopologyData = GTD.GeometryTopologyData.from_xml(
            xml)
        for point in self.currentGeometryTopologyData.points:
            subtype = point.chest_type
            if subtype in self.params.mainTypes.keys():
                # Main type. The subtype will be "Any"
                mainType = subtype
                subtype = 0
            else:
                mainType = self.params.getMainTypeForSubtype(subtype)
            # Activate the current fiducials list based on the main type
            fidListNode = self.setActiveFiducialsListNode(
                volumeNode, mainType, subtype, point.feature_type)
            # Check if the coordinate system is RAS (and make the corresponding transform otherwise)
            if self.currentGeometryTopologyData.coordinate_system == self.currentGeometryTopologyData.LPS:
                coord = Util.lps_to_ras(point.coordinate)
            elif self.currentGeometryTopologyData.coordinate_system == self.currentGeometryTopologyData.IJK:
                coord = Util.ijk_to_ras(volumeNode, point.coordinate)
            else:
                # Try default mode (RAS)
                coord = point.coordinate
            # Add the fiducial
            fidListNode.AddFiducial(
                coord[0], coord[1], coord[2],
                self.getMarkupLabel(mainType, subtype, point.feature_type))
    def loadFiducials(self, volumeNode, fileName):
        """ Load from disk a list of fiducials for a particular volume node
        :param volumeNode: Volume (scalar node)
        :param fileName: full path of the file to load the fiducials where
        """
        with open(fileName, "r") as f:
            xml = f.read()

        geom = GTD.GeometryTopologyData.from_xml(xml)
        for point in geom.points:
            subtype = point.chest_type
            if subtype in self.params.mainTypes.keys():
                # Main type. The subtype will be "Any"
                mainType = subtype
                subtype = 0
            else:
                mainType = self.params.getMainTypeForSubtype(subtype)
            # Activate the current fiducials list based on the main type
            fidList = self.setActiveFiducialsListNode(volumeNode, mainType, subtype, point.feature_type)
            # Check if the coordinate system is RAS (and make the corresponding transform otherwise)
            if geom.coordinate_system == geom.LPS:
                coord = Util.lps_to_ras(point.coordinate)
            elif geom.coordinate_system == geom.IJK:
                coord = Util.ijk_to_ras(volumeNode, point.coordinate)
            else:
                # Try default mode (RAS)
                coord = point.coordinate
            # Add the fiducial
            fidList.AddFiducial(coord[0], coord[1], coord[2], self.getMarkupLabel(mainType, subtype, point.feature_type))