Skip to content

Commit

Permalink
ref: deprecate hologram input type in favor of raw-oah
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Mar 18, 2022
1 parent e561895 commit 1b0c5fe
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.7.6
- ref: deprecate "hologram" input type in favor of "raw-oah"
0.7.5
- enh: write HDF5 image metadata so that HDFView 3.1.1 can
visualize the phase data
Expand Down
2 changes: 1 addition & 1 deletion examples/background_mask_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

# create QPImage instance
qpi = qpimage.QPImage(data=edata,
which_data="hologram",
which_data="raw-oah",
meta_data={"medium index": 1.335,
"wavelength": 550e-9,
"pixel size": 0.107e-6})
Expand Down
2 changes: 1 addition & 1 deletion examples/background_poly2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
edata = np.array(Image.open("./data/hologram_cell_curved_bg.jpg"))

# create QPImage instance
qpi = qpimage.QPImage(data=edata, which_data="hologram")
qpi = qpimage.QPImage(data=edata, which_data="raw-oah")
pha0 = qpi.pha

# background correction using tilt only
Expand Down
4 changes: 2 additions & 2 deletions examples/hologram_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# create QPImage instance
qpi = qpimage.QPImage(data=edata["data"],
bg_data=edata["bg_data"],
which_data="hologram",
# This parameter allows to pass arguments to the
which_data="raw-oah",
# This parameter allows passing arguments to the
# hologram-analysis algorithm of qpimage.
# (see qpimage.holo.get_field)
holo_kw={
Expand Down
4 changes: 2 additions & 2 deletions examples/hologram_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
quality. Contributions from the central band can lead to strong
artifacts. A balance between high resolution (large filter size)
and small contributions from the central band (small filter size)
usually has be found.
usually has to be found.
- It is not trivial to compare a gaussian filter with a disk filter
in terms of filter size (sigma vs. radius).
The gaussian filter takes into account larger frequencies and
Expand Down Expand Up @@ -61,7 +61,7 @@

for filter_name in filters:
qpi = qpimage.QPImage(data=hologram,
which_data="hologram",
which_data="raw-oah",
holo_kw={"filter_size": .5,
"filter_name": filter_name})
qpis.append(qpi)
Expand Down
24 changes: 15 additions & 9 deletions qpimage/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#: valid combinations for keyword argument `which_data`
VALID_INPUT_DATA = ["field",
"hologram",
"hologram", # deprecated
"raw-oah", # off-axis holography
"raw-qlsi", # quadri-wave lateral shearing interferometry
"phase",
("phase", "amplitude"),
("phase", "intensity"),
Expand Down Expand Up @@ -42,15 +44,15 @@ def __init__(self, data=None, bg_data=None, which_data="phase",
which_data: str or tuple
String or comma-separated list of strings indicating
the order and type of input data. Valid values are
"hologram", "field", "phase", "phase,amplitude",
or "phase,intensity", where the latter two require an
indexable object with the phase data as first element.
defined in :const:`VALID_INPUT_DATA`, where phase and
amplitude/intensity data require an indexable object
with the phase data as first element.
meta_data: dict or qpimage.MetaDict
Metadata associated with the input data.
see :data:`qpimage.meta.META_KEYS`
holo_kw: dict
Special keyword arguments for phase retrieval from
hologram data (`which_data="hologram"`).
hologram data (`which_data="raw-oah"`).
See :func:`qpimage.holo.get_field` for valid keyword
arguments.
Expand Down Expand Up @@ -263,9 +265,9 @@ def _get_amp_pha(self, data, which_data, proc_phase=True):
which_data: str
String or comma-separated list of strings indicating
the order and type of input data. Valid values are
"field", "phase", "hologram", "phase,amplitude", or
"phase,intensity", where the latter two require an
indexable object with the phase data as first element.
defined in :const:`VALID_INPUT_DATA`, where phase and
amplitude/intensity data require an indexable object
with the phase data as first element.
proc_phase: bool
Process the phase data. This includes phase unwrapping
using :func:`skimage.restoration.unwrap_phase` and
Expand Down Expand Up @@ -294,7 +296,11 @@ def _get_amp_pha(self, data, which_data, proc_phase=True):
elif which_data == ("phase", "intensity"):
amp = np.sqrt(data[1])
pha = data[0]
elif which_data == "hologram":
elif which_data in ["hologram", "raw-oah"]:
if which_data == "hologram":
warnings.warn("The 'hologram' data type is deprecated, "
+ "please use 'raw-oah' instead!",
DeprecationWarning)
amp, pha = self._get_amp_pha(holo.get_field(data, **self.holo_kw),
which_data="field")
else:
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_get_amp_pha_holo():
kx = -.6
ky = -.4
image = np.sin(kx * x + ky * y)
qpi = qpimage.QPImage(image, which_data="hologram")
qpi = qpimage.QPImage(image, which_data="raw-oah")
qpi.compute_bg(which_data="phase",
fit_offset="fit",
fit_profile="tilt",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_holo.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def test_qpimage_holo():
data = disk_max * ((x - size / 2)**2 + (y - size / 2)**2 < 30**2)
image = np.sin(kx * x + ky * y + data)
qpi = qpimage.QPImage(image,
which_data="hologram",
which_data="raw-oah",
holo_kw={"filter_name": "gauss"})
qpi.compute_bg(which_data="phase",
fit_offset="fit",
Expand Down

0 comments on commit 1b0c5fe

Please sign in to comment.