Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 27dc261b318aec869e9ee31aeba86d2b655c6d6b 2 parents 28e0992 + 3b0a2ed
@LeeKamentsky LeeKamentsky authored
View
186 cellprofiler/modules/correctilluminationcalculate.py
@@ -89,96 +89,106 @@ def create_settings(self):
provided_attributes={cps.AGGREGATE_IMAGE_ATTRIBUTE:True,
cps.AVAILABLE_ON_LAST_ATTRIBUTE:False })
- self.intensity_choice = cps.Choice("Select how the illumination function is calculated",
- [IC_REGULAR, IC_BACKGROUND],
- IC_REGULAR, doc = '''
- Do you want to calculate using regular intensities or background intensities?<br>
- <ul>
- <li><i>Regular:</i> If you have objects that are evenly dispersed across your image(s) and
- cover most of the image, the <i>Regular</i> method might be appropriate. Regular
- intensities makes the illumination function based on the intensity at
- each pixel of the image (or group of images if you are in <i>All</i> mode) and
- is most often rescaled (see below) and applied by division using
- <b>CorrectIlluminationApply.</b> Note that if you are in <i>Each</i> mode or using a
- small set of images with few objects, there will be regions in the
- average image that contain no objects and smoothing by median filtering
- is unlikely to work well.
- <i>Note:</i> it does not make sense to choose (<i>Regular + No Smoothing + Each</i>)
- because the illumination function would be identical to the original
- image and applying it will yield a blank image. You either need to smooth
- each image, or you need to use <i>All</i> images.</li>
- <li><i>Background intensities:</i>
- If you think that the background (dim points) between objects show the
- same pattern of illumination as your objects of interest, you can choose the
- <i>Background</i> method. Background intensities finds the minimum pixel
- intensities in blocks across the image (or group of images if you are in
- <i>All</i> mode) and is most often applied by subtraction using the
- <b>CorrectIlluminationApply</b> module.
- <i>Note:</i> if you will be using the <i>Subtract</i> option in the
- <b>CorrectIlluminationApply</b> module, you almost certainly do not want to
- <i>Rescale</i>. </li>
- </ul> ''')
-
- self.dilate_objects = cps.Binary("Dilate objects in the final averaged image?",False, doc = '''
- <i>(Used only if the Regular method is selected)</i><br>
- Do you want to dilate objects in the final averaged image?
- For some applications, the incoming images are binary and each object
- should be dilated with a Gaussian filter in the final averaged
- (projection) image. This is for a sophisticated method of illumination
- correction where model objects are produced.''')
-
- self.object_dilation_radius = cps.Integer("Dilation radius",1,0,doc='''
- <i>(Used only if the Regular method and dilation is selected)</i><br>
- This value should be roughly equal to the original radius of the objects''')
-
- self.block_size = cps.Integer("Block size",60,1,doc = '''
- <i>(Used only if Background is selected)</i><br>
- The block size should be large enough that every square block of pixels is likely
- to contain some background pixels, where no objects are located.''')
-
- self.rescale_option = cps.Choice("Rescale the illumination function?",
- [cps.YES, cps.NO, RE_MEDIAN], doc = '''
- The illumination function can be rescaled so that the pixel intensities
- are all equal to or greater than 1. Rescaling is recommended if you plan to
- use the <i>Regular</i> method (and hence, the <i>Division</i> option in
- <b>CorrectIlluminationApply</b>) so that the corrected images are in the
- range 0 to 1. It is not recommended if you plan to use the <i>Background</i>
- method, which is paired with the <i>Subtract</i> option in <b>CorrectIlluminationApply</b>.
- Note that as a result of the illumination function being rescaled from 1 to
- infinity, the rescaling of each image might be dramatic if there is substantial
- variation across the field of view, causing the corrected images
- to be very dark. The <i>Median</i> option chooses the median value in the
- image to rescale so that division increases some values and decreases others.''')
+ self.intensity_choice = cps.Choice(
+ "Select how the illumination function is calculated",
+ [IC_REGULAR, IC_BACKGROUND],
+ IC_REGULAR, doc = '''
+ Do you want to calculate using regular intensities or background intensities?<br>
+ <ul>
+ <li><i>Regular:</i> If you have objects that are evenly dispersed across your image(s) and
+ cover most of the image, the <i>Regular</i> method might be appropriate. Regular
+ intensities makes the illumination function based on the intensity at
+ each pixel of the image (or group of images if you are in <i>All</i> mode) and
+ is most often rescaled (see below) and applied by division using
+ <b>CorrectIlluminationApply.</b> Note that if you are in <i>Each</i> mode or using a
+ small set of images with few objects, there will be regions in the
+ average image that contain no objects and smoothing by median filtering
+ is unlikely to work well.
+ <i>Note:</i> it does not make sense to choose (<i>Regular + No Smoothing + Each</i>)
+ because the illumination function would be identical to the original
+ image and applying it will yield a blank image. You either need to smooth
+ each image, or you need to use <i>All</i> images.</li>
+ <li><i>Background intensities:</i>
+ If you think that the background (dim points) between objects show the
+ same pattern of illumination as your objects of interest, you can choose the
+ <i>Background</i> method. Background intensities finds the minimum pixel
+ intensities in blocks across the image (or group of images if you are in
+ <i>All</i> mode) and is most often applied by subtraction using the
+ <b>CorrectIlluminationApply</b> module.
+ <i>Note:</i> if you will be using the <i>Subtract</i> option in the
+ <b>CorrectIlluminationApply</b> module, you almost certainly do not want to
+ <i>Rescale</i>. </li>
+ </ul>
+ <p>Please note that if a mask was applied to the input image, the pixels outside of the
+ mask will be exlcuded from consideration. This is useful, for instance, in cases where
+ you have masked out the well edge in an image from a multi-well plate; the dark well
+ edge would distort the illumination correction function along the interior well edge.
+ Masking the image beforehand solves this problem.</p>''')
+
+ self.dilate_objects = cps.Binary(
+ "Dilate objects in the final averaged image?",False, doc = '''
+ <i>(Used only if the Regular method is selected)</i><br>
+ Do you want to dilate objects in the final averaged image?
+ For some applications, the incoming images are binary and each object
+ should be dilated with a Gaussian filter in the final averaged
+ (projection) image. This is for a sophisticated method of illumination
+ correction where model objects are produced.''')
+
+ self.object_dilation_radius = cps.Integer(
+ "Dilation radius",1,0,doc='''
+ <i>(Used only if the Regular method and dilation is selected)</i><br>
+ This value should be roughly equal to the original radius of the objects''')
+
+ self.block_size = cps.Integer(
+ "Block size",60,1,doc = '''
+ <i>(Used only if Background is selected)</i><br>
+ The block size should be large enough that every square block of pixels is likely
+ to contain some background pixels, where no objects are located.''')
+
+ self.rescale_option = cps.Choice(
+ "Rescale the illumination function?",
+ [cps.YES, cps.NO, RE_MEDIAN], doc = '''
+ The illumination function can be rescaled so that the pixel intensities
+ are all equal to or greater than 1. Rescaling is recommended if you plan to
+ use the <i>Regular</i> method (and hence, the <i>Division</i> option in
+ <b>CorrectIlluminationApply</b>) so that the corrected images are in the
+ range 0 to 1. It is not recommended if you plan to use the <i>Background</i>
+ method, which is paired with the <i>Subtract</i> option in <b>CorrectIlluminationApply</b>.
+ Note that as a result of the illumination function being rescaled from 1 to
+ infinity, the rescaling of each image might be dramatic if there is substantial
+ variation across the field of view, causing the corrected images
+ to be very dark. The <i>Median</i> option chooses the median value in the
+ image to rescale so that division increases some values and decreases others.''')
self.each_or_all = cps.Choice(
- "Calculate function for each image individually, or based on all images?",
- [EA_EACH, EA_ALL_FIRST, EA_ALL_ACROSS], doc = '''
- Calculate a separate function for each image, or one for all the images?
- You can calculate the illumination function using just the current
- image or you can calculate the illumination function using all of
- the images in each group.
- The illumination function can be calculated in one of the three ways:
- <ul>
- <li><i>%(EA_EACH)s:</i> Calculate an illumination function for each image
- individually. </li>
- <li><i>%(EA_ALL_FIRST)s:</i> Calculate an illumination
- function based on all of the images in a group, performing the
- calculation before proceeding to the next module. This means that the
- illumination function will be created in the first cycle (making the first
- cycle longer than subsequent cycles), and lets you use the function in a subsequent
- <b>CorrectIllumination_Apply</b> module in the same pipeline, but also
- means that you will not have the ability to filter out images (e.g., by using
- <b>FlagImage</b>). The input images need to be produced by a <b>LoadImage</b>
- or <b>LoadData</b> module; using images produced by other modules will yield an error.</li>
- <li><i>%(EA_ALL_ACROSS)s:</i> Calculate an illumination function
- across all cycles in each group. This option takes any image
- as input; however, the illumination function
- will not be completed until the end of the last cycle in the group.
- You can use <b>SaveImages</b> to save the illumination function
- after the last cycle in the group and then use the resulting
- image in another pipeline. The option is useful if you want to exclude
- images that are filtered by a prior <b>FlagImage</b> module.</li>
- </ul>''' % globals())
+ "Calculate function for each image individually, or based on all images?",
+ [EA_EACH, EA_ALL_FIRST, EA_ALL_ACROSS], doc = '''
+ Calculate a separate function for each image, or one for all the images?
+ You can calculate the illumination function using just the current
+ image or you can calculate the illumination function using all of
+ the images in each group.
+ The illumination function can be calculated in one of the three ways:
+ <ul>
+ <li><i>%(EA_EACH)s:</i> Calculate an illumination function for each image
+ individually. </li>
+ <li><i>%(EA_ALL_FIRST)s:</i> Calculate an illumination
+ function based on all of the images in a group, performing the
+ calculation before proceeding to the next module. This means that the
+ illumination function will be created in the first cycle (making the first
+ cycle longer than subsequent cycles), and lets you use the function in a subsequent
+ <b>CorrectIllumination_Apply</b> module in the same pipeline, but also
+ means that you will not have the ability to filter out images (e.g., by using
+ <b>FlagImage</b>). The input images need to be produced by a <b>LoadImage</b>
+ or <b>LoadData</b> module; using images produced by other modules will yield an error.</li>
+ <li><i>%(EA_ALL_ACROSS)s:</i> Calculate an illumination function
+ across all cycles in each group. This option takes any image
+ as input; however, the illumination function
+ will not be completed until the end of the last cycle in the group.
+ You can use <b>SaveImages</b> to save the illumination function
+ after the last cycle in the group and then use the resulting
+ image in another pipeline. The option is useful if you want to exclude
+ images that are filtered by a prior <b>FlagImage</b> module.</li>
+ </ul>''' % globals())
self.smoothing_method = cps.Choice(
"Smoothing method",
View
15 cellprofiler/modules/flagimage.py
@@ -196,9 +196,8 @@ def set_directory_fn(path):
for the negative category for images whose power log slope is less than -2.5
pixels and will score the opposite for images whose slope is larger.
The filter adds positive and negative and flags the images whose
- positive score is higher than the negative score.
- <p>Note that if the rules are obtained from CellProfiler Analyst, the images
- that are fail are those represented by the second number between the brackets.</p>"""))
+ positive score is higher than the negative score."""))
+
def get_rules_class_choices(group=group):
'''Get the available choices from the rules file'''
try:
@@ -207,6 +206,7 @@ def get_rules_class_choices(group=group):
return [str(i) for i in range(1, nclasses+1)]
except:
return [str(i) for i in range(1, 3)]
+
group.append("rules_class", cps.MultiChoice(
"Class number",
choices = ["1", "2"],
@@ -216,7 +216,14 @@ def get_rules_class_choices(group=group):
CellProfiler Analyst classifier user interface lists the names of
the classes in order. By default, these are the positive (class 1)
and negative (class 2) classes. <b>FlagImage</b> uses the
- first class from CellProfiler Analyst if you choose "1", etc."""))
+ first class from CellProfiler Analyst if you choose "1", etc.
+ Please note the following:
+ <ul>
+ <li>The flag is set if the image falls into the selected class.</li>
+ <li>You can make multiple class selections. If you do so, the module
+ will set the flag if the image falls into any of the selected classes.</li>
+ </ul>"""))
+
group.rules_class.get_choices = get_rules_class_choices
group.append("measurement", cps.Measurement("Which measurement?",
View
20 cellprofiler/modules/measureobjectsizeshape.py
@@ -8,6 +8,9 @@
the image using <b>IdentifyPrimaryObjects</b>.
<h4>Available measurements</h4>
+See the <i>Technical Notes</i> below for an explanation of creating an ellipse with the
+same second-moments as an object region.
+
<ul>
<li><i>Area:</i> The actual number of pixels in the region.</li>
@@ -79,6 +82,23 @@
the order which can be calculated (and indeed users could add more by
adjusting the code), the higher order polynomials carry less information.</li>
</ul>
+
+<h3>Technical notes</h3>
+A number of the object measurements are generated by creating an ellipse with the
+same second-moments as the original object region. This is essentially the
+best-fitting ellipse for a given object with the same statistical properties.
+Furthermore, they are not affected by the translation or uniform scaling of a region.
+
+References:<br>
+<ul><li>Rocha L, Velho L, Carvalho PCP, "Image moments-based structuring and tracking of objects",
+Proceedings from XV Brazilian Symposium on Computer Graphics and Image Processing, 2002.
+<a href="http://sibgrapi.sid.inpe.br/col/sid.inpe.br/banon/2002/10.23.11.34/doc/35.pdf">[PDF]</a>
+</li>
+<li>Principles of Digital Image Processing: Core Algorithms (Undergraduate Topics in Computer Science):
+<a href="http://www.scribd.com/doc/58004056/Principles-of-Digital-Image-Processing#page=49">Section 2.4.3 - Statistical shape properties</a>
+</li></ul>
+
+
<h3>Changes from CellProfiler 1.0</h3>
The Zernike features are computed within a circle overlaid on each object
in both CellProfiler 1.0 and 2.0. CellProfiler 1.0 first finds a square that
View
3  cellprofiler/modules/saveimages.py
@@ -409,7 +409,8 @@ def visible_settings(self):
if self.gray_or_color == GC_COLOR:
result.append(self.colormap)
result.append(self.update_file_names)
- result.append(self.create_subdirectories)
+ if self.file_name_method == FN_FROM_IMAGE:
+ result.append(self.create_subdirectories)
return result
@property
Please sign in to comment.
Something went wrong with that request. Please try again.