Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
- fix: segmenters more than two levels below `Segmenter` (e.g. a
subclass of `SegmentThresh`) were not found by `get_segmenters`,
so their pipeline identifier could not be resolved
- fix: `detect_flickering` raised a `TypeError` for `HDF5Data`
instances, although the docstring allowed them
- docs: comment on intended behavior of `fill_holes` (mask
post-processing), Haralick texture features, and the sparsemed
background assignment after cleansing
Expand Down
8 changes: 5 additions & 3 deletions dcnum/read/detect_flicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def detect_flickering(image_data: np.ndarray | HDF5Data,
Parameters
----------
image_data:
sliceable object (e.g. numpy array or HDF5Data) containing
image data.
sliceable object (e.g. numpy array or image cache) containing
image data or HDF5Data instance (the "image" feature is used)
roi_height: int
height of the ROI in pixels for which to search for flickering;
the entire width of the image is used
Expand All @@ -38,7 +38,9 @@ def detect_flickering(image_data: np.ndarray | HDF5Data,
max_frames: int
maximum number of frames to include in the flickering analysis
"""
# slice event axis first in case we have and HDF5Data instance
if isinstance(image_data, HDF5Data):
image_data = image_data.image
# slice event axis first in case we have an image cache
roi_data = image_data[:max_frames][:, :roi_height, :]
roi_median = np.median(roi_data, axis=(1, 2))
roi_offset = roi_median - np.median(roi_median)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_read_detect_flicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def test_detect_flicker_hdf5data_instance():
assert len(hd) == 1000
assert not detect_flickering(hd.image)
assert detect_flickering(hd.image, brightness_threshold=1)
# HDF5Data instance (dcnum 0.31.2 raised a TypeError)
assert not detect_flickering(hd)
assert detect_flickering(hd, brightness_threshold=1)


def test_detect_flicker_none():
Expand Down
Loading