Electromagnets are placed above the sample slide, and an inverted microscope is placed below. The image is captured via a CCD camera and transferred to a computer, where the three-dimensional positions of the magnetic beads are determined.  The position of the bead within the horizontal plane of the glass slide, x and y, are determined by real-time correlation of the bead images.  The vertical length of the hairpin, measured by the vertical position of the attached magnetic bead, is measured by the bead’s diffraction ring diameter, which increases with distance.