Usage¶
Examples¶
Command Line Interface¶
tomocupy includes a commad-line-interface (CLI). The simplest way to set a reconstruction parameter is to directly
pass it as an option to the tomocupy
command. Some options also accept an argument, while others simple enable certain
behavior. Parameters given directly via the command line will override those given via a parameter file or global configuration file.
To list all the options supported by the tomocupy CLI, after installing tomocupy, type:
(tomocupy)$ tomocupy -h
(tomocupy)$ tomocupy recon -h
(tomocupy)$ tomocupy recon_steps -h
Below are different reconstruction examples
Try center¶
(tomocupy)$ tomocupy recon --file-name data/test_data.h5 --nsino-per-chunk 4 --reconstruction-type try --center-search-width 100
Full volume¶
(tomocupy)$ tomocupy recon --file-name data/test_data.h5 --nsino-per-chunk 4 --rotation-axis 700 --reconstruction-type full
Double FOV¶
(tomocupy)$ (tomocupy)$ tomocupy recon --file-name data/test_data.h5 --nsino-per-chunk 4 --rotation-axis 700 --reconstruction-type full --file-type double_fov
Full volume rec with phase retrieval¶
(tomocupy)$ tomocupy recon_steps --file-name data/test_data.h5 --nsino-per-chunk 4 --rotation-axis 700 --reconstruction-type full --energy 20 --pixel-size 1.75 --propagation-distance 100 --retrieve-phase-alpha 0.001 --retrieve-phase-method paganin --reconstruction-type full
Laminographic try¶
(tomocupy)$ tomocupy recon_steps --file-name data/test_data.h5 --nsino-per-chunk 8 --nproj-per-chunk 8 --reconstruction-type try --center-search-width 100 --lamino-angle 20
Laminographic try angle¶
(tomocupy)$ tomocupy recon_steps --file-name data/test_data.h5 --nsino-per-chunk 8 --nproj-per-chunk 8 --rotation-axis 700 --reconstruction-type try_lamino --lamino-search-width 2 --lamino-angle 20
Laminographic full rec¶
(tomocupy)$ tomocupy recon_steps --file-name data/test_data.h5 --nsino-per-chunk 8 --nproj-per-chunk 8--reconstruction-type full --rotation-axis 700 --lamino-angle 20
Reconstruct APS data¶
This section contains the readrec_aps script.
Download file: readrec_aps.py
1import sys
2import pathlib
3import dxchange
4import tomocupy
5
6from tomocupy.dataio import reader
7from tomocupy.dataio import writer
8from tomocupy.global_vars import args
9
10def read_aps(fname):
11
12 _, meta_dict = dxchange.read_hdf_meta(fname)
13
14 params_dict = {}
15 for section in tomocupy.config.RECON_STEPS_PARAMS:
16 for key, value in tomocupy.config.SECTIONS[section].items():
17 key = key.replace('-', '_')
18 params_dict[key] = value['default']
19
20 # create a parameter object identical to the one passed using the CLI
21 global args
22 args.__dict__.update(params_dict)
23
24 # set only the parameters that are different from the default
25 args.reconstruction_type = 'try'
26 args.file_name = fname
27 args.rotation_axis_auto = 'auto'
28 args.out_path_name = '/data/tmpfdc/'
29 args.clear_folder = True
30 args.fbp_filter = 'shepp'
31 args.retrieve_phase_method = None
32 args.remove_stripe_method = 'vo'
33 args.pixel_size = meta_dict['measurement_instrument_detection_system_objective_resolution'][0] * 1e-4
34 args.propagation_distance = meta_dict['measurement_instrument_detector_motor_stack_setup_z'][0]
35 args.energy = meta_dict['measurement_instrument_monochromator_energy'][0]
36 args.retrieve_phase_alpha = 0.0008
37
38def main():
39
40 if len(sys.argv) == 1:
41 print ('ERROR: Must provide an hdf file name')
42 print ('Example:')
43 print (' python readrec_aps.py /data/aps_dataset.h5')
44 sys.exit(1)
45 else:
46 file_name = sys.argv[1]
47 p = pathlib.Path(file_name)
48 if p.is_file():
49 read_aps(file_name)
50
51 cl_reader = reader.Reader()
52 cl_writer = writer.Writer()
53
54 clrotthandle = tomocupy.FindCenter(cl_reader)
55 args.rotation_axis = clrotthandle.find_center()*2**args.binning
56 print(f'set rotaion axis {args.rotation_axis}')
57
58 clpthandle = tomocupy.GPURec(cl_reader, cl_writer)
59 clpthandle.recon_all()
60
61 print('Done!')
62
63
64 else:
65 print('ERROR: %s does not exist' % p)
66 sys.exit(1)
67
68
69if __name__ == "__main__":
70 main()