コード例 #1
0
ファイル: starfish.py プロジェクト: vipulsinghal02/starfish
def build_parser():
    parser = argparse.ArgumentParser()

    parser.add_argument("--profile",
                        action="store_true",
                        help="enable profiling")
    parser.add_argument("--noop",
                        help=argparse.SUPPRESS,
                        dest="starfish_command",
                        action="store_const",
                        const=noop)

    subparsers = parser.add_subparsers(dest="starfish_command")

    Registration._add_to_parser(subparsers)
    Filter._add_to_parser(subparsers)
    SpotFinder.add_to_parser(subparsers)
    Segmentation._add_to_parser(subparsers)
    TargetAssignment.add_to_parser(subparsers)
    Decoder.add_to_parser(subparsers)

    show_group = subparsers.add_parser("show")
    show_group.add_argument("in_json", type=FsExistsType())
    show_group.add_argument("--sz", default=10, type=int, help="Figure size")
    show_group.set_defaults(starfish_command=show)

    build_group = subparsers.add_parser("build")
    BuilderCli.add_to_parser(build_group)

    validate_group = subparsers.add_parser("validate")
    ValidateCli.add_to_parser(validate_group)

    return parser
コード例 #2
0
def iss_pipeline(fov, codebook):
    primary_image = fov[starfish.FieldOfView.PRIMARY_IMAGES]

    # register the raw images
    registration = Registration.FourierShiftRegistration(
        upsampling=1000,
        reference_stack=fov['dots']
    )
    registered = registration.run(primary_image, in_place=False)

    # filter raw data
    masking_radius = 15
    filt = Filter.WhiteTophat(masking_radius, is_volume=False)
    filtered = filt.run(registered, verbose=True, in_place=False)

    # detect spots using laplacian of gaussians approach
    p = SpotFinder.BlobDetector(
        min_sigma=1,
        max_sigma=10,
        num_sigma=30,
        threshold=0.01,
        measurement_type='mean',
    )

    mp = fov['dots'].max_proj(Indices.ROUND, Indices.Z)
    mp_numpy = mp._squeezed_numpy(Indices.ROUND, Indices.Z)
    intensities = p.run(filtered, blobs_image=mp_numpy)

    # decode the pixel traces using the codebook
    decoded = codebook.decode_per_round_max(intensities)

    # segment cells
    seg = Segmentation.Watershed(
        nuclei_threshold=.16,
        input_threshold=.22,
        min_distance=57,
    )
    label_image = seg.run(primary_image, fov['nuclei'])

    # assign spots to cells
    ta = TargetAssignment.Label()
    assigned = ta.run(label_image, decoded)

    return assigned, label_image
コード例 #3
0
def iss_pipeline(fov, codebook):
    primary_image = fov.primary_image

    # register the raw images
    registration = Registration.FourierShiftRegistration(
        upsampling=1000,
        reference_stack=fov['dots']
    )
    registered = registration.run(primary_image, in_place=False)

    # filter raw data
    masking_radius = 15
    filt = Filter.WhiteTophat(masking_radius, is_volume=False)
    filtered = filt.run(registered, verbose=True, in_place=False)

    # detect spots using laplacian of gaussians approach
    p = SpotFinder.GaussianSpotDetector(
        min_sigma=1,
        max_sigma=10,
        num_sigma=30,
        threshold=0.01,
        measurement_type='mean',
    )
    blobs_image = fov['dots'].max_proj(Indices.ROUND, Indices.Z)
    intensities = p.run(filtered, blobs_image=blobs_image)

    # decode the pixel traces using the codebook
    decoded = codebook.decode_per_round_max(intensities)

    # segment cells
    seg = Segmentation.Watershed(
        dapi_threshold=.16,
        input_threshold=.22,
        min_distance=57,
    )
    regions = seg.run(primary_image, fov['nuclei'])

    # assign spots to cells
    ta = TargetAssignment.PointInPoly2D()
    assigned = ta.run(decoded, regions)

    return assigned, regions
コード例 #4
0
# EPY: END markdown

# EPY: START markdown
#For each imaging round, the max projection across color channels should look like the dots stain.
#Below, this computes the max projection across the color channels of an imaging round and learns the linear transformation to maps the resulting image onto the dots image.
#
#The Fourier shift registration approach can be thought of as maximizing the cross-correlation of two images.
#
#In the below table, Error is the minimum mean-squared error, and shift reports changes in x and y dimension.
# EPY: END markdown

# EPY: START code
from starfish.image import Registration

registration = Registration.FourierShiftRegistration(upsampling=1000,
                                                     reference_stack=dots,
                                                     verbose=True)
registered_image = registration.run(primary_image, in_place=False)
# EPY: END code

# EPY: START markdown
### Use spot-detector to create 'encoder' table  for standardized input  to decoder
# EPY: END markdown

# EPY: START markdown
#Each pipeline exposes an encoder that translates an image into spots with intensities.  This approach uses a Gaussian spot detector.
# EPY: END markdown

# EPY: START code
from starfish.spots import SpotFinder
import warnings