... | ... | @@ -28,14 +28,72 @@ Each processing feature should come with a unit test. |
|
|
The unit test is likely to need data. There are two options:
|
|
|
- The data can either be created (synthetic data). In this case, it must be created in a way that the result is exactly known and reproducible (see the flatfield tests)
|
|
|
- Or, the data can be "real data" (with proper permissions). It is hosted on "edna-site", and must use `nabu.testutils.get_data` (relying on `silx.resources.ExternalResources`).
|
|
|
- The unit test should use the Python module `pytest` or `unittest`.
|
|
|
|
|
|
|
|
|
### Application Component (optional)
|
|
|
|
|
|
If you wish to expose the new feature as an application component, you have to create a class inheriting from `nabu.app.component.Component`. Please refer to the API documentation.
|
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
Let us take the example of the feature "Correct the rings artefacts on the sinogram".
|
|
|
|
|
|
The rings correction method is the Fourier-Wavelets method described by Münch Et Al
|
|
|
|
|
|
```python
|
|
|
from ..thirdparty.pore3d_deringer_munch import munchetal_filter
|
|
|
|
|
|
class Deringer(SinoProcessing):
|
|
|
def __init__(self, sino_shape=None, radios_shape=None, method="munch", deringer_kwargs=None):
|
|
|
"""
|
|
|
Parameters
|
|
|
-----------
|
|
|
deringer_kwargs: dict
|
|
|
Dictionary of named options to pass to the sinogram de-striping function.
|
|
|
|
|
|
Please see the SinoProcessing documentation for other parameters
|
|
|
"""
|
|
|
super().__init__(sinos_shape=sinos_shape, radios_shape=radios_shape)
|
|
|
self._init_destriping_function(method, deringer_args, deringer_kwargs)
|
|
|
|
|
|
|
|
|
def _init_destriping_function(self, method, deringer_kwargs):
|
|
|
self.deringer_kwargs = {}
|
|
|
if deringer_kwargs is not None:
|
|
|
self.deringer_kwargs = deringer_kwargs
|
|
|
|
|
|
def _destripe_sinogram(self, sinogram):
|
|
|
return munchetal_filter(
|
|
|
sinogram,
|
|
|
*self.deringer_args,
|
|
|
**self.deringer_kwargs
|
|
|
)
|
|
|
|
|
|
|
|
|
def correct_rings(self, sinos, output=None):
|
|
|
"""
|
|
|
Correct the rings in sinogram.
|
|
|
Defaults to in-place processing !
|
|
|
|
|
|
Parameters
|
|
|
-----------
|
|
|
sino: numpy.ndarray, optional
|
|
|
Sinogram or stack of sinograms.
|
|
|
output: numpy.ndarray, optional
|
|
|
Stack of sinograms. If not provided, the correction will overwrite
|
|
|
the sinogram passed as input.
|
|
|
"""
|
|
|
if output is None:
|
|
|
output = sinos
|
|
|
if sinos.ndim == 2:
|
|
|
output[:] = self._destripe_sinogram(sinos)
|
|
|
return output
|
|
|
n_sinos = sinos.shape[0]
|
|
|
for i in range(n_sinos):
|
|
|
output[i] = self._destripe_sinogram(sinos[i])
|
|
|
return output
|
|
|
```
|
|
|
|
|
|
|
|
|
|
... | ... | |