Skip to content

Instantly share code, notes, and snippets.

@mattcai
Created April 13, 2020 23:22
Show Gist options
  • Save mattcai/42d6123d934f988be37c5cd2b08f5e80 to your computer and use it in GitHub Desktop.
Save mattcai/42d6123d934f988be37c5cd2b08f5e80 to your computer and use it in GitHub Desktop.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
from starfish import Experiment, FieldOfView, ImageStack, display
from starfish.core.spots.DecodeSpots.trace_builders import build_traces_sequential
from starfish.spots import AssignTargets, FindSpots, DecodeSpots
from starfish.image import ApplyTransform, LearnTransform, Filter
from starfish.types import Axes, Levels
from starfish.util.plot import diagnose_registration, imshow_plane, intensity_histogram, overlay_spot_calls
# load data
experiment = Experiment.from_json('https://d26bikfyahveg8.cloudfront.net/RNAScope/formatted/experiment.json')
imgs = experiment["fov_000"].get_image(FieldOfView.PRIMARY_IMAGES)
dapi = experiment["fov_000"].get_image('nuclei')
# register images
learn_translation = LearnTransform.Translation(reference_stack=dapi.sel({Axes.ROUND: 0}), axes=Axes.ROUND, upsampling=1000)
transforms_list = learn_translation.run(dapi)
registered_imgs = warp.run(imgs, transforms_list=transforms_list, in_place=False)
# white tophat filter
whitetophat = Filter.WhiteTophat(masking_radius=2, is_volume=False)
wth_imgs = whitetophat.run(registered_imgs, in_place=False)
# define blob detector for 2D images
bd = FindSpots.BlobDetector(
min_sigma=0.5,
max_sigma=2,
num_sigma=9,
threshold=0.2,
is_volume=False,
measurement_type='mean',
)
# run blob detector without reference_image
bd_spots = bd.run(image_stack=wth_imgs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment