Cell three-dimensional positioning method based on self-supervised learning
By building a microscopic operating system and a self-supervised comparative learning model, the problem of not being able to obtain cell depth information in the existing technology is solved, and high-precision three-dimensional positioning of microscopic cells is achieved, which improves the accuracy and reliability of positioning.
Patent Information
- Application Number
- CN202510002352.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-06
AI Technical Summary
Existing microscopy imaging technology can only provide two-dimensional position information and cannot directly obtain depth information. In the process of living cells, there are common problems such as insufficient accuracy, slow response speed or high cost.
By building a microscopic operating system, cell images at different defocus distances are collected, data sets are constructed, and two-dimensional position information of cells is extracted using image processing technology, and the training model is trained through self-supervised comparison and comparison learning, combined with fine-tuning to achieve depth estimation, thereby completing three-dimensional positioning of cells.
High-precision three-dimensional positioning of microscopic cells is achieved, the accuracy of cell positioning is improved, and more reliable technical support is provided for subsequent cellular operations.
Smart Images

Figure CN119942050A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of microscopic image processing, and specifically relates to a three-dimensional cell positioning method based on self-supervised learning. Background Art
[0002] In biology and medicine, microscopic image analysis is a very important research field, and microscopic cell localization technology is one of its important branches. Existing microscope imaging technologies still have limitations. They can only provide two-dimensional position information and cannot directly obtain depth information. At the same time, in the task of microscopic cell localization, people hope to obtain not only the two-dimensional position information of cells, but also the depth information of cells. Although there are some depth estimation methods, such as image gradient-based methods, histogram-based methods, and holographic microscope-based methods, these methods generally have problems of insufficient accuracy, slow response speed, or high cost when dealing with living cells.
[0003] Therefore, developing a high-precision, fast-response three-dimensional positioning method is of great significance for cell manipulation under a microscope. This can not only improve the accuracy of cell positioning, but also provide more reliable technical support for subsequent cell manipulation.
[0004] Compared with existing technologies:
[0005] Technical comparison with patent CN118737283A "A method for predicting RNA subcellular localization based on improved Transformer and SETextCNN"
[0006] Patent CN118737283A achieves high-precision subcellular localization prediction of RNA molecules through the improved Transformer architecture and SE-TextCNN model, showing strong generalization and feature extraction capabilities. The present invention constructs a micromanipulation system, through which cell images are collected, and a data set containing cell position, shape, color, quantity and background complexity is constructed based on these images; then image processing technology is used to extract the two-dimensional position information of the cells; finally, the model is trained through self-supervised contrast learning, combined with fine-tuning to achieve depth estimation, thereby completing the three-dimensional positioning of the cells. Summary of the invention
[0007] In response to the above problems, the present invention proposes a cell three-dimensional positioning method based on self-supervised learning, which aims to achieve high-precision three-dimensional positioning of microscopic cells through a micromanipulation system, a data set construction method, a cell two-dimensional positioning method and a cell depth estimation method.
[0008] To achieve the above object, the technical solution adopted by the present invention is:
[0009] A method for three-dimensional cell positioning based on self-supervised learning, the specific steps are as follows:
[0010] 1) Build a micromanipulation system: Build an experimental system including a commercial inverted microscope, a micromanipulation system, and a computer to collect cell images and perform three-dimensional positioning;
[0011] The micromanipulation system comprises:
[0012] A Nikon TS-2 inverted microscope equipped with a 40x objective was used to capture cell images;
[0013] MN30-18 micromanipulator system controls the movement of cells in the Z direction to obtain images at different defocus distances;
[0014] 2) Dataset construction method: By adjusting the distance between the focal plane of the microscope and the cells, cell images at different defocus distances are collected to construct a dataset covering different positions, shapes, colors, numbers and background complexity of cells;
[0015] 3) Cell 2D positioning method: Image processing technology, including filtering, mask application, thresholding, dilation operation, contour detection and other steps, is used to extract the 2D position information of cells;
[0016] 4) Cell depth estimation method: Use self-supervised contrastive learning to pre-train the depth estimation model, extract depth features by comparing cell images of the same depth and different depths, and fine-tune them in combination with depth labels to achieve high-precision depth estimation.
[0017] As a further improvement of the present invention, the method for constructing the data set S2) includes:
[0018] Step 2.1, place the cell sample on a glass slide and mount it on a micromanipulator system, and adjust the focus of the microscope so that the cells are in the focal plane;
[0019] Step 2.2, the micromanipulator system moves in the Z direction, 10 μm at a time, to capture cell images. For each cell, images with a defocus distance from -150 μm to 150 μm are captured, and a total of 3100 images of 100 cells are captured;
[0020] Step 2.3, quantitative analysis of the images in the data set, including cell location distribution, cell number, cell area, cell color including H, S, V values, background complexity including impurity number and area, and cell shape.
[0021] As a further improvement of the present invention, the S3) two-dimensional cell positioning method comprises:
[0022] Step 3.1, filtering, select 15*15 Gaussian kernel to filter the original image and remove Gaussian white noise; the role of step 3.1 is to pre-process the input image and reduce noise;
[0023] Step 3.2, color segmentation, the color mode of the image is converted to HSV mode, then five masks are defined and some masks are preprocessed; the function of step 3.2 is to extract the target area according to the color features;
[0024] The process of mask definition and preprocessing in step 3.2 is as follows:
[0025] A series of points in the target area are randomly selected, and the HSV values of these points are analyzed. Masks are defined based on the analysis results. The detailed mask values are as follows: Mask 1: [20,35,100]-[130,200,225], Mask 2: [20,12,140]-[35,30,167], Mask 3: [12,18,189]-[35,30,220], Mask 4: [90,8,160]-[110,20,190], Mask 5: [30,19,174]-[36,36,180]; Then, Mask 1 and Mask 3 are blurred using the Gaussian kernel selected from the cv2.GaussianBlur function;
[0026] Step 3.3, process and merge the masks, search for the contours of mask 2 to mask 5 in turn and calculate the contour areas, and sort the contours in mask 2 to mask 5 in descending order according to the area, then filter the masks according to the contour area, and finally merge mask 1 to mask 5 into one mask; the purpose of step 3.3 is to filter out valid masks and merge the valid masks into the total mask;
[0027] The process of screening the mask according to the contour area in step 3.3 is as follows: Masks 2 to 5 are judged in turn, that is, whether the maximum contour area in the mask is less than 1000 pixels; if it is less than 1000 pixels, the mask is considered invalid and set to all black; if it is greater than 1000 pixels, no change is made;
[0028] Step 3.4, morphological operation, close the total mask, then binarize the mask after the closing operation, and use the expansion operation to further connect the adjacent areas, and finally filter the contour according to the area; the role of step 3.4 is to perform morphological processing on the merged mask, remove noise and connect the disconnected areas;
[0029] Step 3.5, filter the contours. If the number of contours exceeds 800, redefine the color range and recreate the mask. If the area of the second largest contour is less than 32,000, search for contours again. Finally, filter the target contour based on the contour area and HSV value. The purpose of step 3.5 is to verify the number and quality of contours and ensure that the found contour is the target area.
[0030] Step 3.6, extract the target area, calculate the center of the target contour, and then crop the target area according to the center coordinates and the predefined cropping range; the purpose of step 3.6 is to obtain the cell plane position and crop a rectangular area containing the target cell from the original image.
[0031] As a further improvement of the present invention, the specific process of step 3.4 is as follows:
[0032] Step 3.4.1, close the total mask, the closing kernel is a 5*5 rectangle and the number of iterations is 4;
[0033] Step 3.4.2, binarize the mask after the closing operation. The binary processing logic is that if the pixel value is greater than 10, it is set to 255, otherwise it is set to 0;
[0034] Step 3.4.3, dilate the binary mask, and the number of iterations of the dilation operation is 4;
[0035] Step 3.4.4, find the contours in the expanded mask and extract the contour area. First, use the cv2.findContours function to find the closed contours in the mask, and then calculate the area of the extracted contours.
[0036] Step 3.4.5, filter contours according to their area size, traverse all contours, and set the area of contours larger than 360,000 pixels to 0;
[0037] Step 3.4.6, sort the contours in descending order according to their area, use np.argsort to sort the contours in descending order according to their area, then return the sorted index list, and rearrange the contours according to the sorted index.
[0038] As a further improvement of the present invention, the process of step 3.5 is:
[0039] Step 3.5.1, determine whether the number of contours is greater than 800; if the number of contours is greater than 800, create new mask 6 and mask 7, and merge the two masks into one, and then sequentially execute steps 3.4.1, step 3.4.4, step 3.4.5, step 3.4.6 and step 3.5.3 on the merged mask; if the number of contours is less than 800, execute step 3.5.2 sequentially;
[0040] Step 3.5.2, determine whether the second largest contour area is less than 32,000 pixels; if the second largest contour area is less than 32,000 pixels, then proceed to step 3.4, step 3.5 and step 3.6 in sequence, wherein when performing step 3.5, the area of the contour of pixels with an area greater than 430,000 is set to 0; if the second largest contour area is greater than 32,000 pixels, then proceed to step 3.5.3;
[0041] Step 3.5.3, verify whether the contour is a cell area, traverse the top three contours with contour areas greater than 30,000 pixels after sorting, then draw the current contour on the original image, extract the pixel coordinates of the contour area, calculate the HSV mean of the contour area, and record the index of the contour with saturation greater than 34 and hue less than 60.
[0042] As a further improvement of the present invention, the process of step 3.6 is:
[0043] Step 3.6.1, calculate the center coordinates of the contour, use the cv2.moments function to calculate the geometric moments of the target contour recorded in step 3.5.3, and calculate the x and y coordinates of the center of mass from the geometric moments;
[0044] Step 3.6.2, define the cropping area, and define the cropping area as a 1300×1500 pixel area centered on the centroid;
[0045] Step 3.6.3, perform boundary check and adjust the cropping area according to the centroid position to prevent the cropping area from exceeding the original image boundary;
[0046] Step 3.6.4, crop the original image and save a copy to a specified location.
[0047] As a further improvement of the present invention, step 4) the cell depth estimation method comprises:
[0048] The following steps are involved:
[0049] Step 4.1, self-supervised contrastive learning pre-training: extract depth features by comparing cell images of the same depth and different depths, and pre-train the depth estimation model;
[0050] Step 4.2, depth label fine-tuning: combine the pre-trained model with the depth label and perform fine-tuning to convert the depth estimation task into a classification task. The depth range is divided into 31 categories, each with an interval of 10 microns, from -150 microns to 150 microns;
[0051] Step 4.3, depth prediction: In the inference stage, the probability of the image belonging to each depth category is predicted through the classifier layer, and the category with the highest probability is selected as the depth estimation result, or a more accurate depth prediction value is obtained by weighted averaging the probabilities of multiple categories.
[0052] As a further improvement of the present invention, the step 4.1 self-supervised contrastive learning pre-training comprises:
[0053] Step 4.1.1, using the contrastive learning framework, cell images at the same depth are considered as positive samples, and cell images at different depths are considered as negative samples;
[0054] Step 4.1.2, perform two random data augmentations on each cell image, including random cropping, grayscale transformation, and random flipping, to generate two enhanced views;
[0055] Step 4.1.3, the enhanced image is input into the encoder to extract features and projected through the multi-layer perceptron MLP;
[0056] In step 4.1.4, supervised contrastive learning loss function is used to bring the features of images with the same depth closer, push the features of images with different depths farther away, and enhance the classification boundaries.
[0057] As a further improvement of the present invention, the step 4.2 of deep label fine-tuning includes:
[0058] Step 4.2.1, divide the depth range into 31 categories, each category is 10 μm apart, ranging from -150 μm to 150 μm;
[0059] Step 4.2.2, use the pre-trained encoder to extract image features and convert the features into a 31-dimensional vector through the classification layer, where each element represents the probability that the image belongs to the corresponding category;
[0060] In step 4.2.3, the cross entropy loss function is used to minimize the difference between the predicted vector and the true label.
[0061] As a further improvement of the present invention, the depth prediction in step 4.3 includes:
[0062] Step 4.3.1, predict the probability of the image belonging to each depth category through the classifier layer, input the image into the pre-trained and fine-tuned model, and output a 31-dimensional probability vector through the classifier layer;
[0063] In step 4.3.2, select the top k categories with the highest probability, where k is set to 3, and calculate their weighted average depth as the final depth prediction value.
[0064] As a further improvement of the present invention, the depth estimation model uses ResNet50 as the backbone network and is pre-trained using the Moco training scheme.
[0065] As a further improvement of the present invention, the training parameters of the depth estimation model in the fine-tuning stage include: a batch size of 16, a learning rate of 0.00001, and training for 100 epochs.
[0066] As a further improvement of the present invention, the depth estimation method can output three-dimensional position information of cells in the inference stage, including two-dimensional plane position and depth information.
[0067] As a further improvement of the present invention, the depth estimation method can process movable and deformable cells and is suitable for depth estimation tasks of living cells.
[0068] Beneficial effects: the benefits brought by the invention and the indicators achieved.
[0069] 1. High-precision three-dimensional positioning. The present invention achieves high-precision three-dimensional positioning of microscopic cells by combining a microscopic operating system, image processing technology, and a deep learning model. Specifically:
[0070] Two-dimensional positioning accuracy: Through image processing technology, including filtering, mask processing, thresholding, dilation operation and contour detection, the two-dimensional position information of cells was successfully extracted, and the positioning success rate reached 95.46%;
[0071] Depth estimation accuracy: We achieve high-precision depth estimation by pre-training the depth estimation model through self-supervised contrastive learning and fine-tuning with depth labels. Experimental results show that the accuracy of depth estimation is significantly better than traditional training methods from scratch and supervised methods based on ImageNet pre-training.
[0072] 2. High degree of automation. The present invention realizes the automation of image acquisition and processing through micromanipulation system and computer control. Specifically:
[0073] Dataset construction automation: Through the movement of the micromanipulator system in the Z direction, the images with defocus distances from -150 microns to 150 microns were automatically captured, and a high-quality dataset containing 2,717 images was constructed;
[0074] Automated image processing: Through the preset image processing process, the filtering, mask processing, contour detection and other steps are automatically completed, reducing manual intervention and improving processing efficiency.
[0075] 3. The dataset is highly diverse. The dataset constructed by the present invention covers the location, shape, color, number and background complexity of cells, and has high diversity. Specifically:
[0076] Cell location distribution: 78.54% of the cells in the dataset are located in the center of the image, and the rest are distributed in different areas of the image;
[0077] Number of cells: Each image contains 2 to 3 cells, covering scenes with different numbers of cells;
[0078] Cell color: Through HSV color mode analysis, the color of cells is significantly different at different depths, and the ranges of H, S, and V values are [34.77, 120.34], [6.51, 160.16], and [105.37, 204.98], respectively;
[0079] Background complexity: The dataset contains different amounts of impurities and impurity areas, which enriches the diversity of the dataset.
[0080] 5. Strong adaptability. The technical solution of the present invention has strong adaptability and can be applied to different types of cells and complex background environments; specifically:
[0081] Image processing methods are highly versatile: Traditional image processing methods do not require image annotation and can adapt to different types of cells by adjusting parameters, making them highly versatile;
[0082] The deep learning model has strong generalization ability: through self-supervised learning and the diversity of data sets, the trained depth estimation model can adapt to different types of cell images and has strong generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 This is a flow chart of the microscopic cell three-dimensional positioning technology of the present invention;
[0084] Figure 2 A flow chart of the method for constructing a data set of the present invention;
[0085] Figure 3 This is a flow chart of the two-dimensional cell positioning method of the present invention;
[0086] Figure 4 The database image of the present invention
[0087] Figure 5 This is a schematic diagram of model training and fine-tuning of the present invention;
[0088] Figure 6 Schematic diagram of depth estimation of the present invention. DETAILED DESCRIPTION
[0089] The following is a detailed description of the technical solution of the application in conjunction with the accompanying drawings. The described embodiments are only part of the embodiments involved in this patent. All non-innovative embodiments of other researchers in this field based on this embodiment are within the scope of protection of this patent.
[0090] Example 1: Technical content of microscopic cell three-dimensional positioning technology based on self-supervised learning:
[0091] This embodiment describes an implementation process of a microscopic cell three-dimensional positioning technology based on self-supervised learning. Figure 1 As shown, the positioning technology includes:
[0092] Micromanipulation system: Build an experimental system including a Nikon TS-2 inverted microscope, an MN30-18 micromanipulation robot system, and a computer to automatically acquire cell images and perform three-dimensional positioning.
[0093] Dataset construction: The distance between the focal plane of the microscope and the cells was adjusted by a micromanipulation robot system, and cell images at different defocus distances were collected to construct a dataset of 2,717 images, covering the location, shape, color, number and background complexity of the cells.
[0094] Two-dimensional cell positioning: Image processing technology, including filtering, mask processing, thresholding, dilation operation and contour detection, is used to extract the two-dimensional position information of cells.
[0095] Cell depth estimation: Use self-supervised contrastive learning to pre-train the depth estimation model, extract depth features by comparing cell images of the same depth and different depths, and fine-tune in combination with depth labels to achieve high-precision depth estimation.
[0096] Through the above steps, the present invention realizes high-precision three-dimensional positioning of microscopic cells and is suitable for cell analysis under complex backgrounds.
[0097] Example 2: Dataset Construction Method, this example describes in detail the process of constructing a data set. Figure 2 As shown, the dataset construction method includes the following steps:
[0098] Step 1: Place the cell sample on a glass slide and mount it on a micromanipulator system. Adjust the focus of the microscope so that the cells are in the focal plane.
[0099] Step 2: The micromanipulator system moves in the Z direction, 10 microns at a time, to capture cell images. For each cell, images are captured at defocus distances from -150 microns to 150 microns, and a total of 3,100 images of 100 cells are captured;
[0100] Step 3: Perform quantitative analysis on the images in the dataset, including cell location distribution, cell number, cell area, cell color (H, S, V values), background complexity (impurity number and area), and cell shape.
[0101] In actual operation, the dataset constructed through the above steps covers the position, shape, color, number and background complexity of cells, providing high-quality training data for subsequent two-dimensional cell positioning and depth estimation.
[0102] Example 3: Two-dimensional cell positioning method. This example describes in detail the implementation process of the two-dimensional cell positioning method. Figure 3 As shown, the two-dimensional cell positioning method includes the following steps:
[0103] Step 1: Filtering. Use a 15×15 Gaussian kernel to filter the original image and remove Gaussian white noise. This step is used to preprocess the input image and reduce noise.
[0104] Step 2: Color segmentation. The color mode of the image is converted to HSV mode, and then five masks are defined and some masks are preprocessed; the purpose of this step is to extract the target area based on color features;
[0105] Step 3: Process and merge masks. Find the contours of Mask 2 to Mask 5 in turn and calculate the contour area, and sort the contours in Mask 2 to Mask 5 in descending order according to the area. Then filter the masks according to the contour area, and finally merge Mask 1 to Mask 5 into one mask; the purpose of this step is to filter out valid masks and merge the valid masks into the total mask;
[0106] Step 4: Morphological operation. Perform a closing operation on the total mask, then binarize the mask after the closing operation, use the dilation operation to further connect the adjacent areas, and finally filter the contours according to the area; the role of this step is to perform morphological processing on the merged mask, remove noise and connect disconnected areas;
[0107] Step 5: Filter contours. If the number of contours exceeds 800, redefine the color range and recreate the mask; if the area of the second largest contour is less than 32,000, re-search the contour; finally, filter the target contour based on the contour area and HSV value; the purpose of this step is to verify the number and quality of contours and ensure that the found contour is the target area;
[0108] Step 6: Extract the target area. Calculate the center of the target contour, and then cut out the target area according to the center coordinates and the predefined cropping range; the purpose of this step is to obtain the cell plane position and crop the rectangular area containing the target cell from the original image. The cut image is as follows Figure 4 shown.
[0109] In actual operation, the above steps can efficiently and accurately extract the two-dimensional position information of cells, providing basic data for subsequent depth estimation.
[0110] Example 4: Cell depth estimation method. This example describes in detail the implementation process of the cell depth estimation method. Figure 5 and Figure 6 As shown, the cell depth estimation method includes the following steps:
[0111] Step 1: Use self-supervised contrastive learning to pre-train a depth estimation model, which extracts depth features by comparing cell images at the same depth and at different depths;
[0112] Step 2: Fine-tune the model by combining the deep labels, matching the deep features learned by contrast with the real deep labels, and further optimizing the model parameters.
[0113] Step 3: Achieve high-precision depth estimation. The fine-tuned model can accurately estimate the depth information of cells, thereby achieving three-dimensional positioning of cells.
[0114] In actual operation, the above steps can achieve high-precision cell depth estimation, and combined with the two-dimensional positioning results, the three-dimensional positioning of the cells can be finally completed.
[0115] The above description is only a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent change made based on the technical essence of the present invention still falls within the scope of protection required by the present invention.
Claims
1. A three-dimensional cell positioning method based on self-supervised learning, characterized in that: The specific steps are as follows: 1) Build a micromanipulation system: Build an experimental system including a commercial inverted microscope, a micromanipulation system, and a computer to collect cell images and perform three-dimensional positioning; The micromanipulation system comprises: A Nikon TS-2 inverted microscope equipped with a 40x objective was used to capture cell images; MN30-18 micromanipulator system controls the movement of cells in the Z direction to obtain images at different defocus distances; 2) Dataset construction method: By adjusting the distance between the focal plane of the microscope and the cells, cell images at different defocus distances are collected to construct a dataset covering different positions, shapes, colors, numbers and background complexity of cells; 3) Cell 2D positioning method: Image processing technology, including filtering, mask application, thresholding, dilation operation, contour detection and other steps, is used to extract the 2D position information of cells; 4) Cell depth estimation method: Use self-supervised contrastive learning to pre-train the depth estimation model, extract depth features by comparing cell images of the same depth and different depths, and fine-tune them in combination with depth labels to achieve high-precision depth estimation.
2. The method for three-dimensional cell positioning based on self-supervised learning according to claim 1, characterized in that: The method for constructing the data set S2) comprises: Step 2.1, place the cell sample on a glass slide and mount it on a micromanipulator system, and adjust the focus of the microscope so that the cells are in the focal plane; Step 2.2, the micromanipulator system moves in the Z direction, 10 μm at a time, to capture cell images. For each cell, images with a defocus distance from -150 μm to 150 μm are captured, and a total of 3100 images of 100 cells are captured; Step 2.3, quantitative analysis of the images in the data set, including cell location distribution, cell number, cell area, cell color including H, S, V values, background complexity including impurity number and area, and cell shape.
3. The method for three-dimensional cell positioning based on self-supervised learning according to claim 1, characterized in that: The S3) two-dimensional cell positioning method comprises: Step 3.1, filtering, select 15*15 Gaussian kernel to filter the original image and remove Gaussian white noise; the role of step 3.1 is to pre-process the input image and reduce noise; Step 3.2, color segmentation, the color mode of the image is converted to HSV mode, then five masks are defined and some masks are preprocessed; the function of step 3.2 is to extract the target area according to the color features; The process of mask definition and preprocessing in step 3.2 is as follows: A series of points in the target area are randomly selected, and the HSV values of these points are analyzed. Masks are defined based on the analysis results. The detailed mask values are as follows: Mask 1: [20,35,100]-[130,200,225], Mask 2: [20,12,140]-[35,30,167], Mask 3: [12,18,189]-[35,30,220], Mask 4: [90,8,160]-[110,20,190], Mask 5: [30,19,174]-[36,36,180]; Then, Mask 1 and Mask 3 are blurred using the Gaussian kernel selected from the cv2.GaussianBlur function; Step 3.3, process and merge the masks, search for the contours of mask 2 to mask 5 in turn and calculate the contour areas, and sort the contours in mask 2 to mask 5 in descending order according to the area, then filter the masks according to the contour area, and finally merge mask 1 to mask 5 into one mask; the purpose of step 3.3 is to filter out valid masks and merge the valid masks into the total mask; The process of screening the mask according to the contour area in step 3.3 is as follows: Masks 2 to 5 are judged in turn, that is, whether the maximum contour area in the mask is less than 1000 pixels; if it is less than 1000 pixels, the mask is considered invalid and set to all black; if it is greater than 1000 pixels, no change is made; Step 3.4, morphological operation, close the total mask, then binarize the mask after the closing operation, and use the expansion operation to further connect the adjacent areas, and finally filter the contour according to the area; the role of step 3.4 is to perform morphological processing on the merged mask, remove noise and connect the disconnected areas; Step 3.5, filter the contours. If the number of contours exceeds 800, redefine the color range and recreate the mask. If the area of the second largest contour is less than 32,000, search for contours again. Finally, filter the target contour based on the contour area and HSV value. The purpose of step 3.5 is to verify the number and quality of contours and ensure that the found contour is the target area. Step 3.6, extract the target area, calculate the center of the target contour, and then crop the target area according to the center coordinates and the predefined cropping range; the purpose of step 3.6 is to obtain the cell plane position and crop a rectangular area containing the target cell from the original image.
4. The method for three-dimensional cell positioning based on self-supervised learning according to claim 3, characterized in that: The specific process of step 3.4 is as follows: Step 3.4.1, close the total mask, the closing kernel is a 5*5 rectangle and the number of iterations is 4; Step 3.4.2, binarize the mask after the closing operation. The binary processing logic is that if the pixel value is greater than 10, it is set to 255, otherwise it is set to 0; Step 3.4.3, dilate the binary mask, and the number of iterations of the dilation operation is 4; Step 3.4.4, find the contours in the expanded mask and extract the contour area. First, use the cv2.findContours function to find the closed contours in the mask, and then calculate the area of the extracted contours. Step 3.4.5, filter contours according to their area size, traverse all contours, and set the area of contours larger than 360,000 pixels to 0; Step 3.4.6, sort the contours in descending order according to their area, use np.argsort to sort the contours in descending order according to their area, then return the sorted index list, and rearrange the contours according to the sorted index.
5. The method for three-dimensional cell positioning based on self-supervised learning according to claim 4, characterized in that: The process of step 3.5 is as follows: Step 3.5.1, determine whether the number of contours is greater than 800; if the number of contours is greater than 800, create new mask 6 and mask 7, and merge the two masks into one, and then sequentially execute steps 3.4.1, step 3.4.4, step 3.4.5, step 3.4.6 and step 3.5.3 on the merged mask; if the number of contours is less than 800, execute step 3.5.2 sequentially; Step 3.5.2, determine whether the second largest contour area is less than 32,000 pixels; if the second largest contour area is less than 32,000 pixels, then proceed to step 3.4, step 3.5 and step 3.6 in sequence, wherein when performing step 3.5, the area of the contour of pixels with an area greater than 430,000 is set to 0; if the second largest contour area is greater than 32,000 pixels, then proceed to step 3.5.3; Step 3.5.3, verify whether the contour is a cell area, traverse the top three contours with contour areas greater than 30,000 pixels after sorting, then draw the current contour on the original image, extract the pixel coordinates of the contour area, calculate the HSV mean of the contour area, and record the index of the contour with saturation greater than 34 and hue less than 60.
6. The method for three-dimensional cell positioning based on self-supervised learning according to claim 5, characterized in that: The process of step 3.6 is as follows: Step 3.6.1, calculate the center coordinates of the contour, use the cv2.moments function to calculate the geometric moments of the target contour recorded in step 3.5.3, and calculate the x and y coordinates of the center of mass from the geometric moments; Step 3.6.2, define the cropping area, and define the cropping area as a 1300×1500 pixel area centered on the centroid; Step 3.6.3, perform boundary check and adjust the cropping area according to the centroid position to prevent the cropping area from exceeding the original image boundary; Step 3.6.4, crop the original image and save a copy to a specified location.
7. The method for three-dimensional cell positioning based on self-supervised learning according to claim 1, characterized in that: Step 4) The cell depth estimation method includes: The following steps are involved: Step 4.1, self-supervised contrastive learning pre-training: extract depth features and pre-train the depth estimation model by comparing cell images of the same depth and different depths; Step 4.2, depth label fine-tuning: combine the pre-trained model with the depth label and perform fine-tuning to convert the depth estimation task into a classification task. The depth range is divided into 31 categories, each with an interval of 10 microns, from -150 microns to 150 microns; Step 4.3, depth prediction: In the inference stage, the probability of the image belonging to each depth category is predicted through the classifier layer, and the category with the highest probability is selected as the depth estimation result, or a more accurate depth prediction value is obtained by weighted averaging the probabilities of multiple categories.
8. The method for three-dimensional cell positioning based on self-supervised learning according to claim 7, characterized in that: The step 4.1 of self-supervised contrastive learning pre-training includes: Step 4.1.1, using the contrastive learning framework, cell images at the same depth are considered as positive samples, and cell images at different depths are considered as negative samples; Step 4.1.2, perform two random data augmentations on each cell image, including random cropping, grayscale transformation, and random flipping, to generate two enhanced views; Step 4.1.3, the enhanced image is input into the encoder to extract features and projected through the multi-layer perceptron MLP; In step 4.1.4, supervised contrastive learning loss function is used to bring the features of images with the same depth closer, push the features of images with different depths farther away, and enhance the classification boundaries.
9. The method for three-dimensional cell positioning based on self-supervised learning according to claim 7, characterized in that: The step 4.2 of deep label fine-tuning includes: Step 4.2.1, divide the depth range into 31 categories, each category is 10 μm apart, ranging from -150 μm to 150 μm; Step 4.2.2, use the pre-trained encoder to extract image features and convert the features into a 31-dimensional vector through the classification layer, where each element represents the probability that the image belongs to the corresponding category; In step 4.2.3, the cross entropy loss function is used to minimize the difference between the predicted vector and the true label.
10. The method for three-dimensional cell positioning based on self-supervised learning according to claim 7, characterized in that: The step 4.3 depth prediction includes: Step 4.3.1, predict the probability of the image belonging to each depth category through the classifier layer, input the image into the pre-trained and fine-tuned model, and output a 31-dimensional probability vector through the classifier layer; In step 4.3.2, select the top k categories with the highest probability, where k is set to 3, and calculate their weighted average depth as the final depth prediction value.