Skip to content

Commit

Permalink
Fix Python 3 issue related to dict_keys. Also change the coordinate f…
Browse files Browse the repository at this point in the history
…rame for zframe-model.vtk from RAS to LPS (https://discourse.slicer.org/t/model-files-are-now-saved-in-lps-coordinate-system/10446). These are part of the transition to Slicer 4.11.20200930. See SlicerProstate#358.
  • Loading branch information
tokjun committed Oct 9, 2020
1 parent db109b9 commit e9da7e8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions SliceTracker/Resources/zframe/zframe-model.vtk
@@ -1,5 +1,5 @@
# vtk DataFile Version 3.0
vtk output
# vtk DataFile Version 4.2
3D Slicer output. SPACE=RAS
ASCII
DATASET POLYDATA
POINTS 168 float
Expand Down Expand Up @@ -60,6 +60,9 @@ POINTS 168 float
-29.25 28.701 -30 -30.75 28.701 -30 -31.5 30 -30
-30.75 31.299 -30 -29.25 31.299 -30 -28.5 30 -30

METADATA
INFORMATION 0

POLYGONS 56 308
4 0 1 3 2
4 2 3 5 4
Expand Down
6 changes: 3 additions & 3 deletions SliceTracker/SliceTrackerRegistration.py
Expand Up @@ -125,7 +125,7 @@ def runRegistration(self):
@onReturnProcessEvents
def updateProgressBar(self, **kwargs):
if self.progress:
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
if hasattr(self.progress, key):
setattr(self.progress, key, value)

Expand Down Expand Up @@ -237,7 +237,7 @@ def doRigidRegistration(self, **kwargs):
'outputVolume': self.registrationResult.volumes.rigid.GetID(),
'maskProcessingMode': "ROI",
'useRigid': True}
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
paramsRigid[key] = value
slicer.cli.run(slicer.modules.brainsfit, None, paramsRigid, wait_for_completion=True)
self.registrationResult.cmdArguments += "Rigid Registration Parameters: %s" % str(paramsRigid) + "\n\n"
Expand Down Expand Up @@ -273,7 +273,7 @@ def doBSplineRegistration(self, initialTransform, **kwargs):
'costFunctionConvergenceFactor': "1.00E+09",
'maskProcessingMode': "ROI",
'initialTransform': initialTransform}
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
paramsBSpline[key] = value

slicer.cli.run(slicer.modules.brainsfit, None, paramsBSpline, wait_for_completion=True)
Expand Down
4 changes: 2 additions & 2 deletions SliceTracker/SliceTrackerUtils/preopHandler.py
Expand Up @@ -95,7 +95,7 @@ def _runPreProcessing(self):

@onReturnProcessEvents
def updateProgressBar(**kwargs):
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
if hasattr(progress, key):
setattr(progress, key, value)

Expand Down Expand Up @@ -303,4 +303,4 @@ def getMostRecentWholeGlandSegmentation(self, path):
return self.getMostRecentFile(path, FileExtension.NRRD, filter="WholeGland")

def getMostRecentTargetsFile(self, path):
return self.getMostRecentFile(path, FileExtension.FCSV)
return self.getMostRecentFile(path, FileExtension.FCSV)
10 changes: 5 additions & 5 deletions SliceTracker/SliceTrackerUtils/sessionData.py
Expand Up @@ -168,7 +168,7 @@ def loadResults(self, data, directory):
self.customProgressBar.updateStatus("Loading series registration result %s" % result.name, index)
slicer.app.processEvents()

for attribute, value in jsonResult.iteritems():
for attribute, value in jsonResult.items():
logging.debug("found %s: %s" % (attribute, value))
if attribute == 'volumes':
self._loadResultFileData(value, directory, slicer.util.loadVolume, result.setVolume)
Expand Down Expand Up @@ -206,7 +206,7 @@ def loadResults(self, data, directory):
self.customProgressBar.text = "Finished loading registration results"

def _loadResultFileData(self, dictionary, directory, loadFunction, setFunction):
for regType, filename in dictionary.iteritems():
for regType, filename in dictionary.items():
data = self._loadOrGetFileData(directory, filename, loadFunction)
setFunction(regType, data)

Expand Down Expand Up @@ -476,7 +476,7 @@ def getFileNameByAttributeName(self, name):

def getAllFileNames(self):
fileNames = {}
for regType, node in self.asDict().iteritems():
for regType, node in self.asDict().items():
if node:
fileNames[regType] = self.getFileName(node)
return fileNames
Expand All @@ -501,7 +501,7 @@ def createFromJSON(data):

def toJSON(self):
output = {}
for key, value in self.__dict__.iteritems():
for key, value in self.__dict__.items():
if any(key.startswith(starter) for starter in ["_", "__"]) or value is None or value == "":
continue
output[key] = value.toJSON() if hasattr(value, "toJSON") else value
Expand Down Expand Up @@ -667,7 +667,7 @@ def isGoingToBeMoved(self, targetList, index):
self.modifiedTargets[regType][index] = True

def getRegistrationTypeForTargetList(self, targetList):
for regType, currentTargetList in self.asDict().iteritems():
for regType, currentTargetList in self.asDict().items():
if targetList is currentTargetList:
return regType
return None
Expand Down
2 changes: 1 addition & 1 deletion SliceTracker/SliceTrackerUtils/steps/plugins/targets.py
Expand Up @@ -448,7 +448,7 @@ def disableTargetMovingMode(self):
self.moveTargetMode = False

def clearTargetMovementObserverAndAnnotations(self):
for widget, (observer, annotation) in self.mouseReleaseEventObservers.iteritems():
for widget, (observer, annotation) in self.mouseReleaseEventObservers.items():
sliceView = widget.sliceView()
interactor = sliceView.interactorStyle().GetInteractor()
interactor.RemoveObserver(observer)
Expand Down

0 comments on commit e9da7e8

Please sign in to comment.