def test_cache_merfish(tmpdir, name, expected, config, monkeypatch): cache_enabled = (0 != config["slicedimage"]["caching"].get( "size_limit", None)) if cache_enabled: config["slicedimage"]["caching"]["directory"] = str(tmpdir / "caching") with monkeypatch.context() as mc: setup_config(config, tmpdir, mc) # Run 1 data.MERFISH(use_test_data=True).fov().get_image("primary") # Run 2 if cache_enabled: data.MERFISH(use_test_data=True).fov().get_image("primary") # Check constraints if cache_enabled: # Enforce smallest size cache = Cache(str(tmpdir / "caching")) cache.cull() cache_size = get_size(tmpdir / "caching") min, max = expected assert (min <= cache_size) and (cache_size <= max)
marked as not passing thresholds in the :py:class:`.DecodedIntensityTable`. In addition, the results from connected component analysis that do not fit in the :py:class:`.DecodedIntensityTable` (e.g. spot attributes and labeled images) are returned in a :py:class:`.ConnectedComponentDecodingResult`. """ import matplotlib.pyplot as plt import numpy as np from copy import deepcopy from starfish import data, FieldOfView, display from starfish.image import Filter from starfish.spots import DetectPixels from starfish.types import Axes, Features, Levels # Load MERFISH data experiment = data.MERFISH(use_test_data=True) imgs = experiment.fov().get_image(FieldOfView.PRIMARY_IMAGES) # filter and deconvolve data ghp = Filter.GaussianHighPass(sigma=3) dpsf = Filter.DeconvolvePSF(num_iter=15, sigma=2, level_method=Levels.SCALE_SATURATED_BY_CHUNK) glp = Filter.GaussianLowPass(sigma=1) ghp.run(imgs, in_place=True) dpsf.run(imgs, in_place=True) glp.run(imgs, in_place=True) # scale data with user-defined factors to normalize images. For this data set, the scale factors # are stored in experiment.json. scale_factors = {(t[Axes.ROUND], t[Axes.CH]): t['scale_factor']
create a gene expression matrix. It then provides a couple examples how cell metadata can be added to the :py:class:`.ExpressionMatrix` and how the matrix can be saved for loading into other analysis tools. """ # Load MERFISH data import os import numpy as np from copy import deepcopy from starfish import BinaryMaskCollection, data from starfish.core.experiment.experiment import FieldOfView from starfish.image import Filter from starfish.spots import DetectPixels, AssignTargets from starfish.types import Axes, Features, Levels experiment = data.MERFISH() fov = experiment["fov_000"] imgs = experiment.fov().get_image(FieldOfView.PRIMARY_IMAGES) dapi = fov.get_image("nuclei") # nuclei # filter and deconvolve data ghp = Filter.GaussianHighPass(sigma=3) dpsf = Filter.DeconvolvePSF(num_iter=15, sigma=2, level_method=Levels.SCALE_SATURATED_BY_CHUNK) glp = Filter.GaussianLowPass(sigma=1) ghp.run(imgs, in_place=True) dpsf.run(imgs, in_place=True) glp.run(imgs, in_place=True) # scale data with user-defined factors to normalize images. For this data set, the scale factors # are stored in experiment.json. scale_factors = {
matplotlib.rcParams["figure.dpi"] = 150 ################################################################################################### # Load Data # --------- # The example data here correspond to DARTFISHv1 2017. The data represent human brain tissue from # the human occipital cortex from 1 field of view (FOV) of larger experiment. The data from one # field of view correspond to 18 images from 6 imaging rounds (r) 3 color channels (c) and 1 z-plane # (z). Each image is 988x988 (y,x) import pprint from starfish import data from starfish import FieldOfView experiment = data.MERFISH(use_test_data=False) pp = pprint.PrettyPrinter(indent=2) pp.pprint(experiment._src_doc) # note the structure of the 5D tensor containing the raw imaging data imgs = experiment.fov().get_image(FieldOfView.PRIMARY_IMAGES) print(imgs) ################################################################################################### # Visualize codebook # ------------------ # The MERFISH codebook maps each barcode to a gene (or blank) feature. The barcodes are 16 bit # vectors that can be read out, for each pixel, from the 8 rounds and 2 color channels. The codebook # contains a precise specification of how each of these 16 bit barcode vectors relate to the 5D # tensor of raw image data.