Tuesday, May 3, 2011

Particle : a python class to compute particle anisotropy by morphological erosion

A python class called particle, is implemented to handle the chromosomes extracted from a metaphase image:
Original segmented chromosomes

The class particle  is instanciated with the counterstain image (DAPI), it is possible to :
  1. display a particle vertically
  2. compute the convex hull area. The convex hull area is computed with from the coordinates of the convex hull vertices.
  3. produce the morphological rose des directions, which describe the particle anisotropy.

Blue curve:orientation curve (rose des direction) for the original particle image (top left). Green curve: orientation curve after high pass filtering (top right).


The script written to test the class, instanciates two particle objects, for example:
  •  p1=particle(im), where im is a DAPI image of segmented chromosomes.
It is then possible to get the morphological "rose des directions", that is the number of morphological erosion by a 1x3 structuring element, necessary to erode totally the particle in a given direction:
  • theta1,rosedirections,VImage=p1.orientationByErosion(10) 

  • The parameter set to 10 is the rotation step
  • theta: the particle principal orientation
  • rosedirections: a numpy array to plot the erosion number vs the rotation angle
  • VImage: rotated particle image
 The particle convex hull is obtained with:
  • p1.cvxhull_area()

The script must be modified to fit  the image path.

Numpy, scipy, matplotlib, pymorph, readmagick, mahotas must be installed. However since original implementation. Mahotas itself or scikit image could be used instead of readmagick to load the image.

With two features, as the particle area and the ratio between the particle area and the convex hull area, it should be possible to start to classify the particles into four categories:
  • non overlapping chromosomes,
  • overlapping chromosomes,
  • nuclei, 
  • remaining small stuffs .

Code on Gist 

anisotropy_RoseDirections.py

Ipython notebook here

http://nbviewer.ipython.org/gist/jeanpat/7673858 

Post a Comment