Beispiel #1
0
def test_spot_detection_with_reference_image(
    data_stack: ImageStack,
    spot_detector: SpotFinderAlgorithmBase,
    radius_is_gyration: bool,
):
    """
    This testing method uses a reference image to identify spot locations. Thus, it should detect
    two spots, each with max intensity 7. Because the channels and rounds are aggregated, this
    method should recognize the 1-hot code used in the testing data, and see one channel "on" per
    round. Thus, the total intensity across all channels and round for each spot should be 14.

    """
    reference_image = data_stack.max_proj(Indices.CH, Indices.ROUND)

    intensity_table = detect_spots(
        data_stack=data_stack,
        spot_finding_method=spot_detector.image_to_spots,
        reference_image=reference_image,
        measurement_function=np.max,
        radius_is_gyration=radius_is_gyration,
    )
    assert intensity_table.shape == (2, 2, 2), "wrong number of spots detected"
    expected = [0.01587425, 0.01587425]
    assert np.allclose(intensity_table.sum((Indices.ROUND, Indices.CH)).values, expected), \
        "wrong spot intensities detected"
Beispiel #2
0
 def call_detect_spots(stack):
     return detect_spots(
         data_stack=stack,
         spot_finding_method=spot_detector.image_to_spots,
         measurement_function=np.max,
         radius_is_gyration=radius_is_gyration,
         n_processes=1,
     )
Beispiel #3
0
 def call_detect_spots(stack):
     return detect_spots(
         data_stack=stack,
         spot_finding_method=spot_detector.image_to_spots,
         reference_image=stack,
         reference_image_max_projection_axes=(Axes.ROUND, Axes.CH),
         measurement_function=np.max,
         radius_is_gyration=radius_is_gyration,
         n_processes=1,
     )
Beispiel #4
0
    def call_detect_spots(stack):

        reference_image_mp = stack.max_proj(Axes.CH, Axes.ROUND)
        reference_image_mp_numpy = reference_image_mp._squeezed_numpy(Axes.CH, Axes.ROUND)

        return detect_spots(
            data_stack=stack,
            spot_finding_method=spot_detector.image_to_spots,
            reference_image=reference_image_mp_numpy,
            measurement_function=np.max,
            radius_is_gyration=radius_is_gyration,
            n_processes=1,
        )
Beispiel #5
0
def test_spot_finding_no_reference_image(
        data_stack: ImageStack,
        spot_detector: SpotFinderAlgorithmBase,
        radius_is_gyration: bool,
):
    """
    This testing method does not provide a reference image, and should therefore check for spots
    in each (round, ch) combination in sequence. With the given input, it should detect 4 spots,
    each with a max value of 7. Because each (round, ch) are measured sequentially, each spot only
    measures a single channel. Thus the total intensity across all rounds and channels for each
    spot should be 7.
    """
    intensity_table = detect_spots(data_stack=data_stack,
                                   spot_finding_method=spot_detector.image_to_spots,
                                   measurement_function=np.max,
                                   radius_is_gyration=radius_is_gyration)
    assert intensity_table.shape == (4, 2, 2), "wrong number of spots detected"
    expected = [0.00793712] * 4
    assert np.allclose(intensity_table.sum((Axes.ROUND, Axes.CH)).values, expected), \
        "wrong spot intensities detected"
Beispiel #6
0
def test_spot_finding_no_reference_image(
        data_stack: ImageStack,
        spot_detector: SpotFinderAlgorithmBase,
        radius_is_gyration: bool,
        max_intensity: float,
):
    """
    This testing method does not provide a reference image, and should therefore check for spots
    in each (round, ch) combination in sequence. With the given input, it should detect 4 spots.
    """

    def call_detect_spots(stack):
        return detect_spots(
            data_stack=stack,
            spot_finding_method=spot_detector.image_to_spots,
            measurement_function=np.max,
            radius_is_gyration=radius_is_gyration,
            n_processes=1,
        )

    intensity_table = call_detect_spots(data_stack)
    assert intensity_table.sizes[Features.AXIS] == 4, "wrong number of spots detected"
    expected = [max_intensity] * 4
    assert np.allclose(intensity_table.sum((Axes.ROUND, Axes.CH)).values, expected), \
        "wrong spot intensities detected"

    # verify this execution strategy produces an empty intensitytable when called with a blank image
    empty_intensity_table = detect_spots(
        data_stack=EMPTY_IMAGESTACK,
        spot_finding_method=spot_detector.image_to_spots,
        measurement_function=np.max,
        radius_is_gyration=radius_is_gyration
    )

    empty_intensity_table = call_detect_spots(EMPTY_IMAGESTACK)
    assert empty_intensity_table.sizes[Features.AXIS] == 0