Skip to content

Boundary conditions

bound_condition_maker(mask)

Assigns boundary conditions to a binary mask and returns a 4D array representing the boundary condition at each voxel in three orthogonal directions.

This function processes a 3D binary mask, calculating boundary conditions for each voxel. Boundary conditions can be INTERIOR, FORWARD, BACKWARD, or NONE, depending on the presence of neighboring voxels.

Parameters:

Name Type Description Default
mask Image3D

A binary mask where non-zero values represent the region of interest.

required

Returns:

Name Type Description
Image3D Image3D

A 4D array (same spatial dimensions as mask, with an additional axis for the X, Y, and Z directions) containing boundary condition values for each voxel and direction.

bound_condition_maker_inner(mask, padded_mask)

Core implementation for computing boundary conditions.

This function iterates over all non-zero voxels in the mask and determines the boundary condition for each voxel in the X, Y, and Z directions.

Parameters:

Name Type Description Default
mask ndarray

A 3D binary mask.

required
padded_mask ndarray

The same mask padded by one voxel in each dimension, to simplify boundary condition calculations.

required

Returns:

Type Description
ndarray

np.ndarray: A 4D array of the same spatial dimensions as mask, with an additional axis for boundary conditions in three directions.

check_neighbors(mask, x, y, z, direction)

Checks the neighbors of a voxel in a specific direction and determines its boundary condition.

Parameters:

Name Type Description Default
mask ndarray

A binary mask (3D array).

required
x int

X-coordinate of the voxel.

required
y int

Y-coordinate of the voxel.

required
z int

Z-coordinate of the voxel.

required
direction Direction

The direction to check (X, Y, or Z).

required

Returns:

Name Type Description
int int

The boundary condition value (e.g., Boundary.INTERIOR.value, Boundary.FORWARD.value, Boundary.BACKWARD.value, or Boundary.NONE.value).