segment.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import slicer
  2. import Elastix
  3. import CTRegistration
  4. import slicerNetwork
  5. configFile = os.path.join(os.path.expanduser('~'), '.EMBRACE','onko-nix.json')
  6. dataManager = CTRegistration.CTRegistrationLogic(configFile)
  7. network = slicerNetwork.labkeyURIHandler()
  8. dataManager.importer.setURIHandler(network)
  9. elastix = Elastix.ElastixLogic()
  10. registrationIndex = 17
  11. """
  12. id="par0023"
  13. modality="3D CT, 3D MR, multimodal"
  14. content="head and neck"
  15. description="intrapatient; rigid + B-spline transformation; localized mutual information combined with bending energy penalty"
  16. publications="Leibfarth (2013), A strategy for multimodal deformable image registration to integrate PET/MR into radiotherapy treatment planning"
  17. """
  18. RegistrationPresets_ParameterFilenames = 5
  19. """
  20. ['Rigid.txt', 'Deformable.txt']
  21. """
  22. parameterFilenames = elastix.getRegistrationPresets()[registrationIndex][RegistrationPresets_ParameterFilenames]
  23. transformNode=slicer.vtkMRMLGridTransformNode()
  24. transformNode.SetName(transformNodeName)
  25. slicer.mrmlScene.AddNode(transformNode)
  26. for i in range(0,86):
  27. patientID = 'LJU'+'{:03d}'.format(i)
  28. dataManager.loadData(network,patientID)
  29. fixedVolumeNode = slicer.util.getFirstNodeByName(patientID+'_DMR')
  30. movingVolumeNode = slicer.util.getFirstNodeByName(patientID+'_CT')
  31. transformNodeName = patientID+'_T2_DF'
  32. elastix.registerVolumes(fixedVolumeNode, movingVolumeNode, parameterFilenames = parameterFilenames, outputVolumeNode = None, outputTransformNode = transformNode, fixedVolumeMaskNode = None, movingVolumeMaskNode = None, forceDisplacementFieldOutputTransform = True)
  33. dataManager.export(network, 'EMBRACE/Studija', patientID)