Skip to content

Commit

Permalink
Merge pull request #55 from GaelleLeroux/main
Browse files Browse the repository at this point in the history
BUG : wrong interface cbct
  • Loading branch information
allemangD authored Dec 12, 2023
2 parents e478693 + 9c9b47d commit 8602659
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 53 deletions.
6 changes: 3 additions & 3 deletions ALI/ALI.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def onPredictButton(self):

ready = True
system = platform.system()
if system=="Windows":
if system=="Windows" :

wsl = self.is_ubuntu_installed()
if wsl :
Expand Down Expand Up @@ -665,7 +665,7 @@ def onProcessStarted(self):
self.startTime = time.time()

system = platform.system()
if system=="Windows":
if system=="Windows" and not self.CBCT_as_input:
self.ui.PredScanLabel.setText(f"Beginning of the process")
self.RunningUIWindows(True)

Expand Down Expand Up @@ -795,7 +795,7 @@ def onProcessUpdate(self,caller,event):

# print(progress)
system = platform.system()
if system=="Windows":
if system=="Windows" and not self.CBCT_as_input:
line = self.read_txt()
self.ui.PredScanLabel.setText(f"{line}")

Expand Down
1 change: 1 addition & 0 deletions ALI/tempo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Beginning of the process
9 changes: 9 additions & 0 deletions AREG_IOS/AREG_IOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def main(args):
surf_T1 = Patched(dataset[idx, "T1"], surf_T1)
# pbar.update(1)

name = os.path.basename(dataset.getUpperPath(idx, "T1"))
WriteSurf(surf_T1, args.output, name, args.suffix)

with open(args.log_path, "r+") as log_f:
log_f.write(str(1))

Expand All @@ -158,13 +161,19 @@ def main(args):

name = os.path.basename(dataset.getUpperPath(idx, "T2"))
WriteSurf(output_icp["source_Or"], args.output, name, args.suffix)


if lower:
surf_lower = dataset.getLowerSurf(idx, "T2")
surf_lower = TransformSurf(surf_lower, output_icp["matrix"])
name_lower = os.path.basename(dataset.getLowerPath(idx, "T2"))
WriteSurf(surf_lower, args.output, name_lower, args.suffix)

surf_lower = dataset.getLowerSurf(idx, "T1")
if surf_lower!=None :
name_lower = os.path.basename(dataset.getLowerPath(idx, "T1"))
WriteSurf(surf_lower, args.output, name_lower, args.suffix)

# pbar.update(1)

with open(args.log_path, "r+") as log_f:
Expand Down
Binary file modified ASO_IOS/ASO_IOS_utils/cache/source.npy
Binary file not shown.
Binary file modified ASO_IOS/ASO_IOS_utils/cache/target.npy
Binary file not shown.
73 changes: 23 additions & 50 deletions AutoMatrix/AutoMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,67 +502,39 @@ def ProcessVolume(self)-> None:
if not os.path.exists(os.path.dirname(outpath)):
os.makedirs(os.path.dirname(outpath))

if extension_scan!=".nii.gz":
self.UpdateTime()
model.SetAndObserveTransformNodeID(tform.GetID())
model.HardenTransform()
self.UpdateTime()
model.SetAndObserveTransformNodeID(tform.GetID())
model.HardenTransform()
self.UpdateTime()

original_stdin = sys.stdin
sys.stdin = DummyFile()

process = multiprocessing.Process(target=self.saveOutput, args=(model,outpath.split(extension_scan)[0]+self.ui.LineEditSuffix.text+matrix_name+extension_scan))
process.start()

while process.is_alive():
slicer.app.processEvents()
self.UpdateTime()
slicer.util.saveNode(model,outpath.split(extension_scan)[0]+self.ui.LineEditSuffix.text+matrix_name+extension_scan)

else:
self.applyBrainsResample(model,tform,outpath.split(extension_scan)[0]+self.ui.LineEditSuffix.text+matrix_name+extension_scan)
sys.stdin = original_stdin
self.UpdateTime()



except:
print("An issue occured")
except Exception as e:
print("An issue occured : ",e)
pass
self.UpdateProgressBar(False)
self.UpdateTime()
slicer.mrmlScene.RemoveNode(model)
self.UpdateTime()



def applyBrainsResample(self, inputVolumeNode, transformationNode, outputFilePath)->None:
'''
Uses the BRAINS Resample module to apply a transformation to an input volume node
and saves the result in a specified file.
'''
brainsResampleModule = slicer.modules.brainsresample
outputVolumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode")



parameters = {
'inputVolume': inputVolumeNode.GetID(),
'warpTransform': transformationNode.GetID(),
'outputVolume' : outputVolumeNode.GetID(),
'interpolationMode': 'Linear'
}
self.UpdateTime()
cliNode = slicer.cli.run(brainsResampleModule, None, parameters)
while cliNode.IsBusy():
slicer.app.processEvents() # to let the user interface available
self.UpdateTime()


original_stdin = sys.stdin
sys.stdin = DummyFile()

process = multiprocessing.Process(target=self.saveOutputVolume, args=(outputVolumeNode,outputFilePath))
process.start()

while process.is_alive():
slicer.app.processEvents()
self.UpdateTime()

sys.stdin = original_stdin

slicer.mrmlScene.RemoveNode(outputVolumeNode)
self.UpdateTime()



def saveOutputVolume(self, outputVolumeNode, outputFilePath)->None:
def saveOutput(self, outputVolumeNode, outputFilePath)->None:
"""
Saves the output volume in the specified file with the .nii.gz extension.
Expand All @@ -572,7 +544,7 @@ def saveOutputVolume(self, outputVolumeNode, outputFilePath)->None:
if not os.path.exists(os.path.dirname(outputFilePath)):
os.makedirs(os.path.dirname(outputFilePath))

slicer.util.saveNode(outputVolumeNode, outputFilePath)
slicer.util.exportNode(outputVolumeNode, outputFilePath,world=True)



Expand Down Expand Up @@ -631,7 +603,8 @@ def UpdateProgressBar(self,end:bool)->None:
self.ui.label_time.setVisible(False)
self.ui.LineEditOutput.setText("")
self.ui.LineEditPatient.setText("")
self.ui.LineEditMatrix.setText("")
if not self.ui.CheckBoxMirror.isChecked():
self.ui.LineEditMatrix.setText("")
self.ui.ComboBoxMatrix.setCurrentIndex(1)
self.ui.ComboBoxPatient.setCurrentIndex(1)

Expand Down

0 comments on commit 8602659

Please sign in to comment.