Skip to content

Commit

Permalink
FIX: separate output files when choosing FDI
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuLeclercq committed Aug 11, 2022
1 parent 9636ac3 commit 142ec75
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
27 changes: 21 additions & 6 deletions CrownSegmentation/CrownSegmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,18 @@ def setup(self):
self.chooseFDI = self.ui.labelComboBox.currentIndex
#print(self.MRMLNode.GetName())


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


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





def onCBchecked(self):
state = self.cb.checkState()
if state==0:
qt.QSettings().setValue("TeethSegVisited",None)
else:
qt.QSettings().setValue("TeethSegVisited",1)



###
### INPUTS
###
Expand Down
24 changes: 15 additions & 9 deletions CrownSegmentationcli/CrownSegmentationcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ def InstallDependencies():
pip_install('fvcore==0.1.5.post20220504')
pip_install('iopath==0.1.9')
if system == "Linux":
# 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

code_path = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/'))
print(code_path)
pip_install(f'{code_path}/_CrownSegmentationcli/pytorch3d-0.7.0-cp39-cp39-linux_x86_64.whl') # py39_cu113_pyt1120
try:
code_path = '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/'))
print(code_path)
pip_install(f'{code_path}/_CrownSegmentationcli/pytorch3d-0.7.0-cp39-cp39-linux_x86_64.whl') # py39_cu113_pyt1120
except:
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')

else:
pip_install("--force-reinstall git+https://github.com/facebookresearch/pytorch3d.git")
raise Exception('Module only works with Linux systems.')
# pip_install("--force-reinstall git+https://github.com/facebookresearch/pytorch3d.git")

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

if chooseFDI:
surf = ConvertFDI(surf,scal)

gum_label = 0
else:
gum_label = 33

if sepOutputs:
# Isolate each label
surf_point_data = surf.GetPointData().GetScalars(scal)
labels = np.unique(surf_point_data)
out_basename = output[:-4]
for label in tqdm(labels, desc = 'Isolating labels'):
thresh_label = post_process.Threshold(surf, scal ,label-0.5,label+0.5)
if label != 33:
if label != gum_label:
utils.Write(thresh_label,f'{out_basename}_id_{label}.vtk',print_out=False)
else:
# gum
utils.Write(thresh_label,f'{out_basename}_gum.vtk',print_out=False)
# all teeth
no_gum = post_process.Threshold(surf, scal ,33-0.5,33+0.5,invert=True)
no_gum = post_process.Threshold(surf, scal ,gum_label-0.5,gum_label+0.5,invert=True)
utils.Write(no_gum,f'{out_basename}_all_teeth.vtk',print_out=False)


Expand Down

0 comments on commit 142ec75

Please sign in to comment.