Monday, August 17, 2015

Chromosome Karyotyping


The goal of this activity is to align the chromosomes in upright orientation using freeman vector code. Initially, one randomly oriented chromosome image was chosen and we device a way to rotate the image such that the chromosome was aligned along the vertical. The steps in implementing this were discussed as we went on this post.

The first problem that I came upon was finding a good chromosome image. Most of the chromosome images are low resolution and contain bands inside them which makes the edge detection unpromising. Morphological operations can be used to solve this problem but I choose to search for a more solid chromosome (see figure below).

Chromosome image.

From the detected edge, we want a list in which the boundary of the chromosome is traced in order. The bwtraceboundary function of Matlab takes care of that. The freeman vector code starts with assigning the numerical code based on the position of the previous boundary pixel. To determine that, we check the difference between the pixel coordinates of the adjacent boundary pixels. The image below summarize the y- (row) and x-coordinate (column) difference with respect to the position of the previous pixel P. 



Based on this, 8 conditions were set to determine the direction of the next boundary pixel and assign the corresponding numerical code. From the numerical code, the gradient was calculated by getting the difference between the adjacent cells then the running sum of three consecutive cells. The positive values then are the convexities and the negative values are the concavities. Zero values are the part of the contour which are straight. What we want to find are the corners which will set as a guide to rotate the image. The corners can be considered as convex curves therefore the positive running sum values. 

Another problem encountered was detecting multiple convexities on the contour. Some additional convexities were due sudden bumps on the detected edge. Ma'am Jing suggested that we resize the image expecting that when you make the image smaller the rough part of the contour will diminish accordingly. Later on, she also introduced Fourier descriptor to smoothen our edges. I applied both to my image. 

Fourier descriptor express the x- and y-coordinates of the contour pixels as a complex number then taking its Fourier transform. A mask was used which set the high frequencies to be zero in order to remove the unnecessary information. Figure below shows the Fourier transform with and without the filter. 

Fourier transform of the contour (left) and that with the mask applied (right). 

The resulting edge was now smoothened as shown in the image below.

Edge of the chromosome (left) and its smoothened version (right).

Multiple detection of the convexities was still an issue but they decreased considerably. I set a condition for the corners to have three consecutive positive running sum values. From the figure below, the green circles on the edge represent those part of the contour with three consecutive positive running sum values.

Edge of the image with green circles as the detected convexities.

I tried to detect just the corners from the convexities but any other ways and conditions I chose were not that successful. Either there would still be convexities on other parts of the edge or failure of detecting the supposed corners entirely. The best that I could do to automate the code is that from the multiple detected corners, I look for two points that have the largest distance between them. Since these two points should be on the other side of the chromosome, the line that can be formed from these two points is the approximate alignment of the chromosome. Determining the equation of this line won't be needed. I just need to compute the angle from the vertical using tangent function to know how much rotation show be used to align the chromosome upright. Image below is the resulting rotated image.

Rotated chromosome image.

I used the same method for other cropped chromosome images. I just applied some morphological image to eliminate the bands inside the chromosomes. Different filters were used in the FT of the contour in order to smoothen the edges of different images.


The figure above consists of the set of chromosome images (left), edge images with detected corners (middle) and the rotated images (right). I can say that the code successfully align chromosome images with different orientations.

--
Reference
[1] Piper, Jim, and Erik Granum. "On fully automatic feature measurement for banded chromosome classification." cytometry 10.3 (1989): 242-255.
[2] Freeman, Herbert. "On the encoding of arbitrary geometric configurations." Electronic Computers, IRE Transactions on 2 (1961): 260-268.
[3] Balista, Junius André F., Maricor N. Soriano, and Caesar A. Saloma. "Compact time-independent pattern representation of entire human gait cycle for tracking of gait irregularities." Pattern Recognition Letters 31.1 (2010): 20-27.