Skip to content

Instantly share code, notes, and snippets.

@bennihepp
bennihepp / example.py
Created February 4, 2012 14:46
Proposal for a new decorator in pyramid or an extension
from pyramid_view_controller import view_controller
from ..models import Building, House, Factory, Skyscraper
class AbstractController(object):
# will not become a view because the class has no @view_controller decorator
@view_controller(name='view')
def view(self):
...
@bennihepp
bennihepp / script.py
Created January 20, 2012 09:41 — forked from thouis/script.py
Example script for CellProfiler RunScript module
import cpscript
from scipy import ndimage
# either ask explicitely for an object
labels = cpscript.objects['Cells'].segmented
# or ask the user to choose one
# cpscript.objects.input_objects.require('The objects from which to measure the distance')
#labels = cpscript.objects.input_objects.segmented
background_labels = np.array(labels == 0, dtype=int)
@bennihepp
bennihepp / textfield.patch
Created January 19, 2012 14:55
CellProfiler patch for changing the size of a cps.Text field
diff -ruN cellprofiler.orig/gui/moduleview.py cellprofiler/gui/moduleview.py
--- cellprofiler.orig/gui/moduleview.py 2012-01-13 10:01:00.632279000 +0100
+++ cellprofiler/gui/moduleview.py 2012-01-12 11:29:23.125876000 +0100
@@ -1066,6 +1066,9 @@
style = 0
if getattr(v, "multiline_display", False):
style = wx.TE_MULTILINE|wx.TE_PROCESS_ENTER
+ size = wx.DefaultSize
+ if getattr(v, "display_size", None) is not None:
+ size = wx.Size(v.display_size[0], v.display_size[1])
@bennihepp
bennihepp / script.py
Created January 19, 2012 10:00
Example script for CellProfiler RunScript module
from scipy import ndimage
labels = Cells.segmented
background_labels = np.array(labels == 0, dtype=int)
dt_labels = ndimage.distance_transform_edt(background_labels)
imVSVG_pixels = imVSVG.pixel_data
imVSVG_dt_pixels = imVSVG_pixels * dt_labels
imVSVG_dr_pixels = imVSVG_pixels / dt_labels
@bennihepp
bennihepp / config.cp
Created January 19, 2012 09:59
CellProfiler RunScript module configuration
RunScript:[module_num:23|svn_version:\'Unknown\'|variable_revision_number:1|show_window:False|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)]
Input image count:1
input object count:1
Input measurement count:0
Input constant count:0
Output image count:3
Output object count:0
Output measurement count:0
Run script in debug mode?:No
Load script script from a file?:Yes
@bennihepp
bennihepp / RunScript.py
Created January 19, 2012 09:51
CellProfiler module to execute small python scripts
'''<b>RunScript</b> - an easy way to write scripts for CellProfiler
<hr>
This module allows you to write small python scripts that are run as part
of the CellProfiler pipeline.
'''
#################################
#
# Imports from useful Python libraries
#
#################################