  Objective: In medical imaging, it is often crucial to accurately assess and
correct movement during image-guided therapy. Deformable image registration
(DIR) consists in estimating the required spatial transformation to align a
moving image with a fixed one. However, it is acknowledged that, boundary
conditions applied to the solution are critical in preventing mis-registration.
Despite the extensive research on registration techniques, relatively few have
addressed the issue of boundary conditions in the context of medical DIR. Our
aim is a step towards customizing boundary conditions to suit the diverse
registration tasks at hand.
  Approach: We propose a generic, locally adaptive, Robin-type condition
enabling to balance between Dirichlet and Neumann boundary conditions,
depending on incoming/outgoing flow fields on the image boundaries. The
proposed framework is entirely automatized through the determination of a
reduced set of hyperparameters optimized via energy minimization.
  Main results: The proposed approach was tested on a mono-modal CT thorax
registration task and an abdominal CT to MRI registration task. For the first
task, we observed a relative improvement in terms of target registration error
of up to 12% (mean 4%), compared to homogeneous Dirichlet and homogeneous
Neumann. For the second task, the automatic framework provides results closed
to the best achievable.
  Significance: This study underscores the importance of tailoring the
registration problem at the image boundaries. In this research, we introduce a
novel method to adapt the boundary conditions on a voxel-by-voxel basis,
yielding optimized results in two distinct tasks: mono-modal CT thorax
registration and abdominal CT to MRI registration. The proposed framework
enables optimized boundary conditions in image registration without any a
priori assumptions regarding the images or the motion.
