def test_allen_smFISH_cropped_data(): # set random seed to errors provoked by optimization functions np.random.seed(777) # load the experiment experiment = starfish.data.allen_smFISH(use_test_data=True) primary_image = experiment.fov().get_image(FieldOfView.PRIMARY_IMAGES) clip = Filter.Clip(p_min=10, p_max=100) clipped_image = clip.run(primary_image, in_place=False) bandpass = Filter.Bandpass(lshort=0.5, llong=7, threshold=0.0, truncate=4) bandpassed_image = bandpass.run(clipped_image, in_place=False) clip = Filter.Clip(p_min=10, p_max=100, is_volume=False) clipped_bandpassed_image = clip.run(bandpassed_image, in_place=False) sigma = (1, 0, 0) # filter only in z, do nothing in x, y glp = Filter.GaussianLowPass(sigma=sigma, is_volume=True) z_filtered_image = glp.run(clipped_bandpassed_image, in_place=False) tlmpf = FindSpots.TrackpyLocalMaxPeakFinder( spot_diameter=5, # must be odd integer min_mass=0.02, max_size=2, # this is max radius separation=7, noise_size=0.65, # this is not used because preprocess is False preprocess=False, percentile=10, # this is irrelevant when min_mass, spot_diameter, and max_size are set properly verbose=True, is_volume=True, ) spots = tlmpf.run(z_filtered_image) # noqa decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel( codebook=experiment.codebook, trace_building_strategy=TraceBuildingStrategies.SEQUENTIAL ) decoder.run(spots=spots)
from starfish.image import Filter from starfish.spots import FindSpots experiment = data.allen_smFISH(use_test_data=True) img = experiment['fov_001'].get_image(FieldOfView.PRIMARY_IMAGES) # filter to remove noise, remove background, blur, and clip bandpass = Filter.Bandpass(lshort=.5, llong=7, threshold=0.0) glp = Filter.GaussianLowPass( sigma=(1, 0, 0), is_volume=True ) clip1 = Filter.Clip(p_min=50, p_max=100) clip2 = Filter.Clip(p_min=99, p_max=100, is_volume=True) clip1.run(img, in_place=True) bandpass.run(img, in_place=True) glp.run(img, in_place=True) clip2.run(img, in_place=True) tlmpf = FindSpots.TrackpyLocalMaxPeakFinder( spot_diameter=5, # must be odd integer min_mass=0.02, max_size=2, # this is max radius separation=7, preprocess=False, percentile=10, # this has no effect when min_mass, spot_diameter, and max_size are set properly verbose=True, ) spots = tlmpf.run(img)
threshold=0.1, is_volume=True, measurement_type='mean', ) lmp = FindSpots.LocalMaxPeakFinder(min_distance=2, stringency=8, min_obj_area=6, max_obj_area=600, is_volume=True) tlmpf = FindSpots.TrackpyLocalMaxPeakFinder( spot_diameter=11, min_mass=0.2, max_size=8, separation=3, preprocess=False, percentile=80, verbose=True, ) # crop imagestacks crop_selection = {Axes.X: (300, 700), Axes.Y: (300, 700)} cropped_imgs = imgs.sel(crop_selection) cropped_dots = dots.sel(crop_selection) # find spots on cropped images bd_spots = bd.run(image_stack=cropped_imgs, reference_image=cropped_dots) lmp_spots = lmp.run(image_stack=cropped_imgs, reference_image=cropped_dots) tlmpf_spots = tlmpf.run(image_stack=cropped_imgs, reference_image=cropped_dots)