Skip to content

Commit

Permalink
Merge pull request #102 from GaelleLeroux/MRI2CBCT
Browse files Browse the repository at this point in the history
MRI2CBCT extension
  • Loading branch information
allemangD authored Jul 24, 2024
2 parents 6b331d1 + 9595031 commit 92abed9
Show file tree
Hide file tree
Showing 34 changed files with 4,147 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ASO_CBCT/LinearTransform_t.tfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#Insight Transform File V1.0
#Transform 0
Transform: AffineTransform_double_3_3
Parameters: 0.9763290732702393 0.15616745925611628 0.14964379491567228 -0.1421477793365056 0.9847545451025459 -0.10026213008697676 -0.16302008930489087 0.07661729941316797 0.9836433499565058 3.8520097928318386 10.915991569159537 -4.582919224464414
FixedParameters: 0 0 0
14 changes: 7 additions & 7 deletions AutoMatrix/AutoMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def ProcessVolume(self)-> None:
print("not a .nii.gz")

self.UpdateTime()
if extension_scan!=".nii.gz":
if extension_scan!=".nii.gz" and extension_scan!=".nrrd":
model = slicer.util.loadModel(scan)
else :
model = slicer.util.loadVolume(scan)
Expand Down Expand Up @@ -616,7 +616,7 @@ def onProcessStarted(self)->None:
Initialize the variables and progress bar.
"""
if os.path.isdir(self.ui.LineEditPatient.text):
self.nbFiles = len(self.dico_patient[".vtk"]) + len(self.dico_patient['.vtp']) + len(self.dico_patient['.stl']) + len(self.dico_patient['.off']) + len(self.dico_patient['.obj']) + len(self.dico_patient['.nii.gz'])
self.nbFiles = len(self.dico_patient[".vtk"]) + len(self.dico_patient['.vtp']) + len(self.dico_patient['.stl']) + len(self.dico_patient['.off']) + len(self.dico_patient['.obj']) + len(self.dico_patient['.nii.gz']) + len(self.dico_patient['nrrd'])
else:
self.nbFiles = 1
self.ui.progressBar.setValue(0)
Expand Down Expand Up @@ -645,20 +645,20 @@ def CheckGoodEntre(self)->bool:
warning_text = warning_text + "Enter file patient" + "\n"
else :
if self.ui.ComboBoxPatient.currentIndex==1 : #folder option
self.dico_patient=search(self.ui.LineEditPatient.text,'.vtk','.vtp','.stl','.off','.obj','.nii.gz')
if len(self.dico_patient['.vtk'])==0 and len(self.dico_patient['.vtp']) and len(self.dico_patient['.stl']) and len(self.dico_patient['.off']) and len(self.dico_patient['.obj']) and len(self.dico_patient['.nii.gz']) :
self.dico_patient=search(self.ui.LineEditPatient.text,'.vtk','.vtp','.stl','.off','.obj','.nii.gz','nrrd')
if len(self.dico_patient['.vtk'])==0 and len(self.dico_patient['.vtp']) and len(self.dico_patient['.stl']) and len(self.dico_patient['.off']) and len(self.dico_patient['.obj']) and len(self.dico_patient['.nii.gz']) and len(self.dico_patient['.nrrd']) :
warning_text = warning_text + "Folder empty or wrong type of file patient" + "\n"
warning_text = warning_text + "File authorized : .vtk / .vtp / .stl / .off / .obj / .nii.gz" + "\n"
warning_text = warning_text + "File authorized : .vtk / .vtp / .stl / .off / .obj / .nii.gz / .nrrd" + "\n"
elif self.ui.ComboBoxPatient.currentIndex==0 : # file option
fname, extension = os.path.splitext(os.path.basename(self.ui.LineEditPatient.text))
try :
fname, extension2 = os.path.splitext(os.path.basename(fname))
extension = extension2+extension
except :
print("not a .nii.gz")
if extension != ".vtk" and extension != ".vtp" and extension != ".stl" and extension != ".off" and extension != ".obj" and extension != ".nii.gz" :
if extension != ".vtk" and extension != ".vtp" and extension != ".stl" and extension != ".off" and extension != ".obj" and extension != ".nii.gz" and extension != ".nrrd":
warning_text = warning_text + "Wrong type of file patient detected" + "\n"
warning_text = warning_text + "File authorized : .vtk / .vtp / .stl / .off / .obj / .nii.gz" + "\n"
warning_text = warning_text + "File authorized : .vtk / .vtp / .stl / .off / .obj / .nii.gz / .nrrd" + "\n"


if self.ui.LineEditMatrix.text=="":
Expand Down
7 changes: 5 additions & 2 deletions AutoMatrix/Method/General_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def GetPatients(file_path:str,matrix_path:str):
files = []

if Path(file_path).is_dir():
files_original = search(file_path,'.vtk','.vtp','.stl','.off','.obj','.nii.gz')
files_original = search(file_path,'.vtk','.vtp','.stl','.off','.obj','.nii.gz','.nrrd')
files = []
for i in range(len(files_original['.vtk'])):
files.append(files_original['.vtk'][i])
Expand All @@ -64,6 +64,9 @@ def GetPatients(file_path:str,matrix_path:str):

for i in range(len(files_original['.nii.gz'])):
files.append(files_original['.nii.gz'][i])

for i in range(len(files_original['.nrrd'])):
files.append(files_original['.nrrd'][i])

for i in range(len(files)):
file = files[i]
Expand All @@ -87,7 +90,7 @@ def GetPatients(file_path:str,matrix_path:str):
except :
print("not a .nii.gz")

if extension ==".vtk" or extension ==".vtp" or extension ==".stl" or extension ==".off" or extension ==".obj" or extension==".nii.gz" :
if extension ==".vtk" or extension ==".vtp" or extension ==".stl" or extension ==".off" or extension ==".obj" or extension==".nii.gz" or extension==".nrrd" :
files = [file_path]
file_pat = os.path.basename(file_path).split('_Seg')[0].split('_seg')[0].split('_Scan')[0].split('_scan')[0].split('_Or')[0].split('_OR')[0].split('_MAND')[0].split('_MD')[0].split('_MAX')[0].split('_MX')[0].split('_CB')[0].split('_lm')[0].split('_T2')[0].split('_T1')[0].split('_Cl')[0].split('.')[0].replace('.','')
for i in range(50):
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ add_subdirectory(AREG)
add_subdirectory(AutoMatrix)
add_subdirectory(AutoCrop3D)

add_subdirectory(MRI2CBCT)
add_subdirectory(MRI2CBCT_CLI)
## NEXT_MODULE

#-----------------------------------------------------------------------------
Expand Down
37 changes: 37 additions & 0 deletions MRI2CBCT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#-----------------------------------------------------------------------------
set(MODULE_NAME MRI2CBCT)

#-----------------------------------------------------------------------------
set(MODULE_PYTHON_SCRIPTS
${MODULE_NAME}.py
utils/Method.py
utils/Preprocess_CBCT_MRI.py
utils/Preprocess_CBCT.py
utils/Preprocess_MRI.py
utils/Reg_MRI2CBCT.py
utils/utils_CBCT.py
)

set(MODULE_PYTHON_RESOURCES
Resources/Icons/${MODULE_NAME}.png
Resources/UI/${MODULE_NAME}.ui
)

#-----------------------------------------------------------------------------
slicerMacroBuildScriptedModule(
NAME ${MODULE_NAME}
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
RESOURCES ${MODULE_PYTHON_RESOURCES}
WITH_GENERIC_TESTS
)

#-----------------------------------------------------------------------------
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)

# Additional build-time testing
add_subdirectory(Testing)
endif()
Loading

0 comments on commit 92abed9

Please sign in to comment.