Skip to content

Instantly share code, notes, and snippets.

@thouis
Forked from bennihepp/script.py
Created January 19, 2012 15:28
Show Gist options
  • Save thouis/1640599 to your computer and use it in GitHub Desktop.
Save thouis/1640599 to your computer and use it in GitHub Desktop.
Example script for CellProfiler RunScript module
import cpscript
from scipy import ndimage
labels = cpscript.Cells.segmented
background_labels = np.array(labels == 0, dtype=int)
dt_labels = ndimage.distance_transform_edt(background_labels)
imVSVG_pixels = cpscript.imVSVG.pixel_data
imVSVG_dt_pixels = imVSVG_pixels * dt_labels
imVSVG_dr_pixels = imVSVG_pixels / dt_labels
imVSVG_dr_pixels[dt_labels == 0] = imVSVG_pixels[dt_labels == 0]
cpscript.imVSVG_dr_pixels.pixel_data = imVSVG_dr_pixels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment