Skip to content

Commit 142ec75

Browse files
FIX: separate output files when choosing FDI
1 parent 9636ac3 commit 142ec75

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

CrownSegmentation/CrownSegmentation.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,18 @@ def setup(self):
211211
self.chooseFDI = self.ui.labelComboBox.currentIndex
212212
#print(self.MRMLNode.GetName())
213213

214-
215-
if qt.QSettings().value('TeethSegVisited') == None:
216-
msg = qt.QMessageBox()
217-
msg.setText(f'Welcome to this module!\n'
214+
# qt.QSettings().setValue("TeethSegVisited",None)
215+
if qt.QSettings().value('TeethSegVisited') is None:
216+
self.msg = qt.QMessageBox()
217+
self.msg.setText(f'Welcome to this module!\n'
218218
'The module works with Linux only. You also need a CUDA capable GPU.\n'
219219
'If you are running it for the first time, The installation of the dependencies will take time.\n' )
220-
msg.setWindowTitle("Welcome!")
221-
msg.exec_()
220+
self.msg.setWindowTitle("Welcome!")
221+
self.cb = qt.QCheckBox()
222+
self.cb.setText("Don't show this again")
223+
self.cb.stateChanged.connect(self.onCBchecked)
224+
self.msg.setCheckBox(self.cb)
225+
self.msg.exec_()
222226

223227

224228
# Make sure parameter node is initialized (needed for module reload)
@@ -327,6 +331,17 @@ def updateParameterNodeFromGUI(self, caller=None, event=None):
327331

328332

329333

334+
335+
336+
def onCBchecked(self):
337+
state = self.cb.checkState()
338+
if state==0:
339+
qt.QSettings().setValue("TeethSegVisited",None)
340+
else:
341+
qt.QSettings().setValue("TeethSegVisited",1)
342+
343+
344+
330345
###
331346
### INPUTS
332347
###

CrownSegmentationcli/CrownSegmentationcli.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ def InstallDependencies():
2222
pip_install('fvcore==0.1.5.post20220504')
2323
pip_install('iopath==0.1.9')
2424
if system == "Linux":
25-
# pip_install('--force-reinstall --no-deps --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py39_cu113_pyt1120/download.html') # pytorch3d
26-
27-
code_path = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/'))
28-
print(code_path)
29-
pip_install(f'{code_path}/_CrownSegmentationcli/pytorch3d-0.7.0-cp39-cp39-linux_x86_64.whl') # py39_cu113_pyt1120
25+
try:
26+
code_path = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/'))
27+
print(code_path)
28+
pip_install(f'{code_path}/_CrownSegmentationcli/pytorch3d-0.7.0-cp39-cp39-linux_x86_64.whl') # py39_cu113_pyt1120
29+
except:
30+
pip_install('--force-reinstall --no-deps --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py39_cu113_pyt1120/download.html')
31+
3032
else:
31-
pip_install("--force-reinstall git+https://github.com/facebookresearch/pytorch3d.git")
33+
raise Exception('Module only works with Linux systems.')
34+
# pip_install("--force-reinstall git+https://github.com/facebookresearch/pytorch3d.git")
3235

3336
if sys.argv[1] == '-1':
3437
InstallDependencies()
@@ -265,21 +268,24 @@ def main(surf,out,rot,res,unet_model,scal,sepOutputs,chooseFDI,log_path):
265268

266269
if chooseFDI:
267270
surf = ConvertFDI(surf,scal)
268-
271+
gum_label = 0
272+
else:
273+
gum_label = 33
274+
269275
if sepOutputs:
270276
# Isolate each label
271277
surf_point_data = surf.GetPointData().GetScalars(scal)
272278
labels = np.unique(surf_point_data)
273279
out_basename = output[:-4]
274280
for label in tqdm(labels, desc = 'Isolating labels'):
275281
thresh_label = post_process.Threshold(surf, scal ,label-0.5,label+0.5)
276-
if label != 33:
282+
if label != gum_label:
277283
utils.Write(thresh_label,f'{out_basename}_id_{label}.vtk',print_out=False)
278284
else:
279285
# gum
280286
utils.Write(thresh_label,f'{out_basename}_gum.vtk',print_out=False)
281287
# all teeth
282-
no_gum = post_process.Threshold(surf, scal ,33-0.5,33+0.5,invert=True)
288+
no_gum = post_process.Threshold(surf, scal ,gum_label-0.5,gum_label+0.5,invert=True)
283289
utils.Write(no_gum,f'{out_basename}_all_teeth.vtk',print_out=False)
284290

285291

0 commit comments

Comments
 (0)