-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a standard starfish.wdl that can be run with any recipe file #1364
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Starfish.experiment": "https://d2nhj9g34unfro.cloudfront.net/browse/formatted/iss/20190506/experiment.json", | ||
"Starfish.num_fovs": 15, | ||
"Starfish.recipe_file": "https://raw.githubusercontent.com/spacetx/starfish/master/workflows/wdl/iss_published/recipe.py" | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||||
import starfish | ||||||
from starfish import FieldOfView | ||||||
from starfish.image import Filter | ||||||
from starfish.image import ApplyTransform, LearnTransform | ||||||
from starfish.spots import DetectSpots | ||||||
from starfish.types import Axes | ||||||
|
||||||
|
||||||
def process_fov(field_num: int, experiment_str: str): | ||||||
"""Process a single field of view of ISS data | ||||||
Parameters | ||||||
---------- | ||||||
field_num : int | ||||||
the field of view to process | ||||||
experiment_str : int | ||||||
path of experiment json file | ||||||
|
||||||
Returns | ||||||
------- | ||||||
DecodedSpots : | ||||||
tabular object containing the locations of detected spots. | ||||||
""" | ||||||
|
||||||
fov_str: str = f"fov_{int(field_num):03d}" | ||||||
|
||||||
# load experiment | ||||||
experiment = starfish.Experiment.from_json(experiment_str) | ||||||
|
||||||
print(f"loading fov: {fov_str}") | ||||||
fov = experiment[fov_str] | ||||||
|
||||||
# note the structure of the 5D tensor containing the raw imaging data | ||||||
imgs = fov.get_image(FieldOfView.PRIMARY_IMAGES) | ||||||
dots = fov.get_image("dots") | ||||||
nuclei = fov.get_image("nuclei") | ||||||
|
||||||
masking_radius = 15 | ||||||
print("Filter WhiteTophat") | ||||||
filt = Filter.WhiteTophat(masking_radius, is_volume=False) | ||||||
|
||||||
filtered_imgs = filt.run(imgs, verbose=True, in_place=False) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider moving the registration to before filtering so you can do inplace processing. |
||||||
filt.run(dots, verbose=True, in_place=True) | ||||||
filt.run(nuclei, verbose=True, in_place=True) | ||||||
|
||||||
print("Learning Transform") | ||||||
learn_translation = LearnTransform.Translation(reference_stack=dots, axes=Axes.ROUND, upsampling=1000) | ||||||
transforms_list = learn_translation.run(imgs.max_proj(Axes.CH, Axes.ZPLANE)) | ||||||
|
||||||
print("Applying transform") | ||||||
warp = ApplyTransform.Warp() | ||||||
registered_imgs = warp.run(filtered_imgs, transforms_list=transforms_list, in_place=False, verbose=True) | ||||||
|
||||||
print("Detecting") | ||||||
p = DetectSpots.BlobDetector( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
min_sigma=1, | ||||||
max_sigma=10, | ||||||
num_sigma=30, | ||||||
threshold=0.01, | ||||||
measurement_type='mean', | ||||||
) | ||||||
|
||||||
intensities = p.run(registered_imgs, blobs_image=dots, blobs_axes=(Axes.ROUND, Axes.ZPLANE)) | ||||||
|
||||||
decoded = experiment.codebook.decode_per_round_max(intensities) | ||||||
df = decoded.to_decoded_spots() | ||||||
return df | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add nl. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Starfish.experiment": "https://d2nhj9g34unfro.cloudfront.net/browse/formatted/iss/20190506/experiment.json", | ||
"Starfish.num_fovs": 2, | ||
"Starfish.recipe_file": "https://raw.githubusercontent.com/spacetx/starfish/master/workflows/wdl/iss_published/recipe.py" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Starfish.experiment": "https://d2nhj9g34unfro.cloudfront.net/xiaoyan_qian/ISS_human_HCA_07_MultiFOV/main_files/experiment.json", | ||
"Starfish.num_fovs": 539, | ||
"Starfish.recipe_file": "https://raw.githubusercontent.com/spacetx/starfish/master/workflows/wdl/iss_spaceTX/recipe.py" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
import starfish | ||
from starfish.types import Axes | ||
|
||
|
||
def process_fov(field_num: int, experiment_str: str): | ||
"""Process a single field of view of ISS data | ||
Parameters | ||
---------- | ||
field_num : int | ||
the field of view to process | ||
experiment_str : int | ||
path of experiment json file | ||
|
||
Returns | ||
------- | ||
DecodedSpots : | ||
tabular object containing the locations of detected spots. | ||
""" | ||
fov_str: str = f"fov_{int(field_num):03d}" | ||
|
||
# load experiment | ||
experiment = starfish.Experiment.from_json(experiment_str) | ||
|
||
fov = experiment[fov_str] | ||
imgs = fov.get_image(starfish.FieldOfView.PRIMARY_IMAGES) | ||
dots = imgs.max_proj(Axes.CH) | ||
|
||
# filter | ||
filt = starfish.image.Filter.WhiteTophat(masking_radius=15, is_volume=False) | ||
filtered_imgs = filt.run(imgs, verbose=True, in_place=False) | ||
filt.run(dots, verbose=True, in_place=True) | ||
|
||
# find threshold | ||
tmp = dots.sel({Axes.ROUND:0, Axes.CH:0, Axes.ZPLANE:0}) | ||
dots_threshold = np.percentile(np.ravel(tmp.xarray.values), 50) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is incompatible with the pipeline architecture. do we have an issue for fixing this? |
||
|
||
# find spots | ||
p = starfish.spots.DetectSpots.BlobDetector( | ||
min_sigma=1, | ||
max_sigma=10, | ||
num_sigma=30, | ||
threshold=dots_threshold, | ||
measurement_type='mean', | ||
) | ||
|
||
# blobs = dots; define the spots in the dots image, but then find them again in the stack. | ||
intensities = p.run(filtered_imgs, blobs_image=dots, blobs_axes=(Axes.ROUND, Axes.ZPLANE)) | ||
|
||
# decode | ||
decoded = experiment.codebook.decode_per_round_max(intensities) | ||
|
||
# save results | ||
df = decoded.to_decoded_spots() | ||
return df |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Starfish.experiment": "https://d2nhj9g34unfro.cloudfront.net/xiaoyan_qian/ISS_human_HCA_07_MultiFOV/main_files/experiment.json", | ||
"Starfish.num_fovs": 2, | ||
"Starfish.recipe_file": "https://raw.githubusercontent.com/spacetx/starfish/master/workflows/wdl/iss_spaceTX/recipe.py" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Starfish.experiment": "https://d2nhj9g34unfro.cloudfront.net/browse/formatted/MERFISH/20190511/experiment.json", | ||
"Starfish.num_fovs": 495, | ||
"Starfish.recipe_file": "https://raw.githubusercontent.com/spacetx/starfish/saxelrod-standard-wdl/workflows/wdl/merfish_published/recipe.py" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just do: