Skip to content

Commit c41750f

Browse files
committed
UI changes, added 2D image option (disable promptpoints sync)
1 parent c921e69 commit c41750f

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

samm-python-terminal/sam_server.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
"""
2+
MIT License
3+
Copyright (c) 2023 Yihao Liu
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.
19+
"""
20+
121
from segment_anything import sam_model_registry, SamPredictor
222
from PIL import Image
323
import numpy as np

samm/SammBase/Resources/UI/SammBase.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,21 @@
101101
</size>
102102
</property>
103103
<property name="text">
104-
<string>Work Space Config:</string>
104+
<string>Work Space Config</string>
105105
</property>
106106
</widget>
107107
</item>
108108
<item row="2" column="0" colspan="3">
109109
<widget class="QLabel" name="label_7">
110110
<property name="text">
111-
<string>Data Type:</string>
111+
<string>Data Type</string>
112112
</property>
113113
</widget>
114114
</item>
115115
<item row="0" column="0" colspan="3">
116116
<widget class="QLabel" name="label_6">
117117
<property name="text">
118-
<string>Work on:</string>
118+
<string>Work on</string>
119119
</property>
120120
</widget>
121121
</item>
@@ -161,7 +161,7 @@
161161
</size>
162162
</property>
163163
<property name="text">
164-
<string>Volume Data</string>
164+
<string>Data</string>
165165
</property>
166166
</widget>
167167
</item>

samm/SammBase/SammBaseLib/LogicSamm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MIT License
3-
Copyright (c) 2022 [Insert copyright holders]
3+
Copyright (c) 2023 Yihao Liu
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights
@@ -66,6 +66,8 @@ def setDefaultParameters(self, parameterNode):
6666
"""
6767
Initialize parameter node with default settings.
6868
"""
69+
if not parameterNode.GetParameter("sammDataOptions"):
70+
parameterNode.SetParameter("sammDataOptions", "Volume")
6971

7072
def processGetVolumeMetaData(self, imageDataShape):
7173
"""

samm/SammBase/SammBaseLib/UtilConnections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MIT License
3-
Copyright (c) 2022 [Insert copyright holders]
3+
Copyright (c) 2023 Yihao Liu
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights

samm/SammBase/SammBaseLib/UtilSlicerFuncs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MIT License
3-
Copyright (c) 2022 Yihao Liu
3+
Copyright (c) 2023 Yihao Liu
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights

samm/SammBase/SammBaseLib/WidgetSamm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MIT License
3-
Copyright (c) 2022 [Insert copyright holders]
3+
Copyright (c) 2023 Yihao Liu
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights

samm/SammBase/SammBaseLib/WidgetSammBase.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MIT License
3-
Copyright (c) 2022 [Insert copyright holders]
3+
Copyright (c) 2023 Yihao Liu
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights
@@ -39,11 +39,16 @@ def setup(self):
3939
self.addObserver(slicer.mrmlScene, slicer.mrmlScene.EndCloseEvent, self.onSceneEndClose)
4040

4141
# UI
42+
43+
self.ui.radioDataVolume.connect("toggled(bool)", self.onRadioDataOptions)
44+
self.ui.radioData2D.connect("toggled(bool)", self.onRadioDataOptions)
45+
4246
self.ui.pushComputePredictor.connect('clicked(bool)', self.onPushComputePredictor)
4347
self.ui.pushStartMaskSync.connect('clicked(bool)', self.onPushStartMaskSync)
4448
self.ui.pushStopMaskSync.connect('clicked(bool)', self.onPushStopMaskSync)
4549
self.ui.pushFreezeSlice.connect('clicked(bool)', self.onPushFreezeSlice)
4650
self.ui.pushUnfreezeSlice.connect('clicked(bool)', self.onPushUnfreezeSlice)
51+
4752
self.ui.comboVolumeNode.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGUI)
4853
self.ui.markupsAdd.connect("markupsNodeChanged()", self.updateParameterNodeFromGUI)
4954
self.ui.markupsRemove.connect("markupsNodeChanged()", self.updateParameterNodeFromGUI)
@@ -100,6 +105,12 @@ def updateParameterNodeFromGUI(self, caller=None, event=None):
100105

101106
self._parameterNode.EndModify(wasModified)
102107

108+
def onRadioDataOptions(self):
109+
if self.ui.radioDataVolume.checked:
110+
self._parameterNode.SetParameter("sammDataOptions", "Volume")
111+
if self.ui.radioData2D.checked:
112+
self._parameterNode.SetParameter("sammDataOptions", "2D")
113+
103114
def onPushComputePredictor(self):
104115
self.logic.processComputePredictor()
105116

@@ -110,8 +121,9 @@ def onPushStartMaskSync(self):
110121
self.logic._flag_mask_sync = True
111122
self.logic.processInitMaskSync()
112123
self.logic.processStartMaskSync()
113-
self.logic._flag_promptpts_sync = True
114-
self.logic.processPromptPointsSync()
124+
if self._parameterNode.GetParameter("sammDataOptions") == "Volume":
125+
self.logic._flag_promptpts_sync = True
126+
self.logic.processPromptPointsSync()
115127

116128
def onPushStopMaskSync(self):
117129
self.logic._flag_promptpts_sync = False

0 commit comments

Comments
 (0)