Our objective is to automate the focusing, counting, identification and photography of cells under the microscope.
To achieve automatic focusing and movement of the mechanical stage, we use belt drives and shaft couplers connected to stepper motors to control the knobs. A camera (Arducam) connected to our Raspberry Pi controller is mounted onto the eyepiece using a 3D-printed mount.
Firstly, our algorithm divides the specimen on the mechanical stage into 9 different segments in a 3-by-3 grid. Starting with the centre grid, an image is taken of the specimen, which is then processed by Cellpose* to count the number of cells present in the segment. Next, the stepper motors move the belt drives and shaft couplers to adjust the specimen on the mechanical stage such that the top-left segment is under the lens of the microscope. Another image is taken and processed by Cellpose to count the number of cells. This process repeats 7 more times in a clockwise direction, following which the algorithm will identify the segment with the median number of cells and subsequently use the maximum focus of the microscope on this segment.
Our code then uses the Cell-SAM (Segment Anything Model) model to segment and count the cells.