Skip to content

Commit

Permalink
ENH: Warn users if masks are not provided for registration and fitting
Browse files Browse the repository at this point in the history
Warn users if masks are not provided for registration and model fitting.
  • Loading branch information
jhlegarreta committed Dec 22, 2024
1 parent 6b6ba70 commit d1acb49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/nifreeze/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#
"""Base infrastructure for nifreeze's models."""

from warnings import warn

import numpy as np

from nifreeze.exceptions import ModelNotFittedError
Expand Down Expand Up @@ -93,6 +95,9 @@ def __init__(self, mask=None, **kwargs):
self._models = None # For parallel (chunked) execution

# Setup brain mask
if mask is None:
warn("No mask provided; consider using a mask to avoid issues in model optimization.")

self._mask = mask

self._datashape = None
Expand Down
4 changes: 4 additions & 0 deletions src/nifreeze/registration/ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,16 @@ def generate_command(
settings["fixed_image_masks"] = [
str(p) for p in _massage_mask_path(fixedmask_path, nlevels)
]
else:
warn("No fixed image mask provided; consider using a mask to avoid optimization issues.")

# Set moving masks if provided
if movingmask_path is not None:
settings["moving_image_masks"] = [
str(p) for p in _massage_mask_path(movingmask_path, nlevels)
]
else:
warn("No moving image mask provided; consider using a mask to avoid optimization issues.")

# Set initalizing affine if provided
if init_affine is not None:
Expand Down

0 comments on commit d1acb49

Please sign in to comment.