|
| 1 | +Basic Use of qpretrieve |
| 2 | +======================= |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +.. code-block:: python |
| 7 | +
|
| 8 | + import qpretrieve |
| 9 | +
|
| 10 | + # load your experimental data |
| 11 | + edata = np.load("./data/hologram_cell.npz") # example data from the qpretrieve repository |
| 12 | + data = edata["data"] |
| 13 | + data_bg = edata["bg_data"] |
| 14 | +
|
| 15 | + # create an off-axis hologram object, to process the holography data |
| 16 | + oah = qpretrieve.OffAxisHologram(data) |
| 17 | + oah.run_pipeline(filter_name=filter_name, filter_size=filter_size) |
| 18 | + # process background hologram |
| 19 | + oah_bg = qpretrieve.OffAxisHologram(data=data_2d_bg) |
| 20 | + oah_bg.process_like(oah) |
| 21 | +
|
| 22 | + print(f"Original Hologram shape: {data.shape}") |
| 23 | + print(f"Processed Field shape: {oah.field.shape}") |
| 24 | +
|
| 25 | + # Now you can look at the phase data |
| 26 | + phase_corrected = oah.phase - oah_bg.phase |
| 27 | +
|
| 28 | +
|
| 29 | +
|
| 30 | +Differences between old (2D) and new (3D) image processing |
| 31 | +---------------------------------------------------------- |
| 32 | + |
| 33 | +qpretrieve used to only processed 2D array layout. Since version (0.4.0), it accepts |
| 34 | +3D array layout, and always returns the data as 3D, regardless of the input |
| 35 | +array layout. |
| 36 | + |
| 37 | +New version example code and output: |
| 38 | +.................................... |
| 39 | + |
| 40 | +.. code-block:: python |
| 41 | +
|
| 42 | + import qpretrieve # versions older than 0.4.0 |
| 43 | +
|
| 44 | + hologram = np.ones(shape=(256, 256)) |
| 45 | + oah = qpretrieve.OffAxisHologram(hologram) |
| 46 | + oah.run_pipeline() |
| 47 | + assert oah.field.shape == (1, 256, 256) # <- now a 3D array is returned |
| 48 | + # if you want the original array layout (2d) |
| 49 | + field_2d = oah.get_array_with_input_layout("field") |
| 50 | +
|
| 51 | + # this means you can input 3D arrays |
| 52 | + hologram_3d = np.ones(shape=(50, 256, 256)) |
| 53 | + oah = qpretrieve.OffAxisHologram(hologram_3d) |
| 54 | + oah.run_pipeline() |
| 55 | + assert oah.field.shape == (50, 256, 256) # <- always a 3D array |
| 56 | +
|
| 57 | +
|
| 58 | +Old version example code and output: |
| 59 | +.................................... |
| 60 | + |
| 61 | +.. code-block:: python |
| 62 | +
|
| 63 | + import qpretrieve # versions older than 0.4.0 |
| 64 | +
|
| 65 | + hologram = np.ones(shape=(256, 256)) |
| 66 | + oah = qpretrieve.OffAxisHologram(hologram) |
| 67 | + oah.run_pipeline() |
| 68 | + assert oah.field.shape == hologram.shape |
| 69 | +
|
0 commit comments