Skip to content

Instantly share code, notes, and snippets.

@mattcai
Last active April 10, 2020 17:22
Show Gist options
  • Save mattcai/53eb5e4e12c82ba42951acb50dfd557d to your computer and use it in GitHub Desktop.
Save mattcai/53eb5e4e12c82ba42951acb50dfd557d to your computer and use it in GitHub Desktop.
starfish TransformsList modified by ApplyTransform.Warp.run()
# %matplotlib inline
# %gui qt
from starfish import Experiment, FieldOfView, display
from starfish.image import ApplyTransform, LearnTransform
from starfish.types import Axes
# load RNAScope 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')
# learn transforms
learn_translation = LearnTransform.Translation(reference_stack=dapi.sel({Axes.ROUND: 0}), axes=Axes.ROUND, upsampling=1000)
transforms_list = learn_translation.run(dapi)
# transforms before applying
print(transforms_list)
# apply transform
warp = ApplyTransform.Warp()
warp.run(imgs, transforms_list=transforms_list, in_place=True)
# transforms after applying
print(transforms_list)
# now applying transform throws error
warp.run(dapi, transforms_list=transforms_list, in_place=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment