Examples¶
In this section we describe the examples which come directly with syris in order to demonstrate its usage.
Composite body¶
composite_body.py
Composite body example¶
Here we show how to use a composite body in order to move groups of objects around. This is possible in two ways, either manually by translating and rotating the composite body, or automatically by using a trajectory.
Manual¶
This example shows manual rotation of a grid of spheres with different radii around one of the spheres. CompositeObject is used to simplify the transformations workflow.
Trajectory¶
This example has the same result as the previous one but achieved by trajectories.
Subtrajectories¶
This example shows a circular global motion followed by the whole composite body and its sub-bodies, which are cuboids following their own local linear trajectories. The sub-bodies further move along their own trajectories.
Edge enhancement¶
edge_enhancement.py
Edge enhancement caused by free-space propagation. Control the accuracy by the –supersampling option. If this value is too low (1), the propagators are not resolved correctly and the resulting images contain artefacts. Increase this value to e.g. 4 and you will see how the propagators and the results change.
Experiment¶
experiment.py
Experiment example.
-
examples.experiment.
main
()¶ Parse command line arguments and execute one of the experiments.
-
examples.experiment.
make_devices
(n, energies, camera=None, highspeed=True, scintillator=None)¶ Create devices with image shape (n, n), X-ray energies, camera and use the high speed setup if highspeed is True.
Fresnel Propagation Accuracy¶
fresnel.py
Comparison of analytical and numerical Fresnel diffraction pattern. The object is a square aperture from Introduction to Fourier Optics by J. W. Goodmann, 2nd edition.
-
examples.fresnel.
crop_to_aperture
(image, w, ps)¶ Crop image to 2x aperture width.
-
examples.fresnel.
main
()¶ Main function.
-
examples.fresnel.
parse_args
()¶ Parse command line arguments.
-
examples.fresnel.
propagate_analytically
(n, w, ps, d, lam)¶ Propagate square aperture analytically.
-
examples.fresnel.
propagate_numerically
(n, w, ps, d, lam)¶ Propagate square aperture numerically.
Mesh Bodies¶
mesh.py
Mesh projection and slice.
-
examples.mesh.
main
()¶ Main function.
-
examples.mesh.
parse_args
()¶ Parse command line arguments.
Laminography of Samples Defined by Meshes¶
mesh_scan.py
Laminography data set generation with mesh geometry.
-
examples.mesh_scan.
log_attributes
(obj)¶ Log object obj attributes.
-
examples.mesh_scan.
make_ground_truth
(args, shape, mesh)¶ Shape is (y, x), so the total number of slices is y.
-
examples.mesh_scan.
scan
(shape, ps, axis, mesh, angles, prefix, lamino_angle=array(45.) * deg, index=0, num_devices=1, shift_coeff=10000.0, ss=1)¶ Make a scan of tomographic angles. shift_coeff is the coefficient multiplied by pixel size which shifts the triangles to get rid of faulty pixels.
Metaballs¶
metaballs.py
Paganin Phase Retrieval¶
paganin.py
Show forward phase contrast simulation and backward phase retrieval using the Paganin method[1].
[1] Paganin, David, et al. “Simultaneous phase and amplitude extraction from a single defocused image of a homogeneous object.” Journal of microscopy 206.1 (2002): 33-40.
Multi GPU Speedup¶
multigpu.py
Show multi-device speedup on a problem of size n x m^k, where n is the number of pixels to compute, m is the base number of operations per pixel powered to k.
Tomographic Rotation¶
tomographic_rotation.py
Example of a trajectory which simulates tomographic rotation.
4D Tomography¶
tomography_4D.py
Simple 4D tomography example. Two cubes rotate around the tomographic rotation axis and at the same time move along y-axis. The total vertical displacement between rotation start and end is the cube edge. This leads to an “incomplete” data set with increasingly more missing data in the sinogram space from top to bottom. There is exactly one complete sinogram, the middle one.
Trajectory¶
trajectory.py
Trajectory and motion example.
-
examples.trajectory.
create_sample
(n, ps, radius=None, velocity=None, x_ends=None, y_ends=None)¶ Crete a metaball with a sine trajectory.
-
examples.trajectory.
main
()¶
-
examples.trajectory.
make_circle
(n=128, axis='z', overall_angle=None, phase_shift=None)¶ Axis specifies the axis of rotation, which can be ‘x’, ‘y’ or ‘z’.
-
examples.trajectory.
parse_args
()¶ Parse command line arguments.
Transformation Order¶
transformation.py
Demonstrates the order of transformations.
-
examples.transformation.
main
()¶ Script execution.
-
examples.transformation.
print_rounded
(vector, decimals=2)¶ Print a roundded version of vector.
-
examples.transformation.
transform
(point=array([1., 0., 0.]) * m, x_rot=array(90.) * deg, y_rot=array(90.) * deg, z_rot=array(0.) * deg)¶ Transform point by a series of rotations, x_rot around x axis and so on for y_rot and z_rot.
Transmission Function Sampling¶
transmission_function_sampling.py
Aliasing of the transmission function of a wedge which projection is computed as f(x, y) = x. Delta is chosen in such a way that it causes phase shift between two adjacent pixels 2Pi in case of no supersampling. Thus, The transmission function of the wedge along x has phase 0, 2Pi, 4Pi, …, which is lost due to insufficient pixel spacing in case of no supersampling.
The used material is a pure phase material, i.e. beta = 0. The results are the real part of the T(x, y), which is cos(-2 Pi / lambda x delta).