Пример #1
0
def processing_pipeline(
    experiment: starfish.Experiment,
    fov_name: str,
    n_processes: Optional[int] = None
) -> Tuple[starfish.ImageStack, starfish.IntensityTable]:
    """Process a single field of view of an experiment

    Parameters
    ----------
    experiment : starfish.Experiment
        starfish experiment containing fields of view to analyze
    fov_name : str
        name of the field of view to process
    n_processes : int

    Returns
    -------
    starfish.IntensityTable :
        decoded IntensityTable containing spots matched to the genes they are hybridized against
    """

    print("Loading images...")
    primary_image = experiment[fov_name].get_image(FieldOfView.PRIMARY_IMAGES)
    all_intensities = list()
    codebook = experiment.codebook
    for primary_image in experiment[fov_name].iterate_image_type(
            FieldOfView.PRIMARY_IMAGES):
        print("Filtering images...")
        filter_kwargs = dict(in_place=True,
                             verbose=True,
                             n_processes=n_processes)
        clip1.run(primary_image, **filter_kwargs)
        bandpass.run(primary_image, **filter_kwargs)
        glp.run(primary_image, **filter_kwargs)
        clip2.run(primary_image, **filter_kwargs)

        print("Calling spots...")
        spot_attributes = tlmpf.run(primary_image)
        all_intensities.append(spot_attributes)

    spot_attributes = IntensityTable.concatanate_intensity_tables(
        all_intensities)
    print("Decoding spots...")
    decoded = codebook.decode_per_round_max(spot_attributes)
    decoded = decoded[decoded["total_intensity"] > .025]

    return primary_image, decoded
Пример #2
0
def test_take_max():
    """
    Create two overlapping IntensityTables with differing number of spots and verify that
    by concatenating them with the TAKE_MAX strategy we only include spots in the overlapping
    section from the IntensityTable that had the most.
    """
    it1 = create_intensity_table_with_coords(Area(min_x=0,
                                                  max_x=2,
                                                  min_y=0,
                                                  max_y=2),
                                             n_spots=10)
    it2 = create_intensity_table_with_coords(Area(min_x=1,
                                                  max_x=2,
                                                  min_y=1,
                                                  max_y=3),
                                             n_spots=20)

    concatenated = IntensityTable.concatanate_intensity_tables(
        [it1, it2], overlap_strategy=OverlapStrategy.TAKE_MAX)

    # The overlap section hits half of the spots from each intensity table, 5 from it1
    # and 10 from i21. It2 wins and the resulting concatenated table should have all the
    # spots from it2 (20) and 6 (one on the border) from it1 (6) for a total of 26 spots
    assert concatenated.sizes[Features.AXIS] == 26