test package¶
This package is used to test the main segmentation algorithm, descending aorta segmentation, ascending aorta segmentation and sagittal segmentation.
In conftest module, you will find the configuration of pytest to pass the program parameters the the test modules.
In test_image_processing module, you will find the actual tests code.
Submodules¶
conftest module¶
- conftest.pytest_addoption(parser)¶
Add argument parser to pytest. We can pass parameters to pytest.
- conftest.pytest_generate_tests(metafunc)¶
Convert parser arguments to parameters
test_image_preprocessing module¶
- test_image_preprocessing.DSC(ref_image, test_image)¶
Calculate the Dice similarity coefficient.
- Parameters:
ref_image (numpy.ndarrays) – The reference image’s numpy ndarrays representation
test_image (numpy.ndarrays) – The test image’s numpy ndarrays representation
- Returns:
The Dice similarity coefficient of the reference and test image
- Return type:
float
- test_image_preprocessing.get_cropped_volume_image(sample)¶
Read the cropped volume from /project-repo/test/sample
- Returns:
The cropped volume sitk image
- Return type:
SITK::image
- test_image_preprocessing.mean_absolute_error(ref_image, test_image)¶
Calculate the mean absolute error between reference image and test image.
- Parameters:
ref_image (numpy.ndarrays) – The reference image’s numpy ndarrays representation
test_image (numpy.ndarrays) – The test image’s numpy ndarrays representation
- Returns:
The Dice similarity coefficient of the reference and test image
- Return type:
float
- test_image_preprocessing.mean_square_error(ref_image, test_image)¶
Calculate the mean square error between reference image and test image. This function only counts if there is a white_pixel on either reference image or test image, ignoring the black pixels
- Parameters:
ref_image (numpy.ndarrays) – The reference image’s numpy ndarrays representation
test_image (numpy.ndarrays) – The test image’s numpy ndarrays representation
- Returns:
The Dice similarity coefficient of the reference and test image
- Return type:
float
- test_image_preprocessing.print_result(ref_image, test_image)¶
Print mean square error, mean absolute error, root mean square error and Sørensen–Dice coefficient between the reference image and the test image
- Parameters:
ref_image (numpy.ndarrays) – The reference image’s numpy ndarrays representation
test_image (numpy.ndarrays) – The test image’s numpy ndarrays representation
- test_image_preprocessing.read_volume_image(sample)¶
Read the segmented descending aorta volume from /project-repo/test/sample
- Returns:
The segmented descending aorta sitk image
- Return type:
SITK::image
- test_image_preprocessing.root_mse(ref_image, test_image)¶
Calculate the root mean square error between reference image and test image.
- Parameters:
ref_image (numpy.ndarrays) – The reference image’s numpy ndarrays representation
test_image (numpy.ndarrays) – The test image’s numpy ndarrays representation
- Returns:
The Dice similarity coefficient of the reference and test image
- Return type:
float
- test_image_preprocessing.test_compare_segmentation(testCase, limit)¶
Read a test cases’ cropped volume from /project-repo/test/sample, perform descending aorta segmentation, and compare the result with the existing volume from /project-repo/test/sample.
- Parameters:
limit (float) – The limit of the test result based on the Sørensen–Dice coefficient.
testCase (str) –
The test case to run the test. The test cases are:
001-43681283
028-07323651
029-05937785
030-75962810
031-62023082
032-22429388
- Returns:
Pass the test if the Sørensen–Dice coefficient between test image and reference image is within the limit set by user.
- Return type:
Boolean