-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: neuronflow <[email protected]>
- Loading branch information
1 parent
4ec1221
commit dcb1ab1
Showing
8 changed files
with
98 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import os | ||
import shutil | ||
import unittest | ||
from abc import ABC, abstractmethod | ||
|
||
from auxiliary.turbopath import turbopath | ||
|
||
|
||
class RegistratorBase(unittest.TestCase): | ||
|
||
@abstractmethod | ||
def get_registrator(self): | ||
pass | ||
|
||
@abstractmethod | ||
def get_method_and_extension(self): | ||
pass | ||
|
||
def setUp(self): | ||
self.registrator = self.get_registrator() | ||
self.method_name, self.matrix_extension = self.get_method_and_extension() | ||
|
||
test_data_dir = turbopath(__file__).parent + "/test_data" | ||
input_dir = test_data_dir + "/input" | ||
self.output_dir = test_data_dir + f"/temp_output_{self.method_name}" | ||
os.makedirs(self.output_dir, exist_ok=True) | ||
|
||
self.fixed_image = input_dir + "/tcia_example_t1c.nii.gz" | ||
self.moving_image = input_dir + "/tcia_example_t1.nii.gz" | ||
|
||
self.matrix = self.output_dir + f"/{self.method_name}_matrix" | ||
self.transform_matrix = ( | ||
input_dir + f"/{self.method_name}_matrix.{self.matrix_extension}" | ||
) | ||
|
||
def tearDown(self): | ||
# Clean up created files if they exist | ||
# shutil.rmtree(self.output_dir) | ||
pass | ||
|
||
def test_register_creates_output_files(self): | ||
transformed_image = ( | ||
self.output_dir + f"/{self.method_name}_registered_image.nii.gz" | ||
) | ||
log_file = self.output_dir + f"/{self.method_name}_registration.log" | ||
|
||
self.registrator.register( | ||
fixed_image_path=self.fixed_image, | ||
moving_image_path=self.moving_image, | ||
transformed_image_path=transformed_image, | ||
matrix_path=self.matrix, | ||
log_file_path=log_file, | ||
) | ||
|
||
self.assertTrue( | ||
os.path.exists(transformed_image), | ||
"transformed file was not created.", | ||
) | ||
|
||
self.assertTrue( | ||
os.path.exists(f"{self.matrix}.{self.matrix_extension}"), | ||
"matrix file was not created.", | ||
) | ||
|
||
self.assertTrue( | ||
os.path.exists(log_file), | ||
"log file was not created.", | ||
) | ||
|
||
def test_transform_creates_output_files(self): | ||
transformed_image = ( | ||
self.output_dir + f"/{self.method_name}_transformed_image.nii.gz" | ||
) | ||
log_file = self.output_dir + f"/{self.method_name}_transformation.log" | ||
|
||
print("tf m:", self.transform_matrix) | ||
self.registrator.transform( | ||
fixed_image_path=self.fixed_image, | ||
moving_image_path=self.moving_image, | ||
transformed_image_path=transformed_image, | ||
matrix_path=self.transform_matrix, | ||
log_file_path=log_file, | ||
) | ||
|
||
self.assertTrue( | ||
os.path.exists(transformed_image), | ||
"transformed file was not created.", | ||
) | ||
|
||
self.assertTrue( | ||
os.path.exists(log_file), | ||
"log file was not created.", | ||
) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0.9888756 0.1354215 0.06153017 -1.314461 | ||
-0.1397797 0.9874795 0.07311541 -1.147088 | ||
-0.05085838 -0.08090271 0.9954236 2.731441 | ||
0 0 0 1 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters