Skip to content

Commit

Permalink
Change testing to diagnose elastix problems
Browse files Browse the repository at this point in the history
tests aren't in logical order now but should be faster to diagnose errors. Need to revert test order to previous order after testing.
  • Loading branch information
MarkGardnerUSyd committed Aug 16, 2024
1 parent 519c022 commit 9c4d26f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CBCTCardiacSegmentation/Registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, RegOutputDir='', ParamDir='', RigidParamFile='', NonRigidPara

if platform.system() == 'Linux':
assert not(not ElastixDir),'Directory to elastix bin/lib files needs to be added for linux'
assert Path(os.path.join(ElastixDir,'bin','elastix')).exists(), 'Elastix Cannot be found at {}'.format(os.path.join(ElastixDir,'bin','elastix.exe'))
assert Path(os.path.join(ElastixDir,'bin','elastix')).exists(), 'Elastix Cannot be found at {}'.format(os.path.join(ElastixDir,'bin','elastix'))

self.ElastixDir = ElastixDir

Expand Down
15 changes: 11 additions & 4 deletions tests/test_CBCT_Segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import os
import glob
import subprocess
from pathlib import Path
import sys
Expand All @@ -28,7 +29,7 @@
from CBCTCardiacSegmentation.CreateCBCTSegmentations import CreateCBCTSegmentations
from CBCTCardiacSegmentation.SegUtil import DoDicomProcessing
from CBCTCardiacSegmentation.DicomHelper import WriteDicomStructs

"""
def test_DicomProcessing():
# Download the test data
data_path = get_lung_dicom()
Expand Down Expand Up @@ -113,7 +114,7 @@ def test_BadSegMethodInput():
rmtree(data_path)
rmtree(OutputDir)

"""
def test_NiftiCBCTSegmentationGeneration():

# Download the test data
Expand All @@ -123,7 +124,8 @@ def test_NiftiCBCTSegmentationGeneration():
test_pat_path = data_path.joinpath("LCTSC-Test-S1-201")
test_pat_path2 = data_path.joinpath("LCTSC-Test-S1-101")

SegmentationMethods = ['Direct','Synthetic','Transform']#,'Test']
#SegmentationMethods = ['Direct','Synthetic','Transform']#,'Test']
SegmentationMethods = ['Synthetic','Transform','Direct']#,'Test']

#Use CT images to test functionality until we can get open source CBCT images
CBCTDir = str(test_pat_path2.joinpath("IMAGES/LCTSC_TEST_S1_101_0_CT_0.nii.gz")) #Is a nifti file
Expand All @@ -135,6 +137,10 @@ def test_NiftiCBCTSegmentationGeneration():
home_dir = Path(os.path.expanduser('~')) # may have to update for github system
elastix_dir = home_dir / 'ElastixDownload' / 'elastix-5.0.1-linux'

assert Path(elastix_dir).exists(),'Elastix directory {} does not exist'.format(elastix_dir)

print(glob.glob(os.path.join(elastix_dir,'*')))

for SegMethod in SegmentationMethods:
print(SegMethod)
OutputDir = './CBCTSegmentations'
Expand Down Expand Up @@ -193,7 +199,7 @@ def test_DicomCBCTSegmentationGeneration():
rmtree(OutputDir)
"""

"""
def test_NiftiToDicomStruct():
data_path = get_lung_dicom()
Expand All @@ -216,3 +222,4 @@ def test_NiftiToDicomStruct():
rmtree(data_path)
rmtree(OutputDir)
"""

0 comments on commit 9c4d26f

Please sign in to comment.