Skip to content

Commit 61df1b6

Browse files
author
idhamari
committed
some cleaning
1 parent 1942766 commit 61df1b6

2 files changed

Lines changed: 10 additions & 28 deletions

File tree

CochleaSeg/CochleaSeg.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@
2020
#-------------------------------------------------------------------------------------#
2121
# Slicer 4.11.0 #
2222
# Updated: 24.6.2019 #
23-
#-------------------------------------------------------------------------------------#
24-
# - Add branches to github to support new Slicer versions #
25-
# - Using VisSimCommon for shared functions. #
26-
# - Use transformation directly to transform the points. #
27-
# - Add more support for windows and mac. #
28-
# - Logic functions are independent and can be called from external script. #
29-
# - test function can be used in external scripts. A demo example is provided #
3023
#======================================================================================
31-
3224
from __future__ import print_function
3325
import os, time, unittest, logging
3426
from shutil import copyfile
@@ -90,7 +82,6 @@ def __init__(self, parent):
9082
#end def init
9183
#end class CochleaSeg
9284

93-
9485
#===================================================================
9586
# Main Widget
9687
#===================================================================
@@ -281,21 +272,15 @@ def run(self, inputVolumeNode, inputFiducialNode, cochleaSide):
281272
Styp="Dv"
282273

283274
# segmentation atlas model paths
284-
285-
modelPath = self.vsc.vtVars['modelPath']+ ",Mdl"+Styp +cochleaSide +"c"+self.vsc.vtVars['imgType']
286-
modelPath = os.path.join(*modelPath.split(","))
287-
modelSegPath = self.vsc.vtVars['modelPath']+ ",Mdl"+Styp +cochleaSide +"cS.seg"+self.vsc.vtVars['imgType']
288-
modelSegPath = os.path.join(*modelSegPath.split(","))
289-
modelImgStPath = self.vsc.vtVars['modelPath']+ ",Mdl"+Styp +cochleaSide +"cSt.fcsv"
290-
modelImgStPath = os.path.join(*modelImgStPath.split(","))
275+
modelPath = os.path.join(self.vsc.vtVars['modelPath'] , "Mdl"+Styp +cochleaSide +"c"+self.vsc.vtVars['imgType'])
276+
modelSegPath = os.path.join(self.vsc.vtVars['modelPath'] , "Mdl"+Styp +cochleaSide +"cS.seg"+self.vsc.vtVars['imgType'])
277+
modelImgStPath = os.path.join(self.vsc.vtVars['modelPath'] , "Mdl"+Styp +cochleaSide +"cSt.fcsv")
291278
# set the results paths:
292279
resTransPathOld = os.path.join(self.vsc.vtVars['outputPath'] ,"TransformParameters.0.txt")
293280
resTransPath=resTransPathOld[0:-6]+'Pars.txt'
294281
resOldDefPath = os.path.join(self.vsc.vtVars['outputPath'] , "deformationField"+self.vsc.vtVars['imgType'])
295282
resDefPath = os.path.join(self.vsc.vtVars['outputPath'] , inputVolumeNode.GetName()+"_dFld"+self.vsc.vtVars['imgType'])
296-
inputImgName = inputVolumeNode.GetStorageNode().GetFileName()
297-
inputImgName = os.path.basename(os.path.splitext(inputImgName)[0])
298-
283+
inputImgName = os.path.basename(os.path.splitext(inputVolumeNode.GetStorageNode().GetFileName())[0])
299284
segNodeName = inputVolumeNode.GetName() + "_S.Seg"
300285
stpNodeName = inputVolumeNode.GetName() + "_StPts"
301286
transNodeName = inputVolumeNode.GetName() + "_Transform"

VisSimCommon/VisSimCommon.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#======================================================================================
32
# 3D Slicer [1] common functions used by VisSim extensions #
43
# #
@@ -238,8 +237,6 @@ def s2b(self,s):
238237
return s.lower() in ("yes", "true", "t", "1")
239238
#enddef
240239

241-
inputPointT = self.vsc.v2t(inputPoint) # "["+str(inputPoint[0])+","+str(inputPoint[1])+","+str(inputPoint[2])+"]"
242-
243240
#convert a vector to text
244241
def v2t(self,v):
245242
return "["+str(v[0])+","+str(v[1])+","+str(v[2])+"]"
@@ -322,7 +319,7 @@ def ptRAS2IJK(self,ptRAS,inputImg,i):
322319
ptIJK = ptIJKf.astype(np.int64)
323320
#print("RAS= " + str(ras)+ " IJK= " + str(ptIJK))
324321
return ptIJK
325-
322+
#enddef
326323

327324
#------------------------------------------------------
328325
# image2points
@@ -374,7 +371,7 @@ def image2points(self,inputImgNode):
374371
self.markupsNode.SetName(inputImgNode.GetName()+ "_StPts")
375372
return self.markupsNode
376373

377-
#enddef
374+
#enddef
378375

379376

380377
#-----------------------------------------------------------------------------------
@@ -525,6 +522,7 @@ def runCropping(self, inputVolume, pointT,croppingLengthT, samplingLengthT, hrCh
525522
# so we can remove these files later
526523
return inputCropPath
527524
#enddef
525+
528526
#--------------------------------------------------------------------------------------------
529527
# run elastix
530528
#--------------------------------------------------------------------------------------------
@@ -800,7 +798,6 @@ def setItemChk(self,itemT, itemChk, itemName, nodes,):
800798
#endif
801799
#print("side selected is " + self.vtVars[itemT])
802800
#endif
803-
804801
#enddef
805802

806803
def setVtID(self,idx,inputVolumeNode , inputFiducialNode):
@@ -853,7 +850,8 @@ def setVtIDfromEdt(self,point,vtID):
853850
return isExternalCall
854851
#enddef
855852

856-
#this part need to be optimized
853+
# Slicer4 Slicer5 conflict
854+
# this part need to be optimized
857855
# reg =0: no registration, 1: fixed image, 2: moving image
858856
def locateItem(self, inputVolumeNode, inputPointEdt, reg, vtID):
859857
self.inputFiducialNodes = []
@@ -1162,8 +1160,7 @@ def dispSeg(self,inputVolumeNode, vtSegNode, view):
11621160
v3DDWidgetV.zoomIn()
11631161
v3DDWidgetV.zoomFactor =0.05 # back to default value
11641162
#enddef
1165-
1166-
1163+
#endclass
11671164

11681165
class VisSimCommonTest(ScriptedLoadableModuleLogic):
11691166

0 commit comments

Comments
 (0)