mr2.operators.functionals.NCC
- class mr2.operators.functionals.NCC[source]
Bases:
Operator[Tensor,tuple[Tensor]](masked) global or local normalized cross-correlation functional.
- __init__(target: Tensor, weight: Tensor | None = None, *, window_size: int | None = None, reduction: Literal['full', 'volume', 'none'] = 'full', eps: float = 1e-12) None[source]
Initialize NCC.
- Parameters:
target (
Tensor) – Target volume. At least 3D in the trailing dimensions.weight (
Tensor|None, default:None) – Optional positive weight (or boolean mask), broadcastable with target. Ifwindow_sizeis notNone, the weight is masked to only include windows that are fully inside the mask.window_size (
int|None, default:None) – IfNone, compute global NCC over the last three dimensions. If integer, compute local NCC with rectangular sliding windows.reduction (
Literal['full','volume','none'], default:'full') – Iffull, return scalar mean over volumes. Ifvolume, return one value per volume. Ifnone, return local NCC map for local mode or per-volume values for global mode.eps (
float, default:1e-12) – Small positive constant for numerical stability.
- forward(x: Tensor) tuple[Tensor][source]
Apply forward of NCC.
Note
Prefer calling the instance as
operator(x)over directly calling this method.
- __add__(other: Operator[Unpack[Tin], Tout]) Operator[Unpack[Tin], Tout][source]
- __add__(other: Tensor | complex) Operator[Unpack[Tin], tuple[Unpack[Tin]]]
Operator addition.
Returns
lambda x: self(x) + other(x)if other is a operator,lambda x: self(x) + other*xif other is a tensor
- __matmul__(other: Operator[Unpack[Tin2], tuple[Unpack[Tin]]] | Operator[Unpack[Tin2], tuple[Tensor, ...]]) Operator[Unpack[Tin2], Tout][source]
Operator composition.
Returns
lambda x: self(other(x))
- __mul__(other: Tensor | complex) Operator[Unpack[Tin], Tout][source]
Operator multiplication with tensor.
Returns
lambda x: self(x*other)