|
|
# Guidelines to add a new feature
|
|
|
|
|
|
This page describes how to add a feature in Nabu.
|
|
|
|
|
|
## A brief recall about Nabu classes
|
|
|
|
|
|
As explained in the [documentation](http://www.silx.org/pub/nabu/doc/processing_components.html), there are two main types of classes in Nabu when it comes to process data:
|
|
|
- "Processing" classes. These are classes implementing a feature to process data (ex. correct rings artefacts). A Processing class is first instantiated with the relevant parameters. Then, it is executed on an image (or stack of images). These classes are the building blocks of the Nabu library.
|
|
|
- "Component" classes. They are a wrapper around the former "Processing" class, ensuring that user options are passed correctly, and memory is efficiently used. These classes are the building blocks of a Nabu application.
|
|
|
|
|
|
## Guidelines to add a new feature
|
|
|
|
|
|
### Processing class
|
|
|
|
|
|
* The feature should be put in the proper nabu module (`preproc`, `reconstruction`, `misc`, ...).
|
|
|
* It must be implemented as a class, possibly inheriting from a base class like `CCDProcessing` or `SinoProcessing`.
|
|
|
* The initialization should only setup parameters for the underlying processing.
|
|
|
* As a general rule, **the initialization should avoid allocating memory** when possible. Allocating several images and 2D FFT plans is fine. 3D data volumes, likely to be "big", should be created only as a last resort - see for example the mechanism of `nabu.cuda.processing.CudaProcessing`.
|
|
|
* The class is then executed on data satisfying the initialization parameters (shape, dtype, etc).
|
|
|
|
|
|
### Unit tests
|
|
|
|
|
|
Each processing feature should come with a unit test. Unit tests are located in the same module as the processing feature. For example, unit tests for pre-processing are in `nabu.preproc.tests`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
Let us take the example of the feature "Correct the rings artefacts on the sinogram".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|