Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Remove trailing white-spaces and fix indentation in CMakeLists.txt #62

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 40 additions & 40 deletions ALI/ALI.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def PathFromNode(node):


# "Dental" : ['LL7','LL6','LL5','LL4','LL3','LL2','LL1','LR1','LR2','LR3','LR4','LR5','LR6','LR7','UL7','UL6','UL5','UL4','UL3','UL2','UL1','UR1','UR2','UR3','UR4','UR5','UR6','UR7'] ,

# "Landmarks type" : ['CL','CB','O','DB','MB','R','RIP','OIP']


Expand Down Expand Up @@ -192,12 +192,12 @@ def __init__(self, parent=None):
self.model_folder = None

self.available_landmarks = [] # list of available landmarks to predict

self.output_folder = None # If save the output in a folder
self.goup_output_files = False

self.scan_count = 0 # number of scans in the input folder
self.landmark_cout = 0 # number of landmark to identify
self.landmark_cout = 0 # number of landmark to identify



Expand Down Expand Up @@ -312,7 +312,7 @@ def SwitchInputType(self,index):
self.lm_tab.FillTab(SURFACE_LANDMARKS)
self.ui.ExtensionLabel.setVisible(False)
self.ui.ExtensioncomboBox.setVisible(False)

else:
self.CBCT_as_input = True
self.ui.MRMLNodeComboBox.nodeTypes = ['vtkMRMLVolumeNode']
Expand All @@ -327,14 +327,14 @@ def SwitchInputType(self,index):
# print()

def SwitchInputExtension(self,index):

if index == 0: # NIFTI, NRRD, GIPL Files
self.SwitchInput(0)
self.isDCMInput = False

self.ui.label_11.setVisible(True)
self.ui.InputComboBox.setVisible(True)

if index == 1: # DICOM Files
self.SwitchInput(1)
self.ui.label_11.setVisible(False)
Expand Down Expand Up @@ -410,7 +410,7 @@ def UpdateSaveType(self,caller=None, event=None):

# self.ui.SearchSaveFolder.setEnabled(not caller)
# self.ui.SaveFolderLineEdit.setEnabled(not caller)

self.save_scan_folder = caller


Expand Down Expand Up @@ -528,7 +528,7 @@ def onPredictButton(self):
if self.model_folder == None:
qt.QMessageBox.warning(self.parent, 'Warning', 'Please select a model folder')
ready = False

if not ready:
return

Expand Down Expand Up @@ -574,7 +574,7 @@ def onPredictButton(self):
param["temp_fold"] = temp_dir

param["DCMInput"] = self.isDCMInput

else:
selected_lm_lst = self.lm_tab.GetSelected()
selected_tooth_lst = self.tooth_lm.GetSelected()
Expand Down Expand Up @@ -607,7 +607,7 @@ def onPredictButton(self):
ready = True
system = platform.system()
if system=="Windows" :

wsl = self.is_ubuntu_installed()
if wsl :
lib = self.check_lib_wsl()
Expand All @@ -616,24 +616,24 @@ def onPredictButton(self):
text = "Code can't be launch. \nWSL doen't have all the necessary libraries, please download the installer and follow the instructin here : https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/releases/download/wsl2_windows/installer_wsl2.zip\nDownloading may be blocked by Chrome, this is normal, just authorize it."
ready = False
messageBox.information(None, "Information", text)
else :
else :
messageBox = qt.QMessageBox()
text = "Code can't be launch. \nWSL is not installed, please download the installer and follow the instructin here : https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/releases/download/wsl2_windows/installer_wsl2.zip\nDownloading may be blocked by Chrome, this is normal, just authorize it."
ready = False
messageBox.information(None, "Information", text)

if ready :
script_path = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(script_path,"tempo.txt")
with open(file_path, 'a') as file:
file.write("Beginning of the process" + '\n') # Écrire le message suivi d'une nouvelle ligne

self.logic = ALILogic()
self.logic.process(param, self.CBCT_as_input)

self.processObserver = self.logic.cliNode.AddObserver('ModifiedEvent',self.onProcessUpdate)
self.onProcessStarted()


def is_ubuntu_installed(self)->bool:
'''
Expand All @@ -652,8 +652,8 @@ def check_lib_wsl(self)->bool:
'''
result1 = subprocess.run("wsl -- bash -c \"dpkg -l | grep libxrender1\"", capture_output=True, text=True)
output1 = result1.stdout.encode('utf-16-le').decode('utf-8')
clean_output1 = output1.replace('\x00', '')
clean_output1 = output1.replace('\x00', '')

result2 = subprocess.run("wsl -- bash -c \"dpkg -l | grep libgl1-mesa-glx\"", capture_output=True, text=True)
output2 = result2.stdout.encode('utf-16-le').decode('utf-8')
clean_output2 = output2.replace('\x00', '')
Expand All @@ -668,8 +668,8 @@ def onProcessStarted(self):
if system=="Windows" and not self.CBCT_as_input:
self.ui.PredScanLabel.setText(f"Beginning of the process")
self.RunningUIWindows(True)
else :

else :
self.ui.PredScanProgressBar.setMaximum(self.scan_count)
self.ui.PredScanProgressBar.setValue(0)
self.ui.PredSegProgressBar.setValue(0)
Expand All @@ -680,7 +680,7 @@ def onProcessStarted(self):
self.total_seg_progress = self.scan_count * self.landmark_cout

self.ui.PredSegProgressBar.setMaximum(self.total_seg_progress)
self.ui.PredSegLabel.setText(f"Landmarks found : 0 / {self.total_seg_progress}")
self.ui.PredSegLabel.setText(f"Landmarks found : 0 / {self.total_seg_progress}")

else:
self.ui.PredScanLabel.setText(f"Scan : 0 / {self.scan_count}")
Expand All @@ -696,7 +696,7 @@ def onProcessStarted(self):
self.total_seg_progress = len(self.tooth_lm.GetSelected()) * len(model_used)

self.ui.PredSegProgressBar.setMaximum(self.total_seg_progress)
self.ui.PredSegLabel.setText(f"Identified : 0 / {self.total_seg_progress}")
self.ui.PredSegLabel.setText(f"Identified : 0 / {self.total_seg_progress}")

self.prediction_step = 0
self.progress = 0
Expand All @@ -706,8 +706,8 @@ def onProcessStarted(self):

self.RunningUI(True)





def UpdateALICBCT(self,progress):
Expand Down Expand Up @@ -744,7 +744,7 @@ def UpdateALICBCT(self,progress):
if self.prediction_step == 2:
# self.progressBar.setValue(self.progress)
self.ui.PredSegProgressBar.setValue(self.progress)
self.ui.PredSegLabel.setText(f"Landmarks found : {self.progress} / {self.total_seg_progress}")
self.ui.PredSegLabel.setText(f"Landmarks found : {self.progress} / {self.total_seg_progress}")

self.progress += 1

Expand All @@ -756,14 +756,14 @@ def UpdateALIIOS(self,progress):
self.ui.PredScanProgressBar.setValue(self.prediction_step)
self.ui.PredScanLabel.setText(f"Scan : {self.prediction_step} / {self.scan_count}")
self.ui.PredSegProgressBar.setValue(self.progress)
self.ui.PredSegLabel.setText(f"Identified: {self.progress} / {self.total_seg_progress}")
self.ui.PredSegLabel.setText(f"Identified: {self.progress} / {self.total_seg_progress}")


if progress == 100:

self.progress += 1
self.ui.PredSegProgressBar.setValue(self.progress)
self.ui.PredSegLabel.setText(f"Identified : {self.progress} / {self.total_seg_progress}")
self.ui.PredSegLabel.setText(f"Identified : {self.progress} / {self.total_seg_progress}")



Expand Down Expand Up @@ -797,8 +797,8 @@ def onProcessUpdate(self,caller,event):
system = platform.system()
if system=="Windows" and not self.CBCT_as_input:
line = self.read_txt()
self.ui.PredScanLabel.setText(f"{line}")
self.ui.PredScanLabel.setText(f"{line}")

else:
if progress == 0:
self.updateProgessBar = False
Expand Down Expand Up @@ -832,8 +832,8 @@ def onProcessUpdate(self,caller,event):
# success

self.OnEndProcess()


def OnEndProcess(self):

script_path = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -843,7 +843,7 @@ def OnEndProcess(self):
print("File delete")
else:
print("The file doesn't exist")

print('PROCESS DONE.')
# script_path = os.path.dirname(os.path.abspath(__file__))
# file_path = os.path.join(script_path,"tempo.txt")
Expand All @@ -860,7 +860,7 @@ def OnEndProcess(self):

if not self.folder_as_input:

input_id = os.path.basename(self.input_path).split(".")[0]
input_id = os.path.basename(self.input_path).split(".")[0]

normpath = os.path.normpath("/".join([self.output_folder, '**', '']))
for img_fn in sorted(glob.iglob(normpath, recursive=True)):
Expand All @@ -884,7 +884,7 @@ def onCancel(self):


print("Cancelled")

def RunningUI(self, run = False):

self.ui.PredictionButton.setVisible(not run)
Expand All @@ -895,19 +895,19 @@ def RunningUI(self, run = False):
self.ui.PredSegLabel.setVisible(run)
self.ui.PredSegProgressBar.setVisible(run)
self.ui.TimerLabel.setVisible(run)

def RunningUIWindows(self,run=False):
self.ui.TimerLabel.setVisible(run)
self.ui.PredScanLabel.setVisible(run)


def cleanup(self):
"""
Called when the application closes and the module widget is destroyed.
"""
if self.logic.cliNode is not None:
# if self.logic.cliNode.GetStatus() & self.logic.cliNode.Running:
self.logic.cliNode.Cancel()
self.logic.cliNode.Cancel()

self.removeObservers()

Expand Down Expand Up @@ -1129,10 +1129,10 @@ def CheckBox(self, caller=None, event=None):
state = True
else:
state = False

if self.lm_status_dic[lm] != state:
self.UpdateLmSelect(lm,state)

def ToggleSelection(self):
idx = self.LM_tab_widget.currentIndex
# print(idx)
Expand Down Expand Up @@ -1188,7 +1188,7 @@ def GetSelected(self):

def SelectAll(self):
self.UpdateAll(True)

def ClearAll(self):
self.UpdateAll(False)

Expand Down Expand Up @@ -1296,7 +1296,7 @@ def process(self, parameters, ALI_CBCT = True):

# stopTime = time.time()
# logging.info('Processing completed in {0:.2f} seconds'.format(stopTime-startTime))


#
# ALITest
Expand Down
2 changes: 1 addition & 1 deletion ALI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ if(BUILD_TESTING)
# Register the unittest subclass in the main script as a ctest.
# Note that the test will also be available at runtime.
slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py)


endif()
Loading