Skip to content

Commit

Permalink
Fixing issue SlicerProstate#358.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokjun committed Oct 8, 2020
1 parent c5c341d commit b4fe318
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions SliceTracker/SliceTrackerRegistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def main(argv):

for inputFile in [args.fixed_label, args.moving_label, args.fixed_volume, args.moving_volume]:
if not os.path.isfile(inputFile):
raise AttributeError, "File not found: %s" % inputFile
raise AttributeError("File not found: %s" % inputFile)

success, fixedLabel = slicer.util.loadLabelVolume(args.fixed_label, returnNode=True)
success, movingLabel = slicer.util.loadLabelVolume(args.moving_label, returnNode=True)
Expand All @@ -325,8 +325,8 @@ def main(argv):
if args.output_directory != "-":
logic.registrationResult.save(args.output_directory)

except Exception, e:
print e
except Exception as e:
print(e)
sys.exit(0)

if __name__ == "__main__":
Expand Down
8 changes: 4 additions & 4 deletions SliceTracker/SliceTrackerUtils/configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ConfigParser
import configparser
import inspect, os
from SlicerDevelopmentToolboxUtils.mixins import ModuleWidgetMixin
from constants import SliceTrackerConstants as constants
from .constants import SliceTrackerConstants as constants


class SliceTrackerConfiguration(ModuleWidgetMixin):
Expand All @@ -13,7 +13,7 @@ def __init__(self, moduleName, configFile):

def loadConfiguration(self):

config = ConfigParser.RawConfigParser()
config = configparser.RawConfigParser()
config.read(self.configFile)

if not self.getSetting("ZFrame_Registration_Class_Name"):
Expand Down Expand Up @@ -69,4 +69,4 @@ def replaceOldValues(self):

for other in ['OTHER_IMAGE', 'Rating_Enabled', 'Maximum_Rating_Score']:
if self.getSetting(other):
self.removeSetting(other)
self.removeSetting(other)
4 changes: 2 additions & 2 deletions SliceTracker/SliceTrackerUtils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
import slicer

from constants import SliceTrackerConstants as constants
from .constants import SliceTrackerConstants as constants

from SlicerDevelopmentToolboxUtils.decorators import logmethod
from SlicerDevelopmentToolboxUtils.widgets import ExtendedQMessageBox
Expand Down Expand Up @@ -275,4 +275,4 @@ def updateTooltipAndIcon(self, series):
icon = Icons.edit
tooltip = self.listWidget.currentItem().text() if self.listWidget.currentItem() else ""
self.setIcon(icon)
self.setToolTip(tooltip)
self.setToolTip(tooltip)
8 changes: 4 additions & 4 deletions SliceTracker/SliceTrackerUtils/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import qt

import slicer
from sessionData import SessionData, RegistrationResult, RegistrationTypeData
from constants import SliceTrackerConstants
from helpers import SeriesTypeManager
from preopHandler import PreopDataHandler
from .sessionData import SessionData, RegistrationResult, RegistrationTypeData
from .constants import SliceTrackerConstants
from .helpers import SeriesTypeManager
from .preopHandler import PreopDataHandler

from SlicerDevelopmentToolboxUtils.constants import DICOMTAGS, STYLE
from SlicerDevelopmentToolboxUtils.events import SlicerDevelopmentToolboxEvents
Expand Down
8 changes: 4 additions & 4 deletions SliceTracker/SliceTrackerUtils/sessionData.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from SlicerDevelopmentToolboxUtils.decorators import onExceptionReturnNone, logmethod
from SlicerDevelopmentToolboxUtils.widgets import CustomStatusProgressbar

from constants import SliceTrackerConstants
from helpers import SeriesTypeManager
from .constants import SliceTrackerConstants
from .helpers import SeriesTypeManager


class SessionData(ModuleLogicMixin):
Expand Down Expand Up @@ -323,7 +323,7 @@ def getLocalGITRevisionInformation():
from git import Repo, InvalidGitRepositoryError
repo = Repo(dirname, search_parent_directories=True)
branch = repo.active_branch
print branch.name
print(branch.name)
return {
"GIT_WC_URL": repo.remote().url,
"GIT_COMMIT_HASH": repo.head.object.hexsha
Expand Down Expand Up @@ -984,4 +984,4 @@ def save(self, outputDir):
success, name = self.saveNodeData(self.volume, outputDir, FileExtension.NRRD)
dictionary["volume"] = name + FileExtension.NRRD
self.handleSaveNodeDataReturn(success, name, savedSuccessfully, failedToSave)
return dictionary
return dictionary
10 changes: 5 additions & 5 deletions SliceTracker/SliceTrackerUtils/steps/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import qt
import vtk
import slicer
from base import SliceTrackerLogicBase, SliceTrackerStep
from .base import SliceTrackerLogicBase, SliceTrackerStep
from ..constants import SliceTrackerConstants as constants
from plugins.results import SliceTrackerRegistrationResultsPlugin
from plugins.targets import SliceTrackerTargetTablePlugin
from plugins.charts import SliceTrackerDisplacementChartPlugin
from .plugins.results import SliceTrackerRegistrationResultsPlugin
from .plugins.targets import SliceTrackerTargetTablePlugin
from .plugins.charts import SliceTrackerDisplacementChartPlugin

from SlicerDevelopmentToolboxUtils.icons import Icons

Expand Down Expand Up @@ -142,4 +142,4 @@ def onNoRegistrationResultsAvailable(self, caller, event):

def onRegistrationResultsAvailable(self, caller, event):
self.approveRegistrationResultButton.enabled = True
self.targetTablePlugin.enabled = True
self.targetTablePlugin.enabled = True
14 changes: 7 additions & 7 deletions SliceTracker/SliceTrackerUtils/steps/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import slicer
import vtk

from base import SliceTrackerLogicBase, SliceTrackerStep
from plugins.case import SliceTrackerCaseManagerPlugin
from plugins.results import SliceTrackerRegistrationResultsPlugin
from plugins.targets import SliceTrackerTargetTablePlugin
from plugins.training import SliceTrackerTrainingPlugin
from plugins.charts import SliceTrackerDisplacementChartPlugin
from .base import SliceTrackerLogicBase, SliceTrackerStep
from .plugins.case import SliceTrackerCaseManagerPlugin
from .plugins.results import SliceTrackerRegistrationResultsPlugin
from .plugins.targets import SliceTrackerTargetTablePlugin
from .plugins.training import SliceTrackerTrainingPlugin
from .plugins.charts import SliceTrackerDisplacementChartPlugin
from ..constants import SliceTrackerConstants as constants
from ..sessionData import RegistrationResult
from ..helpers import IncomingDataMessageBox, SeriesTypeToolButton, SeriesTypeManager
Expand Down Expand Up @@ -368,4 +368,4 @@ def promptUserAndApplyBiasCorrectionIfNeeded(self):
currentModule.parent().enabled = True
customProgressbar.updateStatus("Bias correction done!")

self.session.data.preopData.usedERC = usedERC
self.session.data.preopData.usedERC = usedERC
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import vtk

from base import SliceTrackerSegmentationPluginBase
from .base import SliceTrackerSegmentationPluginBase
from ....algorithms.automaticProstateSegmentation import AutomaticSegmentationLogic

class SliceTrackerAutomaticSegmentationPlugin(SliceTrackerSegmentationPluginBase):
Expand Down Expand Up @@ -44,4 +44,4 @@ def _onSegmentationFinished(self, caller, event, labelNode):
# import ast
# status = ast.literal_eval(str(callData))
# self.updateProgressBar(progress=statusBar, text=status["text"].replace("\n", ""), value=status["value"],
# maximum = 100)
# maximum = 100)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ...base import SliceTrackerPlugin, SliceTrackerLogicBase
from ....constants import SliceTrackerConstants as constants
from base import SliceTrackerSegmentationPluginBase
from .base import SliceTrackerSegmentationPluginBase
from SurfaceCutToLabel import SurfaceCutToLabelWidget

from SlicerDevelopmentToolboxUtils.decorators import onModuleSelected
Expand Down Expand Up @@ -120,4 +120,4 @@ def _onSegmentationFinished(self, caller, event, labelNode):
displayNode = labelNode.GetDisplayNode()
displayNode.SetAndObserveColorNodeID(self.session.mpReviewColorNode.GetID())
self.surfaceCutToLabelWidget.colorSpin.setValue(self.session.segmentedLabelValue)
super(SliceTrackerManualSegmentationPlugin, self)._onSegmentationFinished(caller, event, labelNode)
super(SliceTrackerManualSegmentationPlugin, self)._onSegmentationFinished(caller, event, labelNode)
4 changes: 2 additions & 2 deletions SliceTracker/SliceTrackerUtils/steps/plugins/targeting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import qt
from ...constants import SliceTrackerConstants as constants
from ..base import SliceTrackerPlugin, SliceTrackerLogicBase
from targets import SliceTrackerTargetTablePlugin
from .targets import SliceTrackerTargetTablePlugin

from SlicerDevelopmentToolboxUtils.helpers import SliceAnnotation
from SlicerDevelopmentToolboxUtils.widgets import TargetCreationWidget
Expand Down Expand Up @@ -143,4 +143,4 @@ def _onTargetingFinished(self, caller, event):
if not self.preopAvailableAndTargetsDefined():
self.session.movingTargets = None

self.invokeEvent(self.TargetingFinishedEvent)
self.invokeEvent(self.TargetingFinishedEvent)
4 changes: 2 additions & 2 deletions SliceTracker/SliceTrackerUtils/steps/plugins/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def unzipFileAndCopyToDirectory(self, filepath, copyToDirectory):
self.clearData()

def copyDirectory(self, source, destination, recursive=True):
print source
print(source)
assert os.path.isdir(source)
for listObject in os.listdir(source):
current = os.path.join(source, listObject)
Expand All @@ -118,4 +118,4 @@ def onCaseClosed(self, caller, event, callData):
self.simulateIntraopPhaseButton.enabled = False

def onPreprocessingSuccessful(self, caller, event):
self.simulateIntraopPhaseButton.enabled = self.session.trainingMode
self.simulateIntraopPhaseButton.enabled = self.session.trainingMode
10 changes: 5 additions & 5 deletions SliceTracker/SliceTrackerUtils/steps/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import slicer
import vtk

from base import SliceTrackerLogicBase, SliceTrackerStep
from .base import SliceTrackerLogicBase, SliceTrackerStep
from ..constants import SliceTrackerConstants as constants
from ..sessionData import SegmentationData

from plugins.targeting import SliceTrackerTargetingPlugin
from plugins.segmentation.manual import SliceTrackerManualSegmentationPlugin
from plugins.segmentation.automatic import SliceTrackerAutomaticSegmentationPlugin
from .plugins.targeting import SliceTrackerTargetingPlugin
from .plugins.segmentation.manual import SliceTrackerManualSegmentationPlugin
from .plugins.segmentation.automatic import SliceTrackerAutomaticSegmentationPlugin

from SlicerDevelopmentToolboxUtils.helpers import SliceAnnotation
from SlicerDevelopmentToolboxUtils.decorators import onModuleSelected
Expand Down Expand Up @@ -358,4 +358,4 @@ def _onTargetingStarted(self, caller, event):
def _onTargetingFinished(self, caller, event):
self.finishStepButton.setEnabled(1 if self.logic.inputsAreSet() else 0)
self.manualSegmentationPlugin.enabled = True
self.backButton.enabled = True
self.backButton.enabled = True
4 changes: 2 additions & 2 deletions SliceTracker/SliceTrackerUtils/steps/zFrameRegistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ..algorithms.zFrameRegistration import LineMarkerRegistration, OpenSourceZFrameRegistration
from ..constants import SliceTrackerConstants
from base import SliceTrackerLogicBase, SliceTrackerStep
from .base import SliceTrackerLogicBase, SliceTrackerStep

from SlicerDevelopmentToolboxUtils.decorators import onModuleSelected
from SlicerDevelopmentToolboxUtils.helpers import SliceAnnotation
Expand Down Expand Up @@ -537,4 +537,4 @@ def onApproveZFrameRegistrationButtonClicked(self):
def onRetryZFrameRegistrationButtonClicked(self):
self.removeZFrameInstructionAnnotation()
self.annotationLogic.SetAnnotationVisibility(self.coverTemplateROI.GetID())
self.initiateZFrameRegistrationStep()
self.initiateZFrameRegistrationStep()
16 changes: 8 additions & 8 deletions SliceTracker/SliceTrackerUtils/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def watch(self, secondsToWait=1):
while True:
currentFiles = self.listdirRecursive(self.directory)
if len(self.files) < len(currentFiles):
print "Number of files changed"
print("Number of files changed")
for newFile in self.getNewFiles(currentFiles):
self.storeSCU(newFile)
time.sleep(secondsToWait)
Expand All @@ -46,7 +46,7 @@ def getNewFiles(self, files):

def storeSCU(self, fileName):
cmd = ('storescu ' + self.host + ' ' + self.port + ' ' + fileName)
print cmd
print(cmd)
os.system(cmd)
self.files.add(fileName)

Expand All @@ -58,11 +58,11 @@ def main(argv):
try:
opts, args = getopt.getopt(argv,"i:d:h:p:?",["help","directory=","host=","port=","interval="])
except getopt.GetoptError:
print 'watch.py -d <watchDirectory> -h <host> -p <port> -i <interval [in seconds]>'
print('watch.py -d <watchDirectory> -h <host> -p <port> -i <interval [in seconds]>')
sys.exit(2)
for opt, arg in opts:
if opt in ("-?", "--help"):
print 'watch.py -d <watchDirectory> -h <host> -p <port>'
print('watch.py -d <watchDirectory> -h <host> -p <port>')
sys.exit()
elif opt in ("-d", "--directory"):
watchDirectory = arg
Expand All @@ -73,12 +73,12 @@ def main(argv):
elif opt in ("-i", "--interval"):
interval = int(arg)
if watchDirectory and host and port:
print 'Directory to watch is: ', watchDirectory
print 'Host to send DICOM files to is: ', host
print 'Port to send DICOM files to is: ', port
print('Directory to watch is: ', watchDirectory)
print('Host to send DICOM files to is: ', host)
print('Port to send DICOM files to is: ', port)

watcher = DICOMDirectoryObserver(directory=watchDirectory, host=host, port=port)
print "Will watch!"
print("Will watch!")
watcher.watch(interval)

if __name__ == "__main__":
Expand Down

0 comments on commit b4fe318

Please sign in to comment.