Hole Finder Dialog

This dialog allows you to use the Holefinder module to find circular holes in a support film that are arranged in a square lattice.  This module was developed in the IMOD program Imodfindholes.  It finds holes by a sequence of steps, starting with an image reduction to bring the holes to a diameter of ~50 pixels, then a smoothing filter, and edge detection with a Sobel filter and a Canny edge detector.  This edge image is correlated with a series of circular templates to determine the best size, preliminary positions are found, the edge image is averaged over the positions with the strongest correlations, and this average edge template is correlated with the edge image.  Positions are then analyzed for whether they are at regular spacings and angles with respect to each other.  The actual reduced image is then averaged at most of the found positions and the resulting image template is correlated with the reduced image.  The positions from this correlation are separately analyzed for location on a regular grid, and results from the two methods are merged.  Holes with extreme outlying intensities are eliminated.

There are two parameters that determine the efficacy of the edge detection: the initial filter and the threshold for the Canny edge detector.  Optimal results are obtained by doing the entire analysis with a series of values and using the filter/threshold pair that detects the most holes.

For a montage, this analysis is done on the overview image as currently displayed, although the program may reload the overview with less binning if holes are too small in the current image.  Individual montage pieces are then analyzed with both average edge and image templates to find hole positions on each piece.  These positions are used to refine and add to those from the overview image, so that each point ends up with an accurately measured position on a specific montage piece that can be used with the Realign to Item routine.  This method can overcome the deficiencies in the alignment of pieces in the overview image, provided that the error in alignment of adjacent pieces is less than half  the periodicity of the holes.  If the error is larger than this, the program will not be able to resolve positions between the pieces accurately, and some holes will be missed or duplicated.

When an overview has bad piece alignments (half a hole periodicity or more), you need to get an overview with less error, not a perfect alignment. The recourse is:

  1. Turn off 'Treat as very sloppy montage' in the Montage Control panel, if it is on.  This will usually prevent alignment errors from giving large shifts between pieces.
  2. If alignments are still bad, turn off 'Align pieces in overview'.
  3. If errors are still too large, you need a better stage calibration or high-defocus magnification calibrations.

The hole-finding operation is done on the current active image in the main buffer display.  Before starting, the program analyzes the autocorrelation of the image to get an independent check on the entered value for periodicity and puts up a message box with 3 choices: to stop and measure the hole-to-hole spacing directly, to go with the entered values, or to go on and skip this analysis in the future.  The autocorrelation analysis is not infallible so you may need to go on.

After finding holes, the image data in the holes is analyzed in 3 ways: the mean intensity is computed; pixels are smoothed by averaging 3x3 blocks of pixels and the standard deviation (SD) of smoothed values is computed; and the percentage of pixels that would be considered dark outliers will be estimated.  In this dialog, you can set a lower and upper cutoff for the mean intensity and upper cutoffs for the SD and percent of black pixels.  These cutoffs are initially constrained to the extreme values of the first set of holes analyzed, but then become independent settings retained between sets of holes.  A cutoff can thus be outside the range found in the current set of holes, which is useful if none of the holes in this particular gris square approach the extremes that are being eliminated.

Hole size

Enter the size of the holes in microns.  This needs to be accurate to within ~10%, preferably better.  After you successfully find holes with your initial value and get an estimate of the actual hole size, use the Set Size/Period button to adopt that new size for future runs.  To measure hole size, zoom up so that the holes are at least half the size of the control panels on the screen.  Measurements in an unzoomed image may not be accurate enough.  Hold down the shift key and the left mouse button to draw a line across a hole.


Enter the distance between the centers of the holes in microns.  This is not the separation between the edges of adjacent holes; that value is shown in the label to the right that include the conventional (size/sep) designation for grids.  The periodicity needs to be accurate within ~15%.  To measure hole periodicity, zoom up so that the holes are at least half the size of the control panels on the screen.  Hold down the shift key and use the left mouse button to draw a line from the edge of one hole to the edge of the next one, being careful not to measure between diagonal neighbors.

Maximum error

Enter the maximum deviation allowed between a point and the predicted location of that point, based on a fit to positions in up to a 5x5 array of neighboring points.  Points will be dropped if they exceed this error.  A value of 0.05 should be good.

Exclude holes outside polygon

With this option checked, the program will look for polygons most of whose points fall on the current image, and take the smallest such one as a boundary polygon.  The option is ignored if no polygon is found, so it can be left on if you ever use it.  Stray points on the grid bar should be easy to eliminate with the lower mean intensity cutoff, but the option to use a polygon is available if points outside the grid square are numerous enough to ruin the hole detection.

Filters to try

The program can apply two different initial filters: Gaussian smoothing with a specified sigma value, or median filtering with a given number of iterations.  While smoothing is most often best, median filtering may be optimal for some kinds of data; thus it is advisable to try both.  Sigma values in pixels are entered in the 'Gaussian sigma' box and iteration numbers in the 'Median filter iterations' box, separated by spaces; either box may be left blank.  Median filtering can reduce noise while preserving the sharpness of the hole edge and may be better in some cases.  The default entries are sigma 1.5, 2, and 3 for Gaussian smoothing and 3 iterations of the median filter.  The median filter takes longer.

Edge threshold

This threshold entry specifies the percentage of pixels in the Sobel-filtered image that will be taken as 'strong' edge points and form the seed for the final edge image. The Canny edge detector also has a lower threshold for selecting points as 'weak' edge points.  The lower threshold is taken to be twice the upper one.  Enter one or more thresholds separated by spaces.  The default entries are 2, 3.2, and 4.4.

Bracket last filter/threshold values

Without this option on, the total number of filter/threshold combinations tried is the product of the number of filters and the number of thresholds.  After one set of holes has been analyzed, this option can be used to try only the subset of the filter and threshold values adjacent to the ones that were last found to be optimal.  This can save variable amounts of time.  The fewest trials will be done if both previous values were at one end of their respective range; if the values are in the middle of each range of 3 or more items, 9 trials will still be done.  Simply adopting the values found on one analysis and applying them on further grid squares was not adequate when tested during development.

Find Holes

Press this button to analyze the currently active image.  The results from each trial pair of filter and threshold values will be shown on a line below this button: the number of points found, and the number missing from a regular grid.  When the trials are done, the final result will be shown, along with the hole size and periodicity found. 

Set Size/Period

Use the hole size and separation from the last hole-finding operation to set the values in the size and periodicity text boxes above.  It is useful to do this once to replace the nominal values that you start with.

Clear Data

Use this button to remove the display of found points and free up all memory used in Holefinder.  Neither of these should be necessary in routine use.   Holefinder caches template transforms so that they can be reused on the next set of holes if they are the same size, saving some time, so it is best not to clear the data unless memory is limited.

Lower mean cutoff

Use the slider or enter a value in the text box to exclude holes whose mean intensity is below the selected value.  This slider ranges from the minimum to the median intensity.  You can enter a value outside the range of the slider.

Upper mean cutoff

Use the slider or enter a value in the text box to exclude holes whose mean intensity is above the selected value.  This slider ranges from the median to the maximum intensity.  You can enter a value outside the range of the slider.

SD cutoff

Use the slider to exclude holes where the standard deviation of smoothed intensity exceeds the selected value.

Black pixel % cutoff

Use the slider to exclude holes where the pecentage of smoothed pixel values that are negative outliers exceeds the selected value.

Show Included

Use this option to toggle whether the included points (the ones passing all the cutoffs) are displayed.  Included points are displayed in magenta.

Show Excluded

Use this option to toggle whether the points excluded by any of these cutoffs are displayed.  Points below the lower mean cutoff are displayed in light blue and ones above the upper mean cutoff are in dark blue.  Ones excluded by the SD cutoff or black pixel cutoff are displayed in light or dark blue depending on which mean cutoff their means are closest to.

Toggle Points

This button can be pressed to turn off the display of all points temporarily; the points will be redsiaplyed when the button is released.

Layout of points

These radio buttons determine the sequence in which points will be placed in the Navigator table by the following button.  They represent the same options allowed when using the Add Grid of Points command: 1) 'Zigzag' will go up one column and down the next. 2) 'Away from focus' will move in the same direction within each column or row, the direction away from the Focus area.  3) 'In groups' will place the points in groups no bigger than the size set with Set Group Radius, with the first point in near the center of the group and other points accessed in a zigzag pattern. This selection is independent of whether the menu option Divide Points into Groups option is on.

Make Navigator Points

Press this button to generate a set of Navigator points from the included holes, ordered in the chosen way.  Points will be marked for acquisition.  When points are placed into multiple groups, a message box will appear showing the number of groups and their average size and giving you the chance to reject the division.  Otherwise, points will be placed into a single group.

The hole positions will no longer be displayed after points are put into the Navigator table, provided that the first (or only) created group still has some points in it.  To bring back the display of the hole positions, delete that group of points in the table by using the 'Collapse groups' option in the Navigator Dialog.