Personal tools
You are here: Home Tutorials pyCoAn: clem add-on tutorial clem_align: finding the holes

clem_align: finding the holes

Interactive function to find coordinate transform from fluorescence to EM image

The simplest way of determining the transform is using the function 'clem_align'. This allows performing all necessary steps and returns a Transform object that can be used to transform the fluorescence image into EM image space. In addition to the two images, the function takes an optional angle to rotate the fluorescence image in the correspondence picker. It is important to put the EM image first.

>>> T = clem_align(em,fl,-100)

 

running iterative median filters

First, iterative median filtering is run on the input images. Next, the binarization process is started. A window containing a binarized version of the median-filtered EM image will pop up.

running binarizer

EM image binarization

 click in the slider (do NOT slide) to determine threshold

 wait until image update is finished before clicking again

 type 'r' and hit return to redo picking

 hit return in this terminal window once done 

clem-em-bin-start

There is a slider below the image that allows changing the cutoff level for the binarization. Only use clicks to change values. Changing the values by actual sliding is likely to freeze the window. If freezing occurs, close the window (red button at top left corner), go to the terminal window, type 'r' (without the quotes) and hit return. This will pop up a fresh window. Adjust the value by clicking on the slider so the holes are easily visible and the hole edges are as well-defined as possible. 

clem-em-bin-end

All windows created by this function are based on matplotlib with identical controls for panning and zooming. It is a good idea to zoom in to double-check how well the hole edges are defined.

clem-em-bin-end-lrg

The slider will still be active in this view. Once happy, go to the terminal window, activate it and hit return. A window with a binarized version of the median-filtered fluorescence image will pop up.

fluorescence image binarization

 click in the slider (do NOT slide) to determine threshold

 wait until image update is finished before clicking again

 type 'r' and hit return to redo picking

 hit return in this terminal window once done 

clem-fl-bin-start

Adjust the threshold by clicking on the slider until the holes are optimally defined. 

clem-fl-bin-end

Once satisfied, go to the terminal window and hit return to continue. Next, the program performs Canny edge detection on the binarized fluorescence and EM images.

running canny edge detection

 
After this process is finished, a new window for the Canny edges of the EM images will appear.

find initial EM hole-radius estimate

Zoom in to determine distance

 hit return in this terminal window when done

clem-em-canny-full

The purpose of this display is to get an estimate for the diameter of the holes. The first step is to zoom into a single hole so that the measurements can be performed more accurately. This is done using either clicking on the 'pan and zoom' double arrow or by clicking on the magnifier (see matplotlib documentation).

clem-em-canny-lrg

Once you are satisfied with the view, go back to the terminal window and hit return.

find initial EM hole-radius estimate

Zoom in to determine distance

 hit return in this terminal window when done  

 click on both edges of circle to estimate distance

Click on one side of the circle, then click on the opposite side. AN estimate for the diameter and the radius will show up in the terminal window. If you are satisfied, hit return in the terminal window, otherwise type 'r' and hit return to make another measurement.

 estimated diameter is:  401 (radius 201)

 type 'r' and hit return to redo picking

 hit return in this terminal window when done

Once you hit return, the program calculates a range for optimization. It can be overwritten but the range is usually sufficient and you can hit return. In either case, the program will continue by optimizing the signal of the circular Hough transform using the specified range and print out the signal for each radius in the range.

197 0.279464285714

198 0.36170212766

199 0.539893617021

200 0.637323943662

201 0.347902097902

202 0.292534722222

203 0.252604166667

It is good practice to check if the maximum is not at the edge of the range. If so, it would be better to rerun with an increased range. In the example case, the optimal radius is 200 and the signal is significantly higher than either neighbor. Once the calculation is finished, the program proceeds to the fluorescence Canny edge image to repeat the procedure.

clem-fl-canny-full

find initial fluorescence hole-radius estimate

Zoom in to determine distance

 hit return in this terminal window when done  

 click on both edges of circle to estimate distance

clem-fl-canny-lrg

 estimated diameter is:  64 (radius 32)

 type 'r' and hit return to redo picking

 hit return in this terminal window when done 

optimize fluorescence radius for hough transform

 specify range with coma delimiter (default: 29, 35): 

29 0.363095238095

30 0.409090909091

31 0.41847826087

32 0.592391304348

33 0.75

34 0.53

35 0.385

Once the optimization is finished, the program launches the circular Hough transform calculations for both the EM image and the fluorescence images using the optimized radii. 

running hough transforms

 

< previous | next >