From a5201c98e8e5f0229b714aedbf65755f93e1912b Mon Sep 17 00:00:00 2001 From: Shelly Belsky Date: Mon, 18 Nov 2024 10:05:30 -0500 Subject: [PATCH] WIP: Consolidate UI and implement config file lists --- AutoscoperM/AutoscoperM.py | 54 +- AutoscoperM/Resources/UI/AutoscoperM.ui | 753 +++++++++++++----------- 2 files changed, 468 insertions(+), 339 deletions(-) diff --git a/AutoscoperM/AutoscoperM.py b/AutoscoperM/AutoscoperM.py index 502ff56..f5e15be 100644 --- a/AutoscoperM/AutoscoperM.py +++ b/AutoscoperM/AutoscoperM.py @@ -215,8 +215,10 @@ def setup(self): self.ui.configGenButton.connect("clicked(bool)", self.onGenerateConfig) self.ui.segmentationButton.connect("clicked(bool)", self.onSegmentation) self.ui.importModelsButton.connect("clicked(bool)", self.onImportModels) - self.ui.loadPVButton.connect("clicked(bool)", self.onLoadPV) + self.ui.populateTrialNameListButton.connect("clicked(bool)", self.onPopulateTrialNameList) + self.ui.populatePartialVolumeListButton.connect("clicked(bool)", self.onPopulatePartialVolumeList) + self.ui.populateCameraCalListButton.connect("clicked(bool)", self.onPopulateCameraCalList) # Default output directory self.ui.mainOutputSelector.setCurrentPath( @@ -556,11 +558,10 @@ def onImportModels(self): slicer.mrmlScene.RemoveNode(returnedNode) self.ui.progressBar.setValue((idx + 1) / len(segmentationFiles) * 100) else: # Should never happen but just in case - raise Exception("No segmentation method selected") + raise Exception("Please select the 'Segmentation From Model' option in order to import models") return slicer.util.messageBox("Success!") - def onSegmentation(self): """ Launches the automatic segmentation process @@ -598,9 +599,8 @@ def onSegmentation(self): segmentationSequenceNode.SetDataNodeAtValue(segmentationNode, str(i)) slicer.mrmlScene.RemoveNode(segmentationNode) currentVolumeNode = self.logic.getNextItemInSequence(volumeNode) - #elif else: # Should never happen but just in case - raise Exception("No segmentation method selected") + raise Exception("Please select the 'Automatic Segmentation' option in order to generate segmentations") return slicer.util.messageBox("Success!") @@ -656,6 +656,50 @@ def onLoadPV(self): slicer.util.messageBox("Success!") + def onPopulateTrialNameList(self): + """ + Populates trial name UI list using files from the selected radiograph directory + """ + radiographDir = os.path.join(self.ui.mainOutputSelector.currentPath, self.ui.vrgSubDir.text) + self.populateFileList(self.ui.trialList, radiographDir, itemType="dir") + + def onPopulatePartialVolumeList(self): + """ + Populates partial volumes UI list using files from the selected PV directory + """ + radiographDir = os.path.join(self.ui.mainOutputSelector.currentPath, self.ui.tiffSubDir.text) + self.populateFileList(self.ui.partialVolumeList, radiographDir) + + def onPopulateCameraCalList(self): + """ + Populates camera calibration UI list using files from the selected camera directory + """ + radiographDir = os.path.join(self.ui.mainOutputSelector.currentPath, self.ui.cameraSubDir.text) + self.populateFileList(self.ui.camCalList, radiographDir) + + def populateFileList(self, listWidget, fileDir, itemType="file"): + """ + Populates trial name UI list using files from the selected radiograph directory + """ + listWidget.clear() + if not self.logic.validatePaths( + fileDir=fileDir, + ): + raise ValueError("Invalid input: subdirectory does not exist") + return + + if itemType == "file": + listFiles = [f.name for f in os.scandir(fileDir) if os.path.isfile(f)] + elif itemType == "dir": + listFiles = [f.name for f in os.scandir(fileDir) if os.path.isdir(f)] + else: + raise ValueError(f"Invalid input: can only search for either files or directories in specified path, but given itemType={itemType}") + return + + for file in listFiles: + fileItem = qt.QListWidgetItem(file) + fileItem.setCheckState(qt.Qt.Unchecked) + listWidget.addItem(fileItem) # # AutoscoperMLogic diff --git a/AutoscoperM/Resources/UI/AutoscoperM.ui b/AutoscoperM/Resources/UI/AutoscoperM.ui index b848016..379c451 100644 --- a/AutoscoperM/Resources/UI/AutoscoperM.ui +++ b/AutoscoperM/Resources/UI/AutoscoperM.ui @@ -9,8 +9,8 @@ 0 0 - 1031 - 1020 + 811 + 1566 @@ -138,44 +138,48 @@ - - - Output Directory: - - - - - - - ctkPathLineEdit::Dirs|ctkPathLineEdit::Executable|ctkPathLineEdit::NoDot|ctkPathLineEdit::NoDotDot|ctkPathLineEdit::Writable - - - - - - - Volume Node: - - - - - - - false - - - - vtkMRMLScalarVolumeNode - vtkMRMLSequenceNode - - - - - - - - - + + + + + Output Directory: + + + + + + + ctkPathLineEdit::Dirs|ctkPathLineEdit::Executable|ctkPathLineEdit::NoDot|ctkPathLineEdit::NoDotDot|ctkPathLineEdit::Writable + + + + + + + Volume Node: + + + + + + + true + + + + vtkMRMLScalarVolumeNode + vtkMRMLSequenceNode + + + + + + + + + + + @@ -189,7 +193,24 @@ false - + + + + Automatic Segmentation + + + true + + + + + + + Threshold Value: + + + + 10000 @@ -199,77 +220,66 @@ - + + + + Margin Size: + + + + 2.000000000000000 - - + + - Threshold Value: + Generate Segmentations - + - Segmentation from Model + OR - - + + - OR + Segmentation from Model - - + + false - - ctkPathLineEdit::Dirs|ctkPathLineEdit::Drives|ctkPathLineEdit::Executable|ctkPathLineEdit::NoDot|ctkPathLineEdit::NoDotDot|ctkPathLineEdit::Readable - - - - - - - STL Model File Directory: - - - - - - Automatic Segmentation - - - true + STL Models Directory: - - - - Margin Size: + + + + false - - - - - - Generate Segmentations + + ctkPathLineEdit::Dirs|ctkPathLineEdit::Drives|ctkPathLineEdit::Executable|ctkPathLineEdit::NoDot|ctkPathLineEdit::NoDotDot|ctkPathLineEdit::Readable - + + + false + Import Models @@ -333,11 +343,11 @@ - + true - + Default Subdirectories @@ -420,7 +430,7 @@ - false + true @@ -478,253 +488,254 @@ false - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - or enter : - - - - - - - true - - - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - Flip X - - - false - - - - - - - Flip Z - - - - - - - 999999999 - - - 1760 - - - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - Render Resolution: (width,height) - - - - - - - Voxel Size: - - - - - - - Generate Config File - - - - - - - 1.000000000000000 - - - - - - - Optimization Offsets: - - - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - .cfg - - - - - - - 999999999 - - - 1760 - - - - - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - Populate PV List From Volume Subdirectory - - - - - - - Volume Flip: - - - - - - - Flip Y - - - false - - - - - - - 1.000000000000000 - - - - - - - 1.000000000000000 - - - - - - - - - - Select Partial Volumes + + + + + + + true + + + Select Trial Names: +(from Radiograph Subfolders) + + + + + + + Populate from Radiographs Subdirectory + + + + + + + + + + and enter : + + + + + + + true + + + + + + + .cfg + + + + + + + Select Partial Volumes from List to add to .cfg - - - - - - - Select Camera Calibrations: - - - - - - - .cfg - - - - - - - true - - - Select Trial Names: - (from Radiograph Subfolders) - - + + + + + + + Populate From Volume Subdirectory + + + + + + + + + + Select Camera Calibrations: + + + + + + + Populate From Camera Subdirectory + + + + + + + - - - Populate Trial Name List from Radiographs - - - - - - - Populate Camera Calibrations - - - - - - - - + + + + + Optimization Offsets: + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + Volume Flip: + + + + + + + Flip X + + + false + + + + + + + Flip Y + + + false + + + + + + + Flip Z + + + + + + + Render Resolution: (width,height) + + + + + + + 999999999 + + + 1760 + + + + + + + 999999999 + + + 1760 + + + + + + + Voxel Size: + + + + + + + 1.000000000000000 + + + + + + + 1.000000000000000 + + + + + + + 1.000000000000000 + + + + + + + Generate Config File + + + + @@ -766,12 +777,6 @@
ctkCollapsibleButton.h
1 - - ctkCollapsibleGroupBox - QGroupBox -
ctkCollapsibleGroupBox.h
- 1 -
ctkPathLineEdit QWidget @@ -860,5 +865,85 @@ + + segGen_fileRadioButton + toggled(bool) + importModelsButton + setEnabled(bool) + + + 122 + 276 + + + 698 + 204 + + + + + segGen_autoRadioButton + toggled(bool) + segmentationButton + setEnabled(bool) + + + 122 + 189 + + + 698 + 276 + + + + + segGen_fileRadioButton + toggled(bool) + segSTLModelsDirLabel + setEnabled(bool) + + + 122 + 276 + + + 279 + 276 + + + + + segGen_autoRadioButton + toggled(bool) + segThresholdLabel + setEnabled(bool) + + + 122 + 189 + + + 279 + 189 + + + + + segGen_autoRadioButton + toggled(bool) + segMarginSizeLabel + setEnabled(bool) + + + 122 + 189 + + + 279 + 220 + + +