Skip to content

Warn about too many 0 counts. #73

@YooSunYoung

Description

@YooSunYoung

We have this helper function to replace 0 counts in background images.

def apply_threshold_to_background_image(
background: CleansedOpenBeamImage, background_threshold: BackgroundPixelThreshold
) -> BackgroundImage:
"""Apply the threshold to the background image.
Parameters
----------
background:
Background image.
background_threshold:
Threshold for the background pixel values.
Any pixel values less than ``background_threshold``
are replaced with ``background_threshold``.
"""
background = CleansedOpenBeamImage(background.copy(deep=False))
background.data = sc.where(
background.data < background_threshold, background_threshold, background.data
)
return BackgroundImage(background)

It was needed because imaging workflows need to normalize sample data pixel by pixel, time bin by time bin.

It surprised people quite a few times that the normalization works but the normalized image does not look normalized if too many histogram bins have 0 counts.

It should either raise an exception or at least throw warning if there are too many 0 counts.
I'm not sure how to decide when it's too-many though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions