Beispiel #1
0
 def run():
     app = QApplication.instance() or QApplication([])
     viewer = napari.Viewer()
     timer = QTimer()
     timer.setInterval(500)
     timer.timeout.connect(viewer.window.close)
     timer.timeout.connect(app.quit)
     timer.start()
     display(stack, spots, masks, viewer=viewer)
     app.exec_()
Beispiel #2
0
def test_display(qtbot, stack, spots, masks):
    from napari import Viewer

    viewer = Viewer()
    view = viewer.window.qt_viewer
    qtbot.addWidget(view)

    if stack is None and spots is None and masks is None:
        with pytest.raises(TypeError):
            display(stack, spots, masks, viewer=viewer)
    else:
        display(stack, spots, masks, viewer=viewer)
Beispiel #3
0
use_test_data = os.getenv("USE_TEST_DATA") is not None
experiment = data.MERFISH(use_test_data=use_test_data)
# EPY: END code

# EPY: START markdown
#Individual imaging rounds and channels can also be visualized
# EPY: END markdown

# EPY: START code
primary_image = experiment.fov().get_image(FieldOfView.PRIMARY_IMAGES)
# EPY: END code

# EPY: START code
# Display the data
# EPY: ESCAPE %gui qt5
display(primary_image)
# EPY: END code

# EPY: START markdown
### Show input file format that specifies how the tiff stack is organized
#
#The stack contains multiple images corresponding to the channel and imaging rounds. MERFISH builds a 16 bit barcode from 8 imaging rounds, each of which measures two channels that correspond to contiguous (but not necessarily consistently ordered) bits of the barcode.
#
#The MERFISH computational pipeline also constructs a scalar that corrects for intensity differences across each of the 16 images, e.g., one scale factor per bit position.
#
#The stacks in this example are pre-registered using fiduciary beads.
# EPY: END markdown

# EPY: START code
pp = pprint.PrettyPrinter(indent=2)
pp.pprint(experiment._src_doc)
Beispiel #4
0
        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


# EPY: END code

# EPY: START markdown
### Run the pipeline on a field of view
# EPY: END markdown

# EPY: START code
experiment = starfish.data.allen_smFISH(use_test_data=True)

image, intensities = processing_pipeline(experiment, fov_name='fov_001')
# EPY: END code

# EPY: START markdown
### Display the results
# EPY: END markdown

# EPY: START code
viewer = starfish.display(image, intensities)
# EPY: END code
Beispiel #5
0
from functools import partial
# EPY: END code

# EPY: START markdown
#If desired, the background that is being subtracted can be visualized
# EPY: END markdown

# EPY: START code
opening = partial(opening, selem=disk(3))

background = img.apply(opening,
                       group_by={Axes.ROUND, Axes.CH, Axes.ZPLANE},
                       verbose=False,
                       in_place=False)

starfish.display(background)
# EPY: END code

# EPY: START code
wth = starfish.image.Filter.WhiteTophat(masking_radius=3)
background_corrected = wth.run(img, in_place=False)
starfish.display(background_corrected)
# EPY: END code

# EPY: START markdown
### Scale images to equalize spot intensities across channels
#
#The number of peaks are not uniform across rounds and channels, which prevents histogram matching across channels. Instead, a percentile value is identified and set as the maximum across channels, and the dynamic range is extended to equalize the channel intensities
# EPY: END markdown

# EPY: START code
# EPY: END markdown

# EPY: START code
use_test_data = os.getenv("USE_TEST_DATA") is not None
exp = data.DARTFISH(use_test_data=use_test_data)

stack = exp.fov().get_image(FieldOfView.PRIMARY_IMAGES)
# EPY: END code

# EPY: START code
print(stack.shape)
# EPY: END code

# EPY: START code
# EPY: ESCAPE %gui qt5
display(stack)
# EPY: END code

# EPY: START markdown
#### Load codebook
# EPY: END markdown

# EPY: START code
exp.codebook
# EPY: END code

# EPY: START markdown
#### Load copy number benchmark results
# EPY: END markdown

# EPY: START code
Beispiel #7
0
# EPY: START code
# EPY: ESCAPE %gui qt
# EPY: END code

# EPY: START code
experiment = starfish.data.STARmap(use_test_data=True)
stack = experiment['fov_000'].get_image('primary')
# EPY: END code

# EPY: START code
# look at the channel/round projection
ch_r_projection = stack.max_proj(Axes.CH, Axes.ROUND)
# EPY: END code

# EPY: START code
starfish.display(ch_r_projection)
# EPY: END code

# EPY: START markdown
#It actually looks like there is a small shift approximately the size of a spot in the `x = -y` direction for at least one (round, channel) pair (see top left corner for most obvious manifestation).
#
#Attempt a translation registration to fix.
# EPY: END markdown

# EPY: START code
# Starmap only requires translation. Verify that things are registered with a quick
# similarity registration.

from skimage.feature import register_translation
from skimage.transform import SimilarityTransform
Beispiel #8
0
from functools import partial
# EPY: END code

# EPY: START markdown
#If desired, the background that is being subtracted can be visualized
# EPY: END markdown

# EPY: START code
opening = partial(opening, selem=disk(3))

background = img.apply(
    opening,
    group_by={Axes.ROUND, Axes.CH, Axes.ZPLANE}, verbose=False, in_place=False
)

starfish.display(background)
# EPY: END code

# EPY: START code
wth = starfish.image.Filter.WhiteTophat(masking_radius=3)
background_corrected = wth.run(img, in_place=False)
starfish.display(background_corrected)
# EPY: END code

# EPY: START markdown
### Scale images to equalize spot intensities across channels
#
#The number of peaks are not uniform across rounds and channels, which prevents histogram matching across channels. Instead, a percentile value is identified and set as the maximum across channels, and the dynamic range is extended to equalize the channel intensities
# EPY: END markdown

# EPY: START code