Skip to content

Commit

Permalink
ENH: enabled action button by default, added help links
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov committed Nov 30, 2012
1 parent 273b2d6 commit 4f4c073
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
50 changes: 29 additions & 21 deletions Util/LabelToDICOMSEGConverter/LabelToDICOMSEGConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ def __init__(self, parent):
parent.dependencies = ["Reporting", "DICOM", "Volumes"]
parent.contributors = ["Andrey Fedorov (Surgical Planning Lab)"] # replace with "Firstname Lastname (Org)"
parent.helpText = """
Module to convert a Slicer label map into a DICOM SEG object.
Module to convert a Slicer label map into a DICOM SEG object.
<a href=\"http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.2/Extensions/LabelToDICOMSEGConverter\">
Usage instructions</a>;
"""
parent.acknowledgementText = """
This file was originally developed by Andrey Fedorov, supported by ...
""" # replace with organization, grant and thanks.
This file was originally developed by Andrey Fedorov, supported by a
supplement to NCI U01CA151261 (PI Fiona Fennessy).
"""
self.parent = parent

#
Expand Down Expand Up @@ -48,10 +51,6 @@ def setup(self):
# Layout within the dummy collapsible button
dummyFormLayout = qt.QFormLayout(dummyCollapsibleButton)

# Input hint
self.__helpLabel = qt.QLabel('Select a label associated with a DICOM volume')
dummyFormLayout.addRow(self.__helpLabel)

# Input label node
label = qt.QLabel('Input label: ')
self.segmentationSelector = slicer.qMRMLNodeComboBox()
Expand Down Expand Up @@ -90,41 +89,45 @@ def setup(self):
dummyFormLayout.addRow(label, self.__exportFolderPicker)
dummyFormLayout.addRow(self.exportButton)
self.exportButton.connect('clicked()', self.onLabelExport)
self.exportButton.enabled = 0
self.exportButton.enabled = 1

# Input hint
self.__helpLabel = qt.QLabel('Select a label associated with a DICOM volume')
dummyFormLayout.addRow(self.__helpLabel)

# Add vertical spacer
self.layout.addStretch(1)

self.outputDir = self.__exportFolderPicker.directory

def onInputChanged(self,newNode):
pass

def onOutputDirChanged(self, newDir):
self.outputDir = newDir

def onLabelExport(self):
'''
TODO: add a check that the selected label is associated with a volume that
has DICOM.instanceUIDs attribute set
'''

label = self.segmentationSelector.currentNode()
scalar = self.volumeSelector.currentNode()

# assuming here the user does the
if label == None or scalar == None:
self.exportButton.enabled = 0
return


labelImage = label.GetImageData()
scalarImage = label.GetImageData()
lDim = labelImage.GetDimensions()
sDim = scalarImage.GetDimensions()
if lDim[0]!=sDim[0] or lDim[1]!=sDim[1] or lDim[2]!=sDim[2]:
self.__helpLabel.text = 'Geometries do not match'
self.exportButton.enabled = 0

self.exportButton.enabled = 1

def onOutputDirChanged(self, newDir):
self.outputDir = newDir
return

def onLabelExport(self):
'''
TODO: add a check that the selected label is associated with a volume that
has DICOM.instanceUIDs attribute set
'''
label = self.segmentationSelector.currentNode()
scalar = self.volumeSelector.currentNode()

Expand All @@ -135,7 +138,12 @@ def onLabelExport(self):
labelCollection.AddItem(label)
reportingLogic = slicer.modules.reporting.logic()
dirName = self.outputDir
reportingLogic.DicomSegWrite(labelCollection, dirName)
fileName = reportingLogic.DicomSegWrite(labelCollection, dirName)

if fileName == '':
self.__helpLabel.text = 'Error!'
else:
self.__helpLabel.text = 'Exported to '+fileName.split('/')[-1]

def onReload(self,moduleName="LabelToDICOMSEGConverter"):
"""Generic reload method for any scripted module.
Expand Down
2 changes: 1 addition & 1 deletion qSlicerReportingModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ QString qSlicerReportingModule::helpText()const
"some support of AIM import/export.<br>"
"Select a markup and right click to jump slice viewers to that location.<br>"
"This is a work in progress (revision " + QString(Reporting_WC_REVISION)+
"). <a href=\"http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Extensions/Reporting\">"
"). <a href=\"http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.2/Extensions/Reporting\">"
"Usage instructions</a>.";
}

Expand Down

0 comments on commit 4f4c073

Please sign in to comment.