1818# [4] https://mtixnat.uni-koblenz.de #
1919# #
2020#-------------------------------------------------------------------------------------#
21- # Slicer 4.11.0 #
22- # Updated: 18.1 .2022 #
21+ # Slicer 5.0.3 #
22+ # Updated: 6.8 .2022 #
2323#======================================================================================
2424
25- import os , time , logging , unittest
25+ # Non Slicer libs
26+ from __future__ import print_function
27+ import os , sys , time , re , shutil , math , unittest , logging , zipfile , platform , subprocess , hashlib
28+ from shutil import copyfile
29+
30+ from six .moves .urllib .request import urlretrieve
2631import numpy as np
27- from __main__ import qt , ctk , slicer
32+ import SimpleITK as sitk
33+
34+ # Slicer related
35+ from __main__ import vtk , qt , ctk , slicer
2836from slicer .ScriptedLoadableModule import *
37+ import sitkUtils
2938import SampleData
30-
39+ import SegmentStatistics
40+ import Elastix
3141import VisSimCommon
3242
3343# TODO:
3747# Terminology
3848# img : ITK image
3949# imgNode : Slicer Node
40- # imgName : Filename without the path and without extension
50+ # imgName : Filename without the path and without extension
4151# imgPath : wholePath + Filename and extension
4252
4353
@@ -50,14 +60,7 @@ def __init__(self, parent):
5060 parent .title = "Cochlea Registration"
5161 parent .categories = ["VisSimTools" ]
5262 parent .dependencies = []
53- parent .contributors = [
54- "Christopher Guy" ,
55- "Ibraheem Al-Dhamari" ,
56- "Michel Peltriauxe" ,
57- "Anna Gessler" ,
58- "Jasper Grimmig" ,
59- "Pepe Eulzer"
60- ]
63+ parent .contributors = ["Ibraheem Al-Dhamari" ]
6164 parent .helpText = " This module uses ACIR method to auatomatically register cochlea images"
6265 parent .acknowledgementText = " This work is sponsored by Cochlear as part of COMBS project "
6366 self .parent = parent
@@ -71,7 +74,7 @@ class CochleaRegWidget(ScriptedLoadableModuleWidget):
7174 def setup (self ):
7275 print (" " )
7376 print ("=======================================================" )
74- print (" Automatic Cochlea Image Registration " )
77+ print (" Automatic Cochlea Image Registration and Fusion " )
7578 print ("=======================================================" )
7679
7780 ScriptedLoadableModuleWidget .setup (self )
@@ -310,11 +313,11 @@ def run(self, fixedVolumeNode, fixedFiducialNode, movingVolumeNode, movingFiduci
310313
311314 print ("=================== Cropping =====================" )
312315 self .vsc .vtVars ['fixedCropPath' ] = self .vsc .runCropping (fixedVolumeNode , fixedPointT ,self .vsc .vtVars ['croppingLength' ], self .vsc .vtVars ['RSxyz' ], self .vsc .vtVars ['hrChk' ],0 )
313- [success , croppedFixedNode ] = slicer .util .loadVolume (self .vsc .vtVars ['fixedCropPath' ], returnNode = True )
316+ [success , croppedFixedNode ] = slicer .util .loadVolume (self .vsc .vtVars ['fixedCropPath' ])
314317 croppedFixedNode .SetName (fixedVolumeNode .GetName ()+ "_F_Crop" )
315318
316319 self .vsc .vtVars ['movingCropPath' ] = self .vsc .runCropping (movingVolumeNode , movingPointT ,self .vsc .vtVars ['croppingLength' ], self .vsc .vtVars ['RSxyz' ], self .vsc .vtVars ['hrChk' ],0 )
317- [success , croppedMovingNode ] = slicer .util .loadVolume (self .vsc .vtVars ['movingCropPath' ], returnNode = True )
320+ [success , croppedMovingNode ] = slicer .util .loadVolume (self .vsc .vtVars ['movingCropPath' ])
318321 croppedMovingNode .SetName (movingVolumeNode .GetName ()+ "_M_Crop" )
319322 print ("************ Register cropped moving image to cropped fixed image **********************" )
320323 cTI = self .vsc .runElastix (self .vsc .vtVars ['elastixBinPath' ],self .vsc .vtVars ['fixedCropPath' ], self .vsc .vtVars ['movingCropPath' ], self .vsc .vtVars ['outputPath' ], self .vsc .vtVars ['parsPath' ], self .vsc .vtVars ['noOutput' ], "336" )
@@ -325,19 +328,19 @@ def run(self, fixedVolumeNode, fixedFiducialNode, movingVolumeNode, movingFiduci
325328 os .rename (resOldDefPath ,resDefPath )
326329
327330 print ("************ Load deformation field Transform **********************" )
328- [success , vtTransformNode ] = slicer .util .loadTransform (resDefPath , returnNode = True )
331+ [success , vtTransformNode ] = slicer .util .loadTransform (resDefPath )
329332 vtTransformNode .SetName (transNodeName )
330333 print ("************ Transform The Original Moving image **********************" )
331334 movingVolumeNode .SetAndObserveTransformNodeID (vtTransformNode .GetID ())
332335 #export seg to lbl then export back with input image as reference
333336 slicer .vtkSlicerTransformLogic ().hardenTransform (movingVolumeNode ) # apply the transform
334337 fnm = os .path .join (self .vsc .vtVars ['outputPath' ] , movingVolumeNode .GetName ()+ "_Registered.nrrd" )
335338 sR = slicer .util .saveNode (movingVolumeNode , fnm )
336- [success , registeredMovingVolumeNode ] = slicer .util .loadVolume (fnm , returnNode = True )
339+ [success , registeredMovingVolumeNode ] = slicer .util .loadVolume (fnm )
337340 registeredMovingVolumeNode .SetName (movingVolumeNode .GetName ()+ "_Registered" )
338341 #remove the tempnode and load the original
339342 slicer .mrmlScene .RemoveNode (movingVolumeNode )
340- [success , movingVolumeNode ] = slicer .util .loadVolume (movingPath , returnNode = True )
343+ [success , movingVolumeNode ] = slicer .util .loadVolume (movingPath )
341344 movingVolumeNode .SetName (os .path .splitext (os .path .basename (movingVolumeNode .GetStorageNode ().GetFileName ()))[0 ])
342345 if (cTI == 0 ) and (cTR == 0 ):
343346 print ("No error is reported during registeration ..." )
0 commit comments