def calculateLRE(case): success, intraopLandmarks = slicer.util.loadMarkupsFiducialList( case['intraopLandmarks'], returnNode=True) success, preopTransformedLandmarks = slicer.util.loadMarkupsFiducialList( case['preopTransformedLandmarks'], returnNode=True) numLandmarks = intraopLandmarks.GetNumberOfFiducials() caseData = [] caseTRE = 0 for i in range(numLandmarks): label = preopTransformedLandmarks.GetNthFiducialLabel(i) label = "-" + label.split("-")[-1] fiducialIndex = getFiducialIndexByLabel(intraopLandmarks, label) intraopPos = ModuleLogicMixin.getTargetPosition( intraopLandmarks, fiducialIndex) preopTransformedPos = ModuleLogicMixin.getTargetPosition( preopTransformedLandmarks, i) landmarkTRE = ModuleLogicMixin.get3DEuclideanDistance( intraopPos, preopTransformedPos) caseTRE = caseTRE + landmarkTRE caseData.append([ " ", intraopLandmarks.GetNthFiducialLabel(fiducialIndex), intraopPos[0], intraopPos[1], intraopPos[2], preopTransformedLandmarks.GetNthFiducialLabel(i), preopTransformedPos[0], preopTransformedPos[1], preopTransformedPos[2], "", landmarkTRE ]) caseTRE = caseTRE / (numLandmarks * 1.0) caseData.append(["", "", "", "", "", "", "", "", "", "", "", caseTRE]) return caseData
return data def calculateLRE(case, landmark, transformed): success, landmarksNode = slicer.util.loadMarkupsFiducialList( landmark, returnNode=True) success, transformedNode = slicer.util.loadMarkupsFiducialList( transformed, returnNode=True) caseData = [] for i in range(landmarksNode.GetNumberOfFiducials()): landmarkData = [case] landmarkPos = ModuleLogicMixin.getTargetPosition(landmarksNode, i) transformedPos = ModuleLogicMixin.getTargetPosition(transformedNode, i) landmarkTRE = ModuleLogicMixin.get3DEuclideanDistance( landmarkPos, transformedPos) landmarkData.append(landmarksNode.GetNthFiducialLabel(i)) landmarkData.append(str(landmarkPos)) landmarkData.append(transformedNode.GetNthFiducialLabel(i)) landmarkData.append(str(transformedPos)) landmarkData.append(landmarkTRE) caseData.append(landmarkData) return caseData def getFiducialIndexByLabel(node, labelEnd): for index in range(node.GetNumberOfFiducials()): if node.GetNthFiducialLabel(index).endswith(labelEnd):