Skip to content

Commit 2d6d0d6

Browse files
committed
Add Codes for Tutorial 02. Interact, Debug & Pipeline
1 parent 286a120 commit 2d6d0d6

File tree

12 files changed

+777
-1
lines changed

12 files changed

+777
-1
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Large Figures' Folder (all saved on GoogleDrive)
2+
_Figures/
3+
4+
5+
6+
# PyCharm Files
7+
.idea/
8+
9+
110
# Byte-compiled / optimized / DLL files
211
__pycache__/
312
*.py[cod]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.16.3...3.19.7 FATAL_ERROR)
2+
3+
project(SL_Tutorials)
4+
5+
#-----------------------------------------------------------------------------
6+
# Extension meta-information
7+
set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/SL_Tutorials")
8+
set(EXTENSION_CATEGORY "Tutorials")
9+
set(EXTENSION_CONTRIBUTORS "Sen Li (ETS)")
10+
set(EXTENSION_DESCRIPTION "This is an example of a simple extension")
11+
set(EXTENSION_ICONURL "https://www.example.com/Slicer/Extensions/SL_Tutorials.png")
12+
set(EXTENSION_SCREENSHOTURLS "https://www.example.com/Slicer/Extensions/SL_Tutorials/Screenshots/1.png")
13+
set(EXTENSION_DEPENDS "NA") # Specified as a list or "NA" if no dependencies
14+
15+
#-----------------------------------------------------------------------------
16+
# Extension dependencies
17+
find_package(Slicer REQUIRED)
18+
include(${Slicer_USE_FILE})
19+
20+
#-----------------------------------------------------------------------------
21+
# Extension modules
22+
add_subdirectory(t_ApplyThreshold)
23+
## NEXT_MODULE
24+
25+
#-----------------------------------------------------------------------------
26+
include(${Slicer_EXTENSION_GENERATE_CONFIG})
27+
include(${Slicer_EXTENSION_CPACK})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## <a href="/README.md" style="text-decoration:none">Step 02: Interact, Debug & Pipeline</a>
2+
3+
<img src="/SL__Summary.png" alt="isolated" width="800"/>
17.4 KB
Loading
815 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#-----------------------------------------------------------------------------
2+
set(MODULE_NAME t_ApplyThreshold)
3+
4+
#-----------------------------------------------------------------------------
5+
set(MODULE_PYTHON_SCRIPTS
6+
${MODULE_NAME}.py
7+
)
8+
9+
set(MODULE_PYTHON_RESOURCES
10+
Resources/Icons/${MODULE_NAME}.png
11+
Resources/UI/${MODULE_NAME}.ui
12+
)
13+
14+
#-----------------------------------------------------------------------------
15+
slicerMacroBuildScriptedModule(
16+
NAME ${MODULE_NAME}
17+
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
18+
RESOURCES ${MODULE_PYTHON_RESOURCES}
19+
WITH_GENERIC_TESTS
20+
)
21+
22+
#-----------------------------------------------------------------------------
23+
if(BUILD_TESTING)
24+
25+
# Register the unittest subclass in the main script as a ctest.
26+
# Note that the test will also be available at runtime.
27+
slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py)
28+
29+
# Additional build-time testing
30+
add_subdirectory(Testing)
31+
endif()
Loading
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>t_ApplyThreshold</class>
4+
<widget class="qMRMLWidget" name="t_ApplyThreshold">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>279</width>
10+
<height>286</height>
11+
</rect>
12+
</property>
13+
<layout class="QVBoxLayout" name="verticalLayout">
14+
<item>
15+
<widget class="ctkCollapsibleButton" name="inputsCollapsibleButton">
16+
<property name="text">
17+
<string>Inputs</string>
18+
</property>
19+
<layout class="QFormLayout" name="formLayout_2">
20+
<item row="0" column="0">
21+
<widget class="QLabel" name="label">
22+
<property name="text">
23+
<string>Input volume:</string>
24+
</property>
25+
</widget>
26+
</item>
27+
<item row="0" column="1">
28+
<widget class="qMRMLNodeComboBox" name="inputSelector">
29+
<property name="toolTip">
30+
<string>Pick the input to the algorithm.</string>
31+
</property>
32+
<property name="nodeTypes">
33+
<stringlist>
34+
<string>vtkMRMLScalarVolumeNode</string>
35+
</stringlist>
36+
</property>
37+
<property name="showChildNodeTypes">
38+
<bool>false</bool>
39+
</property>
40+
<property name="addEnabled">
41+
<bool>false</bool>
42+
</property>
43+
<property name="removeEnabled">
44+
<bool>false</bool>
45+
</property>
46+
</widget>
47+
</item>
48+
<item row="2" column="0">
49+
<widget class="QLabel" name="label_3">
50+
<property name="text">
51+
<string>Image threshold:</string>
52+
</property>
53+
</widget>
54+
</item>
55+
<item row="2" column="1">
56+
<widget class="ctkSliderWidget" name="imageThresholdSliderWidget">
57+
<property name="toolTip">
58+
<string>Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero.</string>
59+
</property>
60+
<property name="singleStep">
61+
<double>0.100000000000000</double>
62+
</property>
63+
<property name="minimum">
64+
<double>-100.000000000000000</double>
65+
</property>
66+
<property name="maximum">
67+
<double>500.000000000000000</double>
68+
</property>
69+
<property name="value">
70+
<double>0.500000000000000</double>
71+
</property>
72+
</widget>
73+
</item>
74+
</layout>
75+
</widget>
76+
</item>
77+
<item>
78+
<widget class="ctkCollapsibleButton" name="outputsCollapsibleButton">
79+
<property name="text">
80+
<string>Outputs</string>
81+
</property>
82+
<layout class="QFormLayout" name="formLayout_4">
83+
<item row="0" column="0">
84+
<widget class="QLabel" name="label_2">
85+
<property name="text">
86+
<string>Thresholded volume:</string>
87+
</property>
88+
</widget>
89+
</item>
90+
<item row="0" column="1">
91+
<widget class="qMRMLNodeComboBox" name="outputSelector">
92+
<property name="toolTip">
93+
<string>Pick the output to the algorithm.</string>
94+
</property>
95+
<property name="nodeTypes">
96+
<stringlist>
97+
<string>vtkMRMLScalarVolumeNode</string>
98+
</stringlist>
99+
</property>
100+
<property name="showChildNodeTypes">
101+
<bool>false</bool>
102+
</property>
103+
<property name="noneEnabled">
104+
<bool>true</bool>
105+
</property>
106+
<property name="addEnabled">
107+
<bool>true</bool>
108+
</property>
109+
<property name="removeEnabled">
110+
<bool>true</bool>
111+
</property>
112+
</widget>
113+
</item>
114+
<item row="1" column="0">
115+
<widget class="QLabel" name="label_5">
116+
<property name="text">
117+
<string>Inverted volume:</string>
118+
</property>
119+
</widget>
120+
</item>
121+
<item row="1" column="1">
122+
<widget class="qMRMLNodeComboBox" name="invertedOutputSelector">
123+
<property name="toolTip">
124+
<string>Result with inverted threshold will be written into this volume</string>
125+
</property>
126+
<property name="nodeTypes">
127+
<stringlist>
128+
<string>vtkMRMLScalarVolumeNode</string>
129+
</stringlist>
130+
</property>
131+
<property name="showChildNodeTypes">
132+
<bool>false</bool>
133+
</property>
134+
<property name="noneEnabled">
135+
<bool>true</bool>
136+
</property>
137+
<property name="addEnabled">
138+
<bool>true</bool>
139+
</property>
140+
<property name="removeEnabled">
141+
<bool>true</bool>
142+
</property>
143+
</widget>
144+
</item>
145+
</layout>
146+
</widget>
147+
</item>
148+
<item>
149+
<widget class="ctkCollapsibleButton" name="advancedCollapsibleButton">
150+
<property name="text">
151+
<string>Advanced</string>
152+
</property>
153+
<property name="collapsed">
154+
<bool>true</bool>
155+
</property>
156+
<layout class="QFormLayout" name="formLayout_3">
157+
<item row="0" column="0">
158+
<widget class="QLabel" name="label_4">
159+
<property name="text">
160+
<string>Invert threshold: </string>
161+
</property>
162+
</widget>
163+
</item>
164+
<item row="0" column="1">
165+
<widget class="QCheckBox" name="invertOutputCheckBox">
166+
<property name="toolTip">
167+
<string>If checked, values above threshold are set to 0. If unchecked, values below are set to 0.</string>
168+
</property>
169+
<property name="text">
170+
<string/>
171+
</property>
172+
</widget>
173+
</item>
174+
</layout>
175+
</widget>
176+
</item>
177+
<item>
178+
<widget class="QPushButton" name="applyButton">
179+
<property name="enabled">
180+
<bool>false</bool>
181+
</property>
182+
<property name="toolTip">
183+
<string>Run the algorithm.</string>
184+
</property>
185+
<property name="text">
186+
<string>Apply</string>
187+
</property>
188+
</widget>
189+
</item>
190+
<item>
191+
<spacer name="verticalSpacer">
192+
<property name="orientation">
193+
<enum>Qt::Vertical</enum>
194+
</property>
195+
<property name="sizeHint" stdset="0">
196+
<size>
197+
<width>20</width>
198+
<height>40</height>
199+
</size>
200+
</property>
201+
</spacer>
202+
</item>
203+
</layout>
204+
</widget>
205+
<customwidgets>
206+
<customwidget>
207+
<class>ctkCollapsibleButton</class>
208+
<extends>QWidget</extends>
209+
<header>ctkCollapsibleButton.h</header>
210+
<container>1</container>
211+
</customwidget>
212+
<customwidget>
213+
<class>ctkSliderWidget</class>
214+
<extends>QWidget</extends>
215+
<header>ctkSliderWidget.h</header>
216+
</customwidget>
217+
<customwidget>
218+
<class>qMRMLNodeComboBox</class>
219+
<extends>QWidget</extends>
220+
<header>qMRMLNodeComboBox.h</header>
221+
</customwidget>
222+
<customwidget>
223+
<class>qMRMLWidget</class>
224+
<extends>QWidget</extends>
225+
<header>qMRMLWidget.h</header>
226+
<container>1</container>
227+
</customwidget>
228+
</customwidgets>
229+
<resources/>
230+
<connections>
231+
<connection>
232+
<sender>t_ApplyThreshold</sender>
233+
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
234+
<receiver>inputSelector</receiver>
235+
<slot>setMRMLScene(vtkMRMLScene*)</slot>
236+
<hints>
237+
<hint type="sourcelabel">
238+
<x>122</x>
239+
<y>132</y>
240+
</hint>
241+
<hint type="destinationlabel">
242+
<x>248</x>
243+
<y>61</y>
244+
</hint>
245+
</hints>
246+
</connection>
247+
<connection>
248+
<sender>t_ApplyThreshold</sender>
249+
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
250+
<receiver>outputSelector</receiver>
251+
<slot>setMRMLScene(vtkMRMLScene*)</slot>
252+
<hints>
253+
<hint type="sourcelabel">
254+
<x>82</x>
255+
<y>135</y>
256+
</hint>
257+
<hint type="destinationlabel">
258+
<x>220</x>
259+
<y>161</y>
260+
</hint>
261+
</hints>
262+
</connection>
263+
<connection>
264+
<sender>t_ApplyThreshold</sender>
265+
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
266+
<receiver>invertedOutputSelector</receiver>
267+
<slot>setMRMLScene(vtkMRMLScene*)</slot>
268+
<hints>
269+
<hint type="sourcelabel">
270+
<x>161</x>
271+
<y>8</y>
272+
</hint>
273+
<hint type="destinationlabel">
274+
<x>173</x>
275+
<y>176</y>
276+
</hint>
277+
</hints>
278+
</connection>
279+
</connections>
280+
</ui>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(Python)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
#slicer_add_python_unittest(SCRIPT ${MODULE_NAME}ModuleTest.py)

0 commit comments

Comments
 (0)