File: create_your_own_sequence.rst

package info (click to toggle)
python-nxtomomill 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,340 kB
  • sloc: python: 17,207; makefile: 15; sh: 3
file content (119 lines) | stat: -rw-r--r-- 3,415 bytes parent folder | download
1
2
3
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
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
How to define your own sequence to build an NXtomo
==================================================

Design
""""""

The conversion process is done as follow:

.. image:: img/nxtomomill_design_1.png

The first step this can be done two ways

.. image:: img/nxtomomill_design_2.png

Until now we were only using the title to deduce the acquisition and the type of frames of each Bliss entry.

But the `FRAME_TYPE_SECTION` allow us to ignore those titles and define manually the sequence of the acquisition.


Coming back to the `FRAME_TYPE_SECTION` section

`FRAME_TYPE_SECTION` section
''''''''''''''''''''''''''''

If this section is fill then the `ENTRIES_AND_TITLES_SECTION` will be ignored. Those are mutually exclusive sections.

From it we can define `data_scans` that allow us to define a sequence of scan defining an acquisition using [url](https://fr.wikipedia.org/wiki/Uniform_Resource_Locator). Like:

.. code-block:: text

    data_scans = (
        (frame_type=projections, entry=silx:///path/to/file?/path/to/scan/node,),
        (frame_type=projections, entry=/path_relative_to_file),
    )

Here we will create one acquisition from `silx:///path/to/file?/path/to/scan/node` to be used as a set of projections and `/path_relative_to_file` as a set of projections to.

.. note::
    
    Url can be relative to different file

.. warning::

    The created acquisition will follow the provided order


Example: create an NXtomo using the `data_scans` field
""""""""""""""""""""""""""""""""""""""""""""""""""""""

Using the configuration file
''''''''''''''''''''''''''''

You can find a file `conversion_using_data_scans.cfg` in the `solution` folder that create an acquisition using `data_scans`:


.. image:: img/nxtomomill_example_data_scans.png


It can be executed by calling:

.. code-block:: bash

    nxtomomill h52nx --config conversion_using_data_scans.cfg

Using the python API
''''''''''''''''''''

.. code-block:: python

    from nxtomomill.converter import from_h5_to_nx
    from nxtomomill.io.config import TomoHDF5Config
    from nxtomomill.io.config.h52nxtomo_models import FrameGroup
    from silx.io.url import DataUrl

    input_file_path = "bambou_hercules_0001.h5"

    configuration = TomoHDF5Config()
    configuration.input_file = input_file_path
    configuration.output_file = "bambou_hercules_0001.nx"
    configuration.data_scans = (
        FrameGroup(
            url=DataUrl(
                file_path=input_file_path,
                data_path="1.1",
                scheme="silx",
            ),
            frame_type="initialization",
        ),
        FrameGroup(
            url=DataUrl(
                file_path=input_file_path,
                data_path="2.1",
                scheme="silx",
            ),
            frame_type="darks",
        ),
        FrameGroup(
            url=DataUrl(
                file_path=input_file_path,
                data_path="3.1",
                scheme="silx",
            ),
            frame_type="flats",
        ),
        FrameGroup(
            url=DataUrl(
                file_path=input_file_path,
                data_path="4.1",
                scheme="silx",
            ),
            frame_type="projections",
        ),            
    )

    res = from_h5_to_nx(configuration=configuration)

.. note::

    you will see another way to create an NXtomo from scratch that could be another alternative.