API References
Top Level Module
Globals
This module contains registries that store data, functions or classes. Useful for registering items within this library or libraries built on Tomo Base.
xp
module-attribute
xp = EnvironmentContext()
logger
module-attribute
logger = get_logger()
TOMOBASE_TRANSFORM_CATEGORIES
module-attribute
TOMOBASE_TRANSFORM_CATEGORIES = TransformItemDict(Image_Processing=None, Align=None, Project=None, Reconstruct=None, Deform=None, Quantification=None)
TOMOBASE_PROCESSES
module-attribute
TOMOBASE_PROCESSES = ProcessItemDict()
TOMOBASE_DATATYPES
module-attribute
TOMOBASE_DATATYPES = DataItemDict(Data=None, Image=None, Sinogram=None, Volume=None)
TOMOBASE_TILTSCHEMES
module-attribute
TOMOBASE_TILTSCHEMES = TiltSchemeItemDict()
TOMOBASE_PHANTOMS
module-attribute
TOMOBASE_PHANTOMS = PhantomItemDict()
GPUContext
Bases: Enum
Source code in tomobase/registrations/environment.py
7 8 9 | |
ItemDictNonSingleton
Source code in tomobase/registrations/base.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
ItemDict
Bases: ItemDictNonSingleton
Source code in tomobase/registrations/base.py
159 160 161 162 163 164 165 166 167 168 | |
Item
Bases: object
Source code in tomobase/registrations/base.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
Data
The Data module contains the data types supported by the Tomo Base library. Each module is registered with an id stored in TOMOBASE_DATATYPES in the global registers.
Data
Bases: ABC
Abstract base class for microscopy and tomography datasets. To implement a child of this class you must:
-
implement methods to read data from a file, these should be class methods that return an instance of the class
-
implement methods to write data to a file
-
create the class variables
_readersand_writerswhich are dictionaries that link each supported filetype to the correct reader or writer respectively, the keys should be the extensions in lowercase
| Attributes: |
|
|---|
Source code in tomobase/data/base.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
from_file
classmethod
from_file(filename: Path | None = None, **kwargs)
Read a dataset from a file
| Parameters: |
|
|---|
| Raises: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/data/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
to_file
to_file(filename: Path | None = None, **kwargs)
Save the data to a file
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in tomobase/data/base.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
layer_metadata
layer_metadata(metadata: dict = {})
Get the layer metadata in the format required for napari implementation
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/data/base.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
layer_attributes
layer_attributes(attributes: dict = {})
Get the layer attributes in the format required for napari implementation
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/data/base.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
to_data_tuple
to_data_tuple(attributes: dict = {}, metadata: dict = {})
Builds a Napari Layer Data Tuple
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/data/base.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
from_data_tuple
classmethod
from_data_tuple(layer, attributes: dict | None = None)
Create an instance of the class from a Napari layer data tuple.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/data/base.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
Image
Bases: Data
A class for single image datasets.
Supported File Formats
- .png
- .jpg
- .jpeg
- .bmp
- .tif
- .tiff
| Attributes: |
|
|---|
Source code in tomobase/data/image.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
Sinogram
Bases: Data
The sinogram is a stack of projection images, indexed using the (n, x, y) orientation.
Supported File Types
- .h5
- .mrc
- .emi
- .mat (experimental)
| Attributes: |
|
|---|
Source code in tomobase/data/sinogram.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
sort
sort(bytime: bool = False)
Sort the sinogram by angles or by time
| Parameters: |
|
|---|
Source code in tomobase/data/sinogram.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
insert
insert(img: ndarray, angle: float, time: float | None = None)
Insert a new image into the sinogram
| Parameters: |
|
|---|
Source code in tomobase/data/sinogram.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
remove
remove(index: int)
Remove an image from the sinogram
| Parameters: |
|
|---|
Source code in tomobase/data/sinogram.py
102 103 104 105 106 107 108 109 110 111 | |
Volume
Bases: Data
A 3D volume that is the result of a tomographic reconstruction.
Supported file formats
- .rec
- .tiff
| Attributes: |
|
|---|
Source code in tomobase/data/volume.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
Phantoms
The phantoms functions are functions which generate a Volume class for sample data. Registered globally to the TOMOBASE_PHANTOMS register. To register a phantom to the library use the phantom_hook function.
get_nanocage
get_nanocage()
Creates a nanocage phantom.
| Returns: |
|
|---|
Source code in tomobase/phantoms/nanocage.py
8 9 10 11 12 13 14 15 16 17 18 | |
get_nanorod
get_nanorod(dim: int = 512, length: int = 300, radius: int = 100, proportion: float = 0.5, intensity: float = 0.3)
Creates a nanorod phantom.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/phantoms/nanorod.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_nanocube
get_nanocube(size: int = 256, dim: int = 512)
Creates a nanocube phantom.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/phantoms/nanocube.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Tilt Schemes
This module contains classes used to implement a tilt scheme. Registered with TOMOBASE_TILTSCHEMES and added to the registration by using the decorator tiltscheme_hook.
TiltScheme
Bases: ABC
Base Class for a Tilt Schemes.
This class provides the basic structure and functionality for all tilt schemes.
| Attributes: |
|
|---|
Source code in tomobase/tiltschemes/tiltscheme.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
get_angle
abstractmethod
get_angle()
Get the tilt angle for the current index.
Source code in tomobase/tiltschemes/tiltscheme.py
22 23 24 25 26 27 | |
Incremental
Bases: TiltScheme
Incremental Tilt Scheme.
| Attributes: |
|
|---|
Source code in tomobase/tiltschemes/incremental.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Binary
Bases: TiltScheme
Binary Tilt Scheme Class. The purpose of this class is to calculate angles using the binary acquisition tilt scheme.
| Attributes: |
|
|---|
Source code in tomobase/tiltschemes/binary.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
GRS
Bases: TiltScheme
Golden Ratio Sequence Tilt Scheme.
| Attributes: |
|
|---|
Source code in tomobase/tiltschemes/grs.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
Hooks
phantom_hook
phantom_hook(name: str | None = None) -> Callable
A decorator used to mark a function as a phantom. The function must return a Volume class.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/hooks.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
tiltscheme_hook
tiltscheme_hook(name: str) -> Callable
A decorator used to mark a class as a tiltscheme. The class must be a child of the TiltScheme class.
:param name: the name of the tilt scheme. Should be human readable casing. :type name: str :return: the decorated class :rtype: Callable
Source code in tomobase/hooks.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
tomobase_hook_process
tomobase_hook_process(**kwargs)
A decorator used to mark a function or class as a tomography process. The function or class is either a standard function or class used to define the process or a QWidget used to attach to napari. Args: name (str): the name of the process. Should be readable casing and spaces. category (enum.TransformCategory or List[enum.TransformCategory]): the category of the process. Should be a member of the TransformCategories enum. includes (list[enum.DataModules]): a list of data types that the process can handle. Either Numpy Cupy or Torch. excludes (list[enum.DataModules]): a list of strings that define the data types that the process cannot handle. Cannot define both includes and excludes subcategories (dict(enum.TransformCategory,[list[str]])): a list of strings that define the subcategories of the process. Used when adding the process to the napari menu.
Source code in tomobase/hooks.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
Processes
rotational_misalignment
rotational_misalignment(sino: Sinogram, tilt_theta: float = 3, tilt_alpha: float = 2, backlash: float = 0.5, backlash_backwards: bool = True)
Apply a random rotational misalignment to the sinogram. Args: sino (Sinogram): The projection data tilt_theta (float): The maximum rotation angle in degrees (default: 3) tilt_alpha (float): The maximum offset in degrees (default: 2) backlash (float): The maximum backlash in degrees (default: 0.5) backlash_backwards (bool): Whether to apply the backlash backwards or forwards (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
translational_misalignment
translational_misalignment(sino: Sinogram, offset: float = 0.25)
Apply a random translational misalignment to the sinogram. Arguments: sino (Sinogram): The projection data offset (float): The maximum offset in pixels (default: 0.25)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
poisson_noise
poisson_noise(obj: Data, rescale: float = True)
Add Poisson noise to the sinogram. Args: obj (Data): The input data object rescale (float): Rescale the data to the range of the Poisson noise (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
gaussian_filter
gaussian_filter(obj: Data, gaussian_sigma: float = 1)
Add Gaussian noise to the sinogram. Args: obj (Data): The input data object gaussian_sigma (float): Standard deviation of the Gaussian noise (default: 1) inplace (bool): Whether to do the operation in-place in the input data object (Default: True) Returns: Data: The result
Source code in tomobase/processes/image_processing/misalignments.py
13 14 15 16 17 18 19 20 21 22 23 24 | |
background_subtract_median
background_subtract_median(image: Data)
Subtract the median of the sinogram from the sinogram."
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/background.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
pad_sinogram
pad_sinogram(sino: Sinogram, x: int = 0, y: int = 0)
Pad the sinogram to the specified size.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
bin
bin(obj: Data, factor: int = 2)
Bin the sinogram data by a specified factor.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
normalize
normalize(sino: Sinogram)
Normalize the sinogram data to the range [0, 1].
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
align_sinogram_xcorr
align_sinogram_xcorr(sino: Sinogram, shifts=None)
Align the projection images using cross-correlation Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) shifts (np.ndarray): A list of shifts to apply in pixels, if None is given it will be calculated (default: None) extend_return (bool): If True, the return value will be a tuple with the shifts in the second item (default: False) Returns: Sinogram: The result shifts (xp.ndarray): The shifts in pixels
Source code in tomobase/processes/alignments/translation.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
align_sinogram_center_of_mass
align_sinogram_center_of_mass(sino: Sinogram)
Align the projection images using the center of mass Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the offset in the second item (default: False) Returns: Sinogram: The result offset (xp.ndarray): The offset in pixels
Source code in tomobase/processes/alignments/translation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
weight_by_angle
weight_by_angle(sino: Sinogram)
Weight the sinogram by the angle Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the weights in the second item (default: False) Returns: Sinogram: The result weights (xp.ndarray): The weights in pixels
Source code in tomobase/processes/alignments/translation.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
align_tilt_axis_rotation
align_tilt_axis_rotation(sino: Sinogram, method: str = 'fbp', angle: float = 0.0, **kwargs)
Align the tilt axis rotation of a sinogram using reprojection
Args:
sino (Sinogram): The projection data
method (str): The reconstruction algorithm (default: 'fbp')
angle (float): A pre-calculated angle in degrees, this is useful for aligning multiple sinograms simultaneously (default: None)
angles (np.ndarray): A list of angles to try in degrees, if None is given it will use numpy.arange(-4, 5) (default: None)
inplace (bool): Whether to do the alignment in-place in the input data object (default: True)
extend_return (bool): If True, the return value will be a tuple with the angle in the second item (default: False)
kwargs (dict): Other keyword arguments are passed to reconstruct see astra reconstruct
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
align_tilt_axis_shift
align_tilt_axis_shift(sino: Sinogram, method: str = 'fbp', offsets: float = 0.0, **kwargs)
Align the tilt axis shift of a sinogram using reprojection
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
alignments
align_sinogram_xcorr
align_sinogram_xcorr(sino: Sinogram, shifts=None)
Align the projection images using cross-correlation Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) shifts (np.ndarray): A list of shifts to apply in pixels, if None is given it will be calculated (default: None) extend_return (bool): If True, the return value will be a tuple with the shifts in the second item (default: False) Returns: Sinogram: The result shifts (xp.ndarray): The shifts in pixels
Source code in tomobase/processes/alignments/translation.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
align_sinogram_center_of_mass
align_sinogram_center_of_mass(sino: Sinogram)
Align the projection images using the center of mass Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the offset in the second item (default: False) Returns: Sinogram: The result offset (xp.ndarray): The offset in pixels
Source code in tomobase/processes/alignments/translation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
weight_by_angle
weight_by_angle(sino: Sinogram)
Weight the sinogram by the angle Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the weights in the second item (default: False) Returns: Sinogram: The result weights (xp.ndarray): The weights in pixels
Source code in tomobase/processes/alignments/translation.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
align_tilt_axis_rotation
align_tilt_axis_rotation(sino: Sinogram, method: str = 'fbp', angle: float = 0.0, **kwargs)
Align the tilt axis rotation of a sinogram using reprojection
Args:
sino (Sinogram): The projection data
method (str): The reconstruction algorithm (default: 'fbp')
angle (float): A pre-calculated angle in degrees, this is useful for aligning multiple sinograms simultaneously (default: None)
angles (np.ndarray): A list of angles to try in degrees, if None is given it will use numpy.arange(-4, 5) (default: None)
inplace (bool): Whether to do the alignment in-place in the input data object (default: True)
extend_return (bool): If True, the return value will be a tuple with the angle in the second item (default: False)
kwargs (dict): Other keyword arguments are passed to reconstruct see astra reconstruct
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
align_tilt_axis_shift
align_tilt_axis_shift(sino: Sinogram, method: str = 'fbp', offsets: float = 0.0, **kwargs)
Align the tilt axis shift of a sinogram using reprojection
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
rotation
align_tilt_axis_shift
align_tilt_axis_shift(sino: Sinogram, method: str = 'fbp', offsets: float = 0.0, **kwargs)
Align the tilt axis shift of a sinogram using reprojection
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
align_tilt_axis_rotation
align_tilt_axis_rotation(sino: Sinogram, method: str = 'fbp', angle: float = 0.0, **kwargs)
Align the tilt axis rotation of a sinogram using reprojection
Args:
sino (Sinogram): The projection data
method (str): The reconstruction algorithm (default: 'fbp')
angle (float): A pre-calculated angle in degrees, this is useful for aligning multiple sinograms simultaneously (default: None)
angles (np.ndarray): A list of angles to try in degrees, if None is given it will use numpy.arange(-4, 5) (default: None)
inplace (bool): Whether to do the alignment in-place in the input data object (default: True)
extend_return (bool): If True, the return value will be a tuple with the angle in the second item (default: False)
kwargs (dict): Other keyword arguments are passed to reconstruct see astra reconstruct
| Returns: |
|
|---|
Source code in tomobase/processes/alignments/rotation.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
backlash_correct
backlash_correct(sino: Sinogram, tolerance: float = 10.0, method: str = 'bounded')
Correct the backlash of a sinogram using reprojection - Note this method is currently experimental Arguments: sino (Sinogram): The projection data tolerance (float): The maximum tolerance in degrees (default: 10.0) method (str): The optimization method to use (default: 'bounded') inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the angle in the second item (default: False) Returns: Sinogram: The result angle (float): The angle in degrees
Source code in tomobase/processes/alignments/rotation.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
translation
align_sinogram_xcorr
align_sinogram_xcorr(sino: Sinogram, shifts=None)
Align the projection images using cross-correlation Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) shifts (np.ndarray): A list of shifts to apply in pixels, if None is given it will be calculated (default: None) extend_return (bool): If True, the return value will be a tuple with the shifts in the second item (default: False) Returns: Sinogram: The result shifts (xp.ndarray): The shifts in pixels
Source code in tomobase/processes/alignments/translation.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
align_sinogram_center_of_mass
align_sinogram_center_of_mass(sino: Sinogram)
Align the projection images using the center of mass Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the offset in the second item (default: False) Returns: Sinogram: The result offset (xp.ndarray): The offset in pixels
Source code in tomobase/processes/alignments/translation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
weight_by_angle
weight_by_angle(sino: Sinogram)
Weight the sinogram by the angle Arguments: sino (Sinogram): The projection data inplace (bool): Whether to do the alignment in-place in the input data object (default: True) extend_return (bool): If True, the return value will be a tuple with the weights in the second item (default: False) Returns: Sinogram: The result weights (xp.ndarray): The weights in pixels
Source code in tomobase/processes/alignments/translation.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
beamdamage
beamdamage
beamdamage(volume: Volume, knock_on: float = 0.01, elastic_deform: float = 0.1, normalize: bool = True)
Apply beam damage simulation to a volume.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/deformations/beamdamage.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
deformations
beamdamage
beamdamage
beamdamage(volume: Volume, knock_on: float = 0.01, elastic_deform: float = 0.1, normalize: bool = True)
Apply beam damage simulation to a volume.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/deformations/beamdamage.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
forward_project
project
project(volume: Volume, angles: ndarray, use_gpu: bool = True)
Create a sinogram from a volume using forward projection. The GPU Context is overriden due to underlying astra gpu usage. Args: volume (Volume): The input volume to be projected. angles (np.array): The angles at which to project the volume. use_gpu (bool): Whether to use GPU for projection. Default is True. Returns: Sinogram: The resulting sinogram.
Source code in tomobase/processes/forward_project.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
image_processing
rotational_misalignment
rotational_misalignment(sino: Sinogram, tilt_theta: float = 3, tilt_alpha: float = 2, backlash: float = 0.5, backlash_backwards: bool = True)
Apply a random rotational misalignment to the sinogram. Args: sino (Sinogram): The projection data tilt_theta (float): The maximum rotation angle in degrees (default: 3) tilt_alpha (float): The maximum offset in degrees (default: 2) backlash (float): The maximum backlash in degrees (default: 0.5) backlash_backwards (bool): Whether to apply the backlash backwards or forwards (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
translational_misalignment
translational_misalignment(sino: Sinogram, offset: float = 0.25)
Apply a random translational misalignment to the sinogram. Arguments: sino (Sinogram): The projection data offset (float): The maximum offset in pixels (default: 0.25)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
poisson_noise
poisson_noise(obj: Data, rescale: float = True)
Add Poisson noise to the sinogram. Args: obj (Data): The input data object rescale (float): Rescale the data to the range of the Poisson noise (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
gaussian_filter
gaussian_filter(obj: Data, gaussian_sigma: float = 1)
Add Gaussian noise to the sinogram. Args: obj (Data): The input data object gaussian_sigma (float): Standard deviation of the Gaussian noise (default: 1) inplace (bool): Whether to do the operation in-place in the input data object (Default: True) Returns: Data: The result
Source code in tomobase/processes/image_processing/misalignments.py
13 14 15 16 17 18 19 20 21 22 23 24 | |
background_subtract_median
background_subtract_median(image: Data)
Subtract the median of the sinogram from the sinogram."
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/background.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
pad_sinogram
pad_sinogram(sino: Sinogram, x: int = 0, y: int = 0)
Pad the sinogram to the specified size.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
bin
bin(obj: Data, factor: int = 2)
Bin the sinogram data by a specified factor.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
normalize
normalize(sino: Sinogram)
Normalize the sinogram data to the range [0, 1].
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
background
background_subtract_median
background_subtract_median(image: Data)
Subtract the median of the sinogram from the sinogram."
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/background.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
misalignments
gaussian_filter
gaussian_filter(obj: Data, gaussian_sigma: float = 1)
Add Gaussian noise to the sinogram. Args: obj (Data): The input data object gaussian_sigma (float): Standard deviation of the Gaussian noise (default: 1) inplace (bool): Whether to do the operation in-place in the input data object (Default: True) Returns: Data: The result
Source code in tomobase/processes/image_processing/misalignments.py
13 14 15 16 17 18 19 20 21 22 23 24 | |
poisson_noise
poisson_noise(obj: Data, rescale: float = True)
Add Poisson noise to the sinogram. Args: obj (Data): The input data object rescale (float): Rescale the data to the range of the Poisson noise (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
translational_misalignment
translational_misalignment(sino: Sinogram, offset: float = 0.25)
Apply a random translational misalignment to the sinogram. Arguments: sino (Sinogram): The projection data offset (float): The maximum offset in pixels (default: 0.25)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
rotational_misalignment
rotational_misalignment(sino: Sinogram, tilt_theta: float = 3, tilt_alpha: float = 2, backlash: float = 0.5, backlash_backwards: bool = True)
Apply a random rotational misalignment to the sinogram. Args: sino (Sinogram): The projection data tilt_theta (float): The maximum rotation angle in degrees (default: 3) tilt_alpha (float): The maximum offset in degrees (default: 2) backlash (float): The maximum backlash in degrees (default: 0.5) backlash_backwards (bool): Whether to apply the backlash backwards or forwards (default: True)
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/misalignments.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
scaling
normalize
normalize(sino: Sinogram)
Normalize the sinogram data to the range [0, 1].
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
8 9 10 11 12 13 14 15 16 17 18 19 20 | |
bin
bin(obj: Data, factor: int = 2)
Bin the sinogram data by a specified factor.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
pad_sinogram
pad_sinogram(sino: Sinogram, x: int = 0, y: int = 0)
Pad the sinogram to the specified size.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in tomobase/processes/image_processing/scaling.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
crop_sinogram
crop_sinogram(sino: Sinogram, x: int = 0, y: int = 0)
Crop the sinogram to the specified size.
Parameters: sino (Sinogram): Input sinogram to be cropped. x (int): Target size for the x dimension. y (int): Target size for the y dimension. inplace (bool): Whether to modify the array in place or return a new array.
Returns: Sinogram: Cropped sinogram.
Source code in tomobase/processes/image_processing/scaling.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
reconstruct
optomo_reconstruct
optomo_reconstruct(sino: Sinogram, iterations: int = 0, use_gpu: bool = True, weighted: bool = False)
Reconstruct a volume from a given sinogram using SIRT ASTRA. Allows for projections to be weighted by angular distribution. Arguments: sino (Sinogram): The projection data iterations (int): The number of iterations when using an iterative reconstructor, leaving this at None will select the default number of iterations for the given algorithm (default: None) use_gpu (bool): Use a GPU if it is available (default: True) weighted (bool): Use a weighted backprojection (default: False)
| Returns: |
|
|---|
Source code in tomobase/processes/reconstruct.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
astra_reconstruct
astra_reconstruct(sino: Sinogram, method: str = 'sirt', iterations: int = 0, use_gpu: bool = True)
Reconstruct a volume from a given sinogram.
| Returns: |
|
|---|
Source code in tomobase/processes/reconstruct.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |