Commit 3b85c0c8 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Start adding array_subtraction

parent dc318d34
......@@ -273,10 +273,11 @@ class SinoNormalization:
kinds = [
def __init__(self, kind="chebyshev", sinos_shape=None, radios_shape=None):
def __init__(self, kind="chebyshev", sinos_shape=None, radios_shape=None, normalization_array=None):
Initialize a SinoNormalization class.
......@@ -286,6 +287,8 @@ class SinoNormalization:
Normalization type. They can be the following:
- chebyshev: Each sinogram line is estimated by a Chebyshev polynomial
of degree 2. This estimation is then subtracted from the sinogram.
- subtract_array: Each sinogram is subtracted with a user-provided array.
The array can be 1D (angle-independent) and 2D (angle-dependent)
Default is "chebyshev"
sinos_shape: tuple, optional
Shape of the sinogram or sinogram stack.
......@@ -293,17 +296,24 @@ class SinoNormalization:
radios_shape: tuple, optional
Shape of the projections or projections stack.
Either this parameter or 'sinos_shape' has to be provided.
normalization_array: numpy.ndarray, optional
Normalization array when kind='subtract_array'.
self._get_shapes(sinos_shape, radios_shape)
self._set_kind(kind, normalization_array)
_get_shapes = SinoBuilder._get_shapes
def _set_kind(self, kind):
def _set_kind(self, kind, normalization_array):
check_supported(kind, self.kinds, "sinogram normalization kind")
self.normalization_kind = kind
if "array" in kind and normalization_array is None:
raise ValueError(
"Expected 'normalization_array' to be provided for normalization kind='%s'" % kind
self.normalization_array = normalization_array
# Chebyshev normalization
......@@ -340,6 +350,18 @@ class SinoNormalization:
return sino
# Array subtraction
def _normalize_subtract_array(self, sino):
if sino.ndim == 2:
sino -= self.normalization_array
for i in range(sino.shape[0]):
sino[i] -= self.normalization_array
return sino
# Dispatch
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment