Friday, November 29, 2013

Compare Clutches - EggArrange v0

I have just finished the first version (v0) of EggArrange. This compares two photographs, that may not necessarily match in scale or position. We would like to test the arrangement hypothesis (Polačiková et al. 2013), however taking standardize photographs in the field is a challenge. Even if you calibrate images based on a size standard, the objects you wish to compare may not actually match in size. One reason for this is if the size standard is located at the edge of the image where subtle distortions occur. A recent distance transformation technique (written for MatLab) was published in Methods in Ecology and Evolution (Taylor et al. 2013). This  technique searches for the minimum difference between two images, displacing the image and stretching until the best match is created. We are initially just interested in the silhouette of the eggs before and after treatment, so our task is relatively simple. However, we don't want to stretch our images, just resize them and move them until they provide the best match, because these are the issues that arose from differences in the photographs (different location of eggs in the frame and distance from nest), and through pre-processing such as calibrating the image to the size standard in both images. Moreover, MatLab provides a substantial finantial barrier for most researchers, therefore I rewrote custom codes that run similar analyses using Linux bash coding and ImageMagick (that is how it is spelled). Here's an example of it in action:


This examines the absolute error (visualized in red pixels) and presents those differences as a percentage of black pixels (eggs) in the first image. The codes can be easily adapted for automation and other types of comparisons.

Here, comparisons are first made between image 1 and image 2 scaled to 15% larger to 15% smaller (1 percent increments). Then the best match is chosen as the new image 2, then image 2 is shifted 30% to the right to 30% to the left, and the best comparison is chosen, then the same is applied to the y axis. These three steps are repeated to optimize the comparison (some rescaling may be necessary).

Generally this works well, but finding the minimum difference produces incorrect comparisons (i.e., a if image 1 has only one egg, the whole clutch in image 2 may be scaled to fit inside that egg - hypothetically speaking). Therefore, along with the dissimilarity (%) the program produces the comparison image. Users are encouraged to check these carefully, and report them with publications as necessary.

Please view my research website to obtain the codes. The pre-release version is password protected, so please contact me to discuss its use.


References:

Polačiková, L., F. Takasu, B. G. Stokke, A. Moksnes, E. Røskaft, P. Cassey, M. E. Hauber, and T. Grim. 2013. Egg arrangement in avian clutches covaries with the rejection of foreign eggs. Animal cognition 16:819–828.

Taylor, C. H., F. Gilbert, and T. Reader. 2013. Distance transform : a tool for the study of animal colour patterns. Methods in Ecology and Evolution 4:771–781.

Friday, November 15, 2013

Comp.posthoc

This short video shows some uses of comp.posthoc, which performs multiple comparisons tests on phylogenetic generalized least squares analyses Here I illustrate the flexibility in family-wise confidence intervals and the plotting function.

Maximize the video size to see the example more clearly. 

In addition to running Tukey HSD tests this function can also run Newman-Keuls method. There is also the option to print all pair-wise contrast comparisons available from the 'summary' function (alternating base groups with the 'contrasts' function). P value adjustments can then be made on these values.




Tuesday, November 12, 2013

Keeping standards clean and measurements consistent

The importance of keeping a white standard clean cannot be understated. Our lab uses an Ocean Optics system with Spectralon white standards. After brainstorming with Nick Friedman about potential issues associated with repeated usage of white standards, under varied conditions, we decided to make a cover for our white standard that would allow calibration but not direct contact. We designed a cap with a small hole, that would allow the probe tip to come close to the standard but not touch it. In addition, we made plans for a probe tip with an inter-changable 90 or 45 degree measurement angle (you just need to flip it). Tom Koutny and I brought these ideas to our campus workshop and they generously made our first prototype in their spare time! I think they did great!


An Avantes spectrometer is shown above, but the parts fit perfectly

Our next steps will be to make another tool to set the depth for the probe inside of the probe tip after calibration. We will also investigate how the shiny aluminium may influence measurements and make minor adjustments to the placement of the thumb screw holes. After completing our tests, and adjustments, I will post detailed plans for those interested in milling or 3D printing these parts at home.