Skip to content

Commit

Permalink
handle missing suffixes
Browse files Browse the repository at this point in the history
Signed-off-by: neuronflow <[email protected]>
  • Loading branch information
neuronflow committed Apr 1, 2024
1 parent 0fbca21 commit 5c26c87
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions brainles_preprocessing/registration/eReg/eReg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# TODO add typing and docs
import os

from ereg.registration import RegistrationClass

from brainles_preprocessing.registration.registrator import Registrator
Expand Down Expand Up @@ -38,6 +40,8 @@ def register(
configuration_file=self.configuration_file,
)

matrix_path = _add_txt_suffix(matrix_path)

registrator.register(
target_image=fixed_image_path,
moving_image=moving_image_path,
Expand Down Expand Up @@ -69,10 +73,28 @@ def transform(
configuration_file=self.configuration_file,
)

matrix_path = _add_txt_suffix(matrix_path)

registrator.resample_image(
target_image=fixed_image_path,
moving_image=moving_image_path,
output_image=transformed_image_path,
transform_file=matrix_path,
log_file=log_file_path,
)


def _add_txt_suffix(filename: str) -> str:
"""
Adds a ".txt" suffix to the filename if it doesn't have any extension.
Parameters:
filename (str): The filename to check and potentially modify.
Returns:
str: The filename with ".txt" suffix added if needed.
"""
base, ext = os.path.splitext(filename)
if not ext:
filename += ".txt"
return filename

0 comments on commit 5c26c87

Please sign in to comment.