torchrelay.extra.bounds
Boundary conditions
There is no common convention to name boundary conditions. This file lists all possible aliases and provides tool to "convert" between them. It also defines function that can be used to implement these boundary conditions.
| NITorch | SciPy | PyTorch | Other | Description |
|---|---|---|---|---|
replicate |
border | nearest, replicate | repeat | a a | a b c d | d d |
zero |
constant(0) | constant, zero | zeros | 0 0 | a b c d | 0 0 |
dct2 |
reflect | reflection (align_corners=True) | neumann | b a | a b c d | d c |
dct1 |
mirror | reflection (align_corners=False) | c b | a b c d | c b |
|
dft |
wrap | circular | c d | a b c d | a b |
|
dst2 |
antireflect, dirichlet | -b -a | a b c d | -d -c |
||
dst1 |
antimirror | -a 0 | a b c d | 0 -d |
to_nitorch
Convert boundary type to NITorch's convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bound |
[list of] str or bound_like
|
Boundary condition in any convention |
required |
as_enum |
bool
|
Return BoundType rather than str |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bound |
[list of] str or BoundType
|
Boundary condition in NITorch's convention |
to_scipy
Convert boundary type to SciPy's convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bound |
[list of] str or bound_like
|
Boundary condition in any convention |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bound |
[list of] str
|
Boundary condition in SciPy's convention |
to_torch
Convert boundary type to PyTorch's convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bound |
[list of] str or bound_like
|
Boundary condition in any convention |
required |
Returns:
| Type | Description |
|---|---|
[list of]
|
bound : str Boundary condition in PyTorchs's convention align_corners : bool or None |
replicate
Apply replicate (nearest/border) boundary conditions to an index
Aliases
border, nearest, repeat
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
{1, 0, -1}
|
Sign of the transformation (always 1 for replicate) |
dft
Apply DFT (circulant/wrap) boundary conditions to an index
Aliases
wrap, circular
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
{1, 0, -1}
|
Sign of the transformation (always 1 for dft) |
dct2
Apply DCT-II (reflect) boundary conditions to an index
Aliases
reflect, neumann
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
{1, 0, -1}
|
Sign of the transformation (always 1 for dct2) |
dct1
Apply DCT-I (mirror) boundary conditions to an index
Aliases
mirror
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
{1, 0, -1}
|
Sign of the transformation (always 1 for dct1) |
dst1
Apply DST-I (antimirror) boundary conditions to an index
Aliases
antimirror
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
[tensor of] {1, 0, -1}
|
Sign of the transformation |
dst2
Apply DST-II (antireflect) boundary conditions to an index
Aliases
antireflect, dirichlet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i |
int or tensor
|
Index |
required |
n |
int
|
Length of the field of view |
required |
Returns:
| Name | Type | Description |
|---|---|---|
i |
int or tensor
|
Index that falls inside the field of view [0, n-1] |
s |
[tensor of] {1, 0, -1}
|
Sign of the transformation (always 1 for dct1) |