Coverage for local_installation_linux/mumott/pipelines/filtered_back_projection.py: 80%

16 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-08-11 23:08 +0000

1import logging 

2 

3from mumott import DataContainer 

4from mumott.methods.projectors import SAXSProjector, SAXSProjectorCUDA 

5from .fbp_utilities import get_filtered_projections 

6 

7logger = logging.getLogger(__name__) 

8 

9 

10def run_fbp(data_container: DataContainer, 

11 use_gpu: bool = False, 

12 fbp_axis: str = 'inner', 

13 filter_type: str = 'Ram-Lak', 

14 **kwargs) -> dict: 

15 """ 

16 This pipeline is used to compute the filtered back projection of the 

17 absorbances calculated from the diode. This allows for a quick, one-step 

18 solution to the problem of scalar tomography. 

19 

20 Parameters 

21 ---------- 

22 data_container 

23 The :class:`DataContainer <mumott.data_handling.DataContainer>` 

24 holding the data set of interest. 

25 use_gpu 

26 Whether to use GPU resources in computing the projections. 

27 Default is ``False``. If set to ``True``, the method will use 

28 :class:`SAXSProjectorCUDA <mumott.methods.projectors.SAXSProjectorCUDA>`. 

29 fbp_axis 

30 Default is ``'inner'``, the value depends on how the sample is mounted to the holder. Typically, 

31 the inner axis is the rotation axis while the ``'outer'`` axis refers to the tilt axis. 

32 filter_type 

33 Default is ``'Ram-Lak'``, a high-pass filter. Other options are ``'Hamming'``, ``'Hann'``, 

34 ``'Shepp-Logan'`` and ``'cosine'``. 

35 kwargs 

36 Miscellaneous keyword arguments. See notes for details. 

37 

38 Notes 

39 ----- 

40 Three possible :attr:`kwargs` can be provided: 

41 

42 Projector 

43 The :ref:`projector class <projectors>` to use. 

44 normalization_percentile 

45 The normalization percentile to use for the transmittivity calculation. See 

46 :func:`get_transmittivities <mumott.data_handling.utilities.get_transmittivities>` for details. 

47 transmittivity_cutoff 

48 The cutoffs to use for the transmittivity calculation. See 

49 :func:`get_transmittivities <mumott.data_handling.utilities.get_transmittivities>` for details. 

50 

51 

52 Returns 

53 ------- 

54 A dictionary with the entry ``'result'``, with an entry ``'x'``, containing 

55 a filtered back projection reconstruction of the absorptivity calculated 

56 from the ``diode``. 

57 """ 

58 if 'Projector' in kwargs: 58 ↛ 59line 58 didn't jump to line 59, because the condition on line 58 was never true

59 Projector = kwargs.pop('Projector') 

60 else: 

61 if use_gpu: 61 ↛ 62line 61 didn't jump to line 62, because the condition on line 61 was never true

62 Projector = SAXSProjectorCUDA 

63 else: 

64 Projector = SAXSProjector 

65 projector = Projector(data_container.geometry) 

66 filtered_projections, indices = get_filtered_projections(data_container.projections, 

67 axis_string=fbp_axis, 

68 filter_type=filter_type, 

69 **kwargs) 

70 filtered_projections = filtered_projections.astype(projector.dtype) 

71 fbp_reconstruction = projector.adjoint(filtered_projections, indices) 

72 return dict(result=dict(x=fbp_reconstruction), projector=projector, fbp_indices=indices)