Skip to content

Commit

Permalink
combined test crashes
Browse files Browse the repository at this point in the history
Signed-off-by: neuronflow <[email protected]>
  • Loading branch information
neuronflow committed Apr 4, 2024
1 parent b162819 commit 293b68c
Showing 1 changed file with 60 additions and 3 deletions.
63 changes: 60 additions & 3 deletions unit_tests/test_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_registration_function():
transform_file=transform_file,
log_file=log_file,
)

# checks
_image_sanity_check(atlas_sri, output_image)
assert os.path.exists(transform_file), "Transform file not created."
Expand Down Expand Up @@ -132,16 +132,73 @@ def test_resample_function():
configuration=test_config,
log_file=log_file,
)

# checks
_image_sanity_check(atlas_sri, output_image)
assert os.path.exists(log_file), "Log file not created."

# cleanup
for file_to_delete in [output_image, log_file]:
os.remove(file_to_delete)


def test_registration_and_resampling_function():
cwd = Path.cwd()
test_data_dir = (cwd / "data").absolute().as_posix()
atlas_data_dir = (cwd / "atlases").absolute().as_posix()
moving_image = os.path.join(test_data_dir, "tcia_aaac_t1ce.nii.gz")
temp_output_dir = tempfile.gettempdir()
output_image = os.path.join(temp_output_dir, "tcia_aaac_t1ce_registered.nii.gz")
resample_output_image = os.path.join(
temp_output_dir, "tcia_aaac_t1ce_resampled.nii.gz"
)

atlas_sri = os.path.join(atlas_data_dir, "sri24", "image.nii.gz")
transform_file = os.path.join(temp_output_dir, "tcia_aaac_t1ce_transform.mat")
log_file = os.path.join(temp_output_dir, "tcia_aaac_t1ce_registration.log")
resample_log_file = os.path.join(
temp_output_dir, "tcia_aaac_t1ce_transformation.log"
)
test_config = {"initialization": "moments", "bias": True}

registration_function(
target_image=atlas_sri,
moving_image=moving_image,
output_image=output_image,
config_file=test_config,
transform_file=transform_file,
log_file=log_file,
)

# checks
_image_sanity_check(atlas_sri, output_image)
assert os.path.exists(transform_file), "Transform file not created."
assert os.path.exists(log_file), "Log file not created."

resample_function(
target_image=atlas_sri,
moving_image=moving_image,
output_image=output_image,
transform_file=transform_file,
configuration=test_config,
log_file=resample_log_file,
)

_image_sanity_check(atlas_sri, resample_output_image)
assert os.path.exists(transform_file), "Transform file not created."
assert os.path.exists(resample_log_file), "Log file not created."

# cleanup
for file_to_delete in [
output_image,
resample_output_image,
transform_file,
log_file,
resample_log_file,
]:
os.remove(file_to_delete)


def test_bias():
cwd = Path.cwd()
test_data_dir = (cwd / "data").absolute().as_posix()
Expand Down

0 comments on commit 293b68c

Please sign in to comment.