Skip to content
Browse files

Merge branch 'master' of git://github.com/CellProfiler/CellProfiler

  • Loading branch information...
2 parents ebed3ad + bc75c3c commit 22642a649a94dca131c7626039c97488feddd696 @LeeKamentsky LeeKamentsky committed Sep 19, 2012
View
9 cellprofiler/modules/identifyprimaryobjects.py
@@ -4,18 +4,19 @@
This module identifies primary objects in grayscale images
containing bright objects on a dark background. Primary objects (e.g., nuclei) are those that can be found in an image without using any corresponding reference image. By contrast, secondary objects are those that are found using previously-identified primary objects as a reference.
-After processing, the window for this module will
-show objects outlined in three colors:
+After processing, the module display window for this module will
+show a panel with objects outlined in three colors:
<ul>
<li>Green: Acceptable; passed all criteria</li>
<li>Red: Discarded based on size</li>
<li>Yellow: Discarded due to touching the border</li>
</ul>
+If you need to change the outline colors (e.g., due to color-blindness), you can
+make adjustments in <i>File > Preferences</i>.
The module window will also show another image where the identified
objects are displayed with arbitrary colors: the colors themselves do not mean
-anything but simply help you distingush the various objects. You can
-change the colormap in <i>File > Preferences</i>.
+anything but simply help you distingush the various objects.
Steps to prepare images for this module:
<ul>
View
31 cellprofiler/modules/identifysecondaryobjects.py
@@ -22,17 +22,28 @@
for secondary objects, except when using the <i>Distance - N</i> option.</li>
</ol>
+After processing, the module display window for this module will
+show panels with objects outlined in two colors:
+<ul>
+<li>Green: Primary objects</li>
+<li>Red: Secondary objects</li>
+</ul>
+If you need to change the outline colors (e.g., due to color-blindness), you can
+make adjustments in <i>File > Preferences</i>.
+
+The module window will also show another image where the identified
+objects are displayed with arbitrary colors: the colors themselves do not mean
+anything but simply help you distingush the various objects.
+
<h3>Technical notes</h3>
-The <i>Propagation</i> algorithm labels from LABELS_IN to LABELS_OUT, steered by
-IMAGE and limited to MASK. MASK should be a logical array. &lambda; is a
-regularization parameter, larger being closer to Euclidean distance in
-the image plane, and zero being entirely controlled by IMAGE. Propagation
-of labels is by shortest path to a nonzero label in LABELS_IN. Distance
-is the sum of absolute differences in the image in a 3x3 neighborhood, combined
-with &lambda; via sqrt(differences<sup>2</sup> + &lambda;<sup>2</sup>). Note that
-there is no separation between adjacent areas with different labels (as there
-would be using, e.g., watershed). Such boundaries must be added in a
-postprocess.
+The <i>Propagation</i> algorithm creates a set of secondary object labels using
+each primary object as a "seed", guided by the input image and limited to the
+foreground region as determined by the chosen thresholding method. &lambda; is
+a regularization parameter; see the help for the setting for more details. Propagation
+of secondary object labels is by the shortest path to an adjacent primary object
+from the starting ("seeding") primary object. The seed-to-pixel distances are
+calculated as the sum of absolute differences in a 3x3 (8-connected) image
+neighborhood, combined with &lambda; via sqrt(differences<sup>2</sup> + &lambda;<sup>2</sup>).
<h4>Available measurements</h4>
<ul>
View
61 cellprofiler/modules/relateobjects.py
@@ -219,6 +219,9 @@ def visible_settings(self):
result += [self.add_step_parent_button]
return result
+ def is_interactive(self):
+ return False
+
def run(self, workspace):
parents = workspace.object_set.get_objects(self.parent_name.value)
children = workspace.object_set.get_objects(self.sub_object_name.value)
@@ -278,23 +281,47 @@ def run(self, workspace):
self.calculate_minimum_distances(workspace, parent_name)
if workspace.frame is not None:
- figure = workspace.create_or_find_figure(title="RelateObjects, image cycle #%d"%(
- workspace.measurements.image_set_number),subplots=(2,2))
- figure.subplot_imshow_labels(0,0,parents.segmented,
- title = self.parent_name.value)
- figure.subplot_imshow_labels(1,0,children.segmented,
- title = self.sub_object_name.value,
- sharex = figure.subplot(0,0),
- sharey = figure.subplot(0,0))
- parent_labeled_children = np.zeros(children.segmented.shape, int)
- parent_labeled_children[children.segmented > 0] = \
- parents_of[children.segmented[children.segmented > 0]-1]
- figure.subplot_imshow_labels(0,1,parent_labeled_children,
- "%s labeled by %s"%
- (self.sub_object_name.value,
- self.parent_name.value),
- sharex = figure.subplot(0,0),
- sharey = figure.subplot(0,0))
+ workspace.display_data.parent_count = parents.count
+ workspace.display_data.parent_labels = parents.segmented
+ workspace.display_data.child_count = children.count
+ workspace.display_data.child_labels = children.segmented
+ workspace.display_data.parents_of = parents_of
+
+ def display(self, workspace):
+ from cellprofiler.gui.cpfigure_tools import renumber_labels_for_display
+ figure = workspace.create_or_find_figure(subplots=(2,2))
+ renumbered_parent_labels = renumber_labels_for_display(
+ workspace.display_data.parent_labels)
+ child_labels = workspace.display_data.child_labels
+ parents_of = workspace.display_data.parents_of
+ #
+ # discover the mapping so that we can apply it to the children
+ #
+ mapping = np.arange(workspace.display_data.parent_count+1)
+ mapping[workspace.display_data.parent_labels.flatten()] = \
+ renumbered_parent_labels.flatten()
+ parent_labeled_children = np.zeros(child_labels.shape, int)
+ mask = child_labels > 0
+ parent_labeled_children[mask] = \
+ mapping[parents_of[child_labels[mask] - 1]]
+
+ figure.subplot_imshow_labels(
+ 0, 0, renumbered_parent_labels,
+ title = self.parent_name.value,
+ renumber=False)
+ figure.subplot_imshow_labels(
+ 1, 0, child_labels,
+ title = self.sub_object_name.value,
+ sharex = figure.subplot(0,0),
+ sharey = figure.subplot(0,0))
+ figure.subplot_imshow_labels(
+ 0, 1, parent_labeled_children,
+ "%s labeled by %s"%
+ (self.sub_object_name.value,
+ self.parent_name.value),
+ renumber=False,
+ sharex = figure.subplot(0,0),
+ sharey = figure.subplot(0,0))
def get_parent_names(self):
'''Get the names of parents to be measured for distance'''
View
14 cellprofiler/modules/straightenworms.py
@@ -45,6 +45,7 @@
__version__="$Revision: 10717 %"
import numpy as np
+import os
from scipy.interpolate import interp1d
from scipy.interpolate.fitpack import bisplrep, dblint
from scipy.ndimage import map_coordinates, extrema
@@ -275,6 +276,13 @@ def visible_settings(self):
result += [ self.add_image_button ]
return result
+ def validate_module(self, pipeline):
+ path = os.path.join(self.training_set_directory.get_absolute_path(),
+ self.training_set_file_name.value)
+ if not os.path.exists(path):
+ raise cps.ValidationError("Can't find file %s" % self.training_set_file_name.value,
+ self.training_set_file_name)
+
def prepare_settings(self, setting_values):
nimages = int(setting_values[IDX_IMAGE_COUNT])
del self.images[1:]
@@ -476,9 +484,9 @@ def sort_fn(a,b):
def read_params(self, workspace):
'''Read the training params or use the cached value'''
d = self.get_dictionary(workspace.image_set_list)
- if "training_params" in d:
- return d["training_params"]
- params = d["training_params"] = {}
+ if "training_params" not in d:
+ d["training_params"] = {}
+ params = d["training_params"]
params = read_params(self.training_set_directory,
self.training_set_file_name,
params)
View
2 cellprofiler/modules/tests/test_straightenworms.py
@@ -173,7 +173,7 @@ def __init__(self):
module.training_set_directory.custom_path = "http://www.cellprofiler.org"
module.training_set_file_name.value = "TrainingSet.xml"
module.get_dictionary = lambda dummy: {
- "training_params" : P()}
+ "training_params" : { "TrainingSet.xml": (P(), "URL")} }
pipeline = cpp.Pipeline()
pipeline.add_module(module)
View
7 cellprofiler/objects.py
@@ -263,12 +263,7 @@ def get_small_removed_segmented(self):
"""
if self.__small_removed_segmented != None:
return self.__small_removed_segmented
- if self.__segmented != None:
- if self.has_unedited_segmented():
- return self.__unedited_segmented
- # If there's only a segmented, then there is no junk.
- return self.__segmented
- return self.__small_removed_segmented
+ return self.unedited_segmented
def set_small_removed_segmented(self,labels):
check_consistency(self.__segmented, self.__unedited_segmented, labels)
View
1 python-2.6.sh
@@ -2,6 +2,7 @@
. /broad/tools/scripts/useuse
reuse .toolbox-0.11.0
+reuse .cython-0.17-toolbox-0.11.0
export PYTHONPATH=$PYTHONPATH:/imaging/analysis/People/imageweb/batchprofiler/cgi-bin/CellProfiler2.0/python/lib/Python2.6/site-packages
export MPLCONFIGDIR=/imaging/analysis/CPCluster/CellProfiler-2.0/.matplotlib
export LAST_CHECKOUT=`echo "import os;cpdir='/imaging/analysis/CPCluster/CellProfiler-2.0';print os.path.join(cpdir,str(max(*[int(x) for x in os.listdir(cpdir) if x.isdigit()])))" | python`

0 comments on commit 22642a6

Please sign in to comment.
Something went wrong with that request. Please try again.