Skip to content

Commit

Permalink
move logging to methods
Browse files Browse the repository at this point in the history
Signed-off-by: neuronflow <[email protected]>
  • Loading branch information
neuronflow committed Dec 14, 2023
1 parent e49bb0a commit 0490e5e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ereg/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(
"none",
]
self.total_attempts = 5
self.log_file = None
self.transform = None
if config_file is not None:
self.update_parameters(config_file)
Expand Down Expand Up @@ -239,6 +238,7 @@ def register(
moving_image: Union[str, sitk.Image],
output_image: str,
transform_file: str = None,
log_file: str = None,
**kwargs,
) -> None:
"""
Expand All @@ -252,10 +252,10 @@ def register(
transform_file (str, optional): The transform file. Defaults to None.
"""

if self.log_file is None:
self.log_file = output_image.replace(".nii.gz", ".log")
if log_file is None:
log_file = output_image.replace(".nii.gz", ".log")
logging.basicConfig(
filename=self.log_file,
filename=log_file,
format="%(asctime)s,%(name)s,%(levelname)s,%(message)s",
datefmt="%H:%M:%S",
level=logging.DEBUG,
Expand Down Expand Up @@ -334,6 +334,7 @@ def resample_image(
moving_image: Union[str, sitk.Image],
output_image: str,
transform_file: str = None,
log_file: str = None,
**kwargs,
) -> None:
"""
Expand All @@ -350,10 +351,10 @@ def resample_image(
# check if output image exists
if not os.path.exists(output_image):
if self.transform is not None:
if self.log_file is None:
self.log_file = output_image.replace(".nii.gz", ".log")
if log_file is None:
log_file = output_image.replace(".nii.gz", ".log")
logging.basicConfig(
filename=self.log_file,
filename=log_file,
format="%(asctime)s,%(name)s,%(levelname)s,%(message)s",
datefmt="%H:%M:%S",
level=logging.DEBUG,
Expand Down Expand Up @@ -867,6 +868,7 @@ def registration_function(
output_image: str,
config_file: str,
transform_file: str = None,
log_file: str = None,
**kwargs,
) -> float:
"""
Expand Down Expand Up @@ -895,6 +897,7 @@ def registration_function(
moving_image=moving_image,
output_image=output_image,
transform_file=transform_file,
log_file=log_file,
**kwargs,
)
return registration_obj.ssim_score

0 comments on commit 0490e5e

Please sign in to comment.