Stacked cell level determination method and system based on multi-focal sharpness analysis
By employing a multi-focal-length sharpness analysis method, the problems of contour association and occlusion in stacked cell hierarchy determination are solved, achieving efficient and accurate cell hierarchy determination, which is applicable to the field of biomedical image processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN MUTUAL UNITED TECH CO LTD
- Filing Date
- 2026-05-08
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies have problems in determining the stacked cell hierarchy, such as difficulty in associating multi-focal contours, inaccurate completion of occluded contours, disordered positioning of overlapping areas, and lack of physical basis for hierarchical reasoning, which leads to misjudgment and insufficient adaptability.
By using a multi-focal-length sharpness analysis method, Z-stack multi-focal-length image sequences are obtained. A contour association data table is established using centroid and area features. An ellipse fitting algorithm is used to complete the occluded contours, locate overlapping areas, quantify sharpness differences, construct an attribute map, and perform topological sorting to achieve cell-level judgment.
It achieves stable correlation of the contour information of the same cell in images with different focal lengths, avoids misjudgment, accurately locates overlapping areas, ensures the physical rationality and accuracy of hierarchical judgment, and adapts to the high-throughput analysis needs of grassroots laboratories.
Smart Images

Figure CN122157255A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of biomedical image processing technology, specifically to a method and system for determining stacked cell hierarchy based on multifocal sharpness analysis. Background Technology
[0002] In the field of cell microscopy image analysis, accurately determining the hierarchical relationship of stacked cells is a key technical link connecting two-dimensional imaging and three-dimensional spatial analysis. Z-stack multifocal imaging technology acquires images layer by layer along the optical axis (Z-axis) by changing the focal plane with a fixed step size, forming an image sequence covering the spatial depth of the sample. Each layer of images corresponds to the imaging state of the sample at different Z-axis depths, which can fully present the morphological distribution of cells in three-dimensional space. With the increasing demand for precision medicine and high-throughput cell experiments, the determination of stacked cell hierarchy based on Z-stack images has become an important direction for the development of cell analysis technology.
[0003] However, existing technologies still have many limitations in determining the stacked cell hierarchy. Traditional morphological methods based on two-dimensional single-focal-length images can only infer the hierarchy using the morphological features of cells on a single plane, and cannot directly correlate with the actual spatial depth information of cells. For multi-layered stacked cells with similar morphologies, misjudgment of the hierarchy is easily caused by morphological confusion due to two-dimensional projection, and it is difficult to distinguish between overlapping cells in the same layer and occlusion cells in different layers, resulting in significant deficiencies in adaptability and robustness. Such methods do not take advantage of the multi-focal-length dimension of Z-stacks and are essentially still indirect inferences based on a two-dimensional plane, failing to overcome the technical bottleneck of missing spatial information.
[0004] Some existing technologies attempt to determine cell layers by comparing the mean grayscale values at different focal lengths in Z-stack images. Their core logic relies on the empirical characteristic that upper-layer cells have higher grayscale values in high-focal-length images. However, this characteristic is easily affected by factors such as uneven microscope illumination, differences in staining concentration, and fluctuations in sample transparency. For low-contrast cell samples (such as unstained live cells), the grayscale difference feature completely fails, failing to meet the needs of complex experimental scenarios. Even in Z-stack multi-focal-length image sequences, simply relying on grayscale features cannot avoid errors caused by imaging conditions, making it difficult to achieve stable judgments across samples and devices.
[0005] From the perspective of physical optics principles, existing technologies generally fail to fully utilize the core correlation characteristic of Z-stack images—the relationship between focal length and focus sharpness. Cells at different spatial depths correspond to optimal focus states on specific focal planes in a Z-stack image sequence. The core physical basis for this state is that upper-layer cells, located at higher spatial depths, correspond to larger focal length values (higher focal planes) in the Z-stack image, and their outlines achieve peak sharpness on these focal planes. Lower-layer cells, on the other hand, correspond to smaller focal length values (lower focal planes) and exhibit peak sharpness on these focal planes. This state is uniquely determined by the actual spatial position of the cells, directly reflecting their spatial hierarchy and unaffected by imaging conditions such as lighting and staining. Existing solutions either ignore this core physical clue or fail to effectively convert focus information into cell hierarchy relationships, making it difficult to achieve high-precision stacking hierarchy determination. Summary of the Invention
[0006] This invention proposes a method and system for determining the stacked cell hierarchy based on multi-focal sharpness analysis, in order to solve the technical problems existing in the prior art, such as difficulty in multi-focal contour association, inaccurate completion of occluded contours, disordered positioning of overlapping areas, and lack of physical basis for hierarchical reasoning.
[0007] The technical problems to be solved by this invention specifically include the following four aspects: First, how to efficiently associate the contour information of the same cell in different focal planes from Z-stack multi-focal images, avoid mismatch of contours under different focal lengths, and provide reliable cell-focal length-contour association data for subsequent analysis; Second, how to complete the occluded broken contours based on the natural morphology of cells through fitting algorithms, accurately determine the complete geometric range of cells, and avoid misjudgment of intersection relationships caused by incomplete contours; Third, how to accurately locate the overlapping areas of stacked cells, limit the scope of sharpness analysis to the key occluded areas, avoid interference from irrelevant areas, and improve the pertinence and accuracy of judgment; Fourth, how to quantify the sharpness differences of cell contours in Z-stack images, locate the optimal focal length of each cell, and establish rigorous occlusion relationship reasoning rules based on focal length to ensure the physical rationality of hierarchical judgment.
[0008] To address the aforementioned technical problems, this invention provides a method for determining stacked cell hierarchy based on multi-focal-length sharpness analysis, comprising the following steps: Step S1: Obtain a Z-stack multifocal image sequence of the same cell field of view, preprocess the Z-stack multifocal image sequence and extract the cell contours of each focal plane; Step S2: Based on the centroid coordinates and area features of the contour, establish a contour association data table for the same cell on different focal planes; Step S3: Use an ellipse fitting algorithm to complete the shape of the occluded cell contour and generate a complete geometric mask for the cell; Step S4: Based on the complete geometric mask, screen potential stacked candidate cell pairs that have spatial intersection, and locate the outline of the overlapping region of the potential stacked candidate cell pairs; Step S5: Calculate the outline sharpness of the overlapping area of each cell in the potential stacked candidate cell pair under multiple focal planes, determine the optimal focusing focal length of each cell, and determine the hierarchical relationship of the cells based on the size relationship of the optimal focusing focal length; Step S6: Construct the property graph and perform topological sorting to output the global stacking level sequence.
[0009] Preferably, in step S1, the method of obtaining the Z-stack multifocal image sequence includes: taking multiple images of the same cell field of view along the optical axis at a fixed focal length interval using a biological microscope, wherein the focal length interval ranges from 0.1 μm to 0.5 μm, keeping the objective lens type, exposure time, and light intensity consistent during shooting, and recording the focal length value corresponding to each image.
[0010] Preferably, in step S1, the preprocessing includes: grayscale conversion, Gaussian filtering smoothing, and adaptive threshold binarization; extracting the cell contours of each focal plane includes: using an edge detection algorithm to perform edge recognition on the preprocessed binary image and extracting the independent contour vertex set of each cell.
[0011] Preferably, in step S2, the method of establishing the contour association data table includes: calculating the centroid coordinates of each contour using the geometric moment method, counting the number of pixels enclosed by the contour as the area value; setting the matching condition as when the distance between the centroids of two contours is less than a first threshold and the area difference is less than a second threshold, determining them as different focal plane contours of the same cell, assigning a unique cell identifier to the successfully matched contours, and establishing an association data table of cell identifier, focal length value and contour coordinates.
[0012] Preferably, in step S3, the ellipse fitting algorithm adopts the least squares ellipse fitting algorithm, including: calculating the gradient value of the multifocal plane contour of each cell, and selecting the contour with the largest gradient value as the fitting basis; using the contour point set of the fitting basis as input, constructing an ellipse equation model, and solving the center coordinates, major axis, minor axis and rotation angle parameters of the ellipse by minimizing the distance error from the contour point to the ellipse; and generating a binary mask with the same size as the original image as the complete geometric mask based on the parameters.
[0013] Preferably, in step S4, the method of screening potential stacking candidate cell pairs includes: performing a bitwise AND operation on the complete geometric mask of any two cells; if the number of pixel values of 1 in the operation result is greater than a third threshold, they are determined to be overlapping cell pairs; for non-overlapping cell pairs, the straight-line distance between the centers of the two cell ellipses and the minimum Euclidean distance between the contour point pairs are calculated; if the preset proximity condition is met, they are determined to be neighboring cell pairs; the overlapping cell pairs and the neighboring cell pairs are integrated to form a potential stacking candidate set.
[0014] Preferably, in step S4, the method for locating the contour of the overlapping region includes: performing a bitwise AND operation on the complete geometric mask of the potential stacked candidate cell pairs to obtain a theoretical overlapping region mask; performing a morphological closing operation on the theoretical overlapping region mask to fill the holes, and obtaining an outer contour point set through edge detection and contour extraction; based on the original contour point set of the cells, using the nearest neighbor matching method to associate each point on the outer contour point set with the nearest original contour, eliminating error points whose distance exceeds a fourth threshold, and outputting the true contact edge contour point set of each cell as the contour of the overlapping region.
[0015] Preferably, in step S5, the gradient function is used as the evaluation index to calculate the sharpness of the overlapping region contour; the method for determining the optimal focusing focal length includes: calculating the average gradient value of the overlapping region contour of the cells under each focal plane to form a sharpness sequence, and determining the focal length corresponding to the peak value of the gradient value in the sharpness sequence as the optimal focusing focal length; the method for judging the hierarchical relationship includes: setting an error threshold, if the optimal focusing focal length of the first cell is greater than the sum of the optimal focusing focal length of the second cell and the error threshold, then it is determined that the first cell occludes the second cell in the upper layer, and if the absolute value of the difference between the optimal focusing focal lengths of the two cells is less than or equal to the error threshold, then it is determined that they are in the same layer.
[0016] Preferably, in step S6, the method of constructing the attribute graph includes: treating each cell as a node, with node attributes including cell identifier, ellipse parameters, and optimal focal length; for cell pairs with a clear occlusion relationship, establishing directed edges from the upper layer cell to the lower layer cell, with the weight of the edge being the absolute value of the difference between the optimal focal lengths of the two cells; for cell pairs with a same layer relationship, establishing undirected edges; and performing topological sorting includes: aggregating nodes connected by undirected edges into same-layer groups, calculating the average value of the optimal focal lengths within the group as the layer representative focal length, counting the in-degree of each same-layer group, enqueuing same-layer groups with an in-degree of zero in descending order of the layer representative focal length, iteratively extracting same-layer groups and adding them to the sorting result and updating the in-degree, and outputting the global stacked layer sequence.
[0017] This invention also provides a stacked cell hierarchy determination system based on multi-focal-length sharpness analysis, comprising: The image acquisition and preprocessing module is used to acquire Z-stack multifocal image sequences of the same cell field of view, preprocess the Z-stack multifocal image sequences, and extract the cell contours of each focal plane. The contour association module is used to establish contour association data tables for the same cell on different focal planes based on the centroid coordinates and area features of the contour. The morphological completion module is used to complete the morphological outline of the occluded cells using an ellipse fitting algorithm, generating a complete geometric mask for the cells. The candidate screening and localization module is used to screen potential stacked candidate cell pairs with spatial intersection based on the complete geometric mask, and to locate the outline of the overlapping region of the potential stacked candidate cell pairs. The clarity quantification and hierarchy judgment module is used to calculate the outline clarity of each cell in the potential stacked candidate cell pair under multiple focal planes, determine the optimal focusing focal length of each cell, and judge the hierarchy relationship of the cells based on the size relationship of the optimal focusing focal length. The topology sorting module is used to construct a property graph and perform topology sorting, outputting a global stacking hierarchy sequence.
[0018] The beneficial effects of the present invention include at least the following: (1) This invention achieves stable and efficient association of the contour information of the same cell in images with different focal lengths by using a cross-focal plane contour matching strategy of centroid and area. This fundamentally avoids the problem of misassociation of different cell contours or misjudgment of the same cell contour as multiple cells, and builds a highly reliable cell ID-focal length-contour basic data for subsequent analysis.
[0019] (2) This invention addresses the problem of outline breakage caused by cell occlusion. It utilizes the natural morphological characteristics of cells and employs the least squares ellipse fitting algorithm to restore the complete geometric shape of cells, generating an accurate cell geometric mask. This effectively overcomes the misjudgment of intersection relationships caused by incomplete outlines and provides a precise basis for subsequent spatial relationship analysis.
[0020] (3) This invention proposes a method for locating overlapping areas by fitting ellipse mask operation and outer contour correlation correction. Through mask operation, morphological processing and contour point allocation and screening based on geometric matching, the real contact edge between cells is accurately locked, eliminating the interference of fitting error and irrelevant areas, so that the clarity analysis and hierarchy judgment are fully focused on the key area where physical occlusion occurs.
[0021] (4) This invention quantifies the sharpness of the contour using a gradient function and establishes a hierarchical reasoning rule that directly correlates the sharpness peak with the spatial depth of the cell based on the physical law that the optimal focal length of the upper cell is higher. This makes the judgment of the occlusion relationship have a rigorous physical basis, avoids hierarchical reasoning confusion caused by subjective experience or invalid features, and ensures the physical rationality and accuracy of the results.
[0022] (5) This invention is highly compatible with the existing Z-stack imaging process. It can be deployed and implemented by simply adding a software analysis module. Experimenters do not need to master complex three-dimensional reconstruction technology to obtain cell-level information from familiar multifocal data, which is suitable for the high-throughput analysis needs of grassroots laboratories. Attached Figure Description
[0023] Figure 1 This is an overall flowchart of the stacked cell hierarchy determination method based on multi-focal sharpness analysis of the present invention; Figure 2 This is a flowchart of the multi-focal plane cell contour extraction and cross-focal correlation method of the present invention; Figure 3 This is a flowchart of the method for clear quantification and pairwise cell hierarchy determination in this invention; Figure 4 Example of a microscopic image of a stack of cells. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0025] This invention proposes a method for determining the stacked cell hierarchy based on multi-focal-length sharpness analysis. According to the physical law that cells at different spatial depths correspond to different optimal focal lengths in the Z-stack image, there is a one-to-one correspondence between cell spatial depth and optimal focal length. Upper-layer cells have greater spatial depth and higher optimal focal lengths, and their contour sharpness reaches its peak at the optimal focal length. Through a complete process from multi-focal-length contour association to fitting and completion, intersection filtering, sharpness quantification, and finally topological sorting, accurate determination of the cell stacking hierarchy is achieved.
[0026] like Figure 1 As shown, this embodiment of the invention provides a method for determining stacked cell hierarchy based on multi-focal-length sharpness analysis, including the following steps: Step S1: Obtain Z-stack multifocal image sequences of the same cell field of view, preprocess the Z-stack multifocal image sequences and extract the cell contours of each focal plane.
[0027] This step involves preparing basic data and is compatible with standard laboratory microscopy procedures, requiring no special equipment.
[0028] During the image acquisition phase, a series of Z-stack multifocal images were captured along the optical axis of the same cell field of view using a conventional biological microscope. During imaging, it was essential to ensure coverage of the entire focal plane containing the cell, with the focal length interval between adjacent focal planes set between 0.1 μm and 0.5 μm, preferably 0.2 μm (adjustable according to cell size and experimental precision requirements). Simultaneously, imaging conditions such as objective lens type, exposure time, and light intensity were kept consistent. Each image was associated with a unique focal length value Z, thus binding the image to relative depth. The image sequence acquired in this way can fully represent the focusing state of the cell at different spatial depths.
[0029] In the image preprocessing stage, a standardized processing procedure is sequentially performed on each acquired Z-stack image to remove interfering factors and highlight cell contour features. The preprocessing procedure includes three main steps: first, grayscale conversion is performed to convert the color image to a grayscale image, unifying the image color dimensions; then, Gaussian filtering is applied to smooth the image and suppress background noise; finally, adaptive threshold binarization is performed to achieve preliminary separation of cells from the background. For image data with high noise levels, additional smoothing or targeted denoising operations can be performed to further improve the stability of subsequent focus evaluation and contour extraction.
[0030] After preprocessing, an edge detection algorithm is used to identify edges in the preprocessed binary image. The set of cell contour vertices for each focal plane is obtained through edge detection and contour extraction algorithms, and the output format is a "list of focal length Z-contour point coordinates (x,y)," laying a reliable foundation for subsequent analysis steps.
[0031] Step S2: Based on the centroid coordinates and area features of the contour, establish a contour association data table for the same cell on different focal planes.
[0032] This step is as follows: Figure 2 As shown, by contour extraction and feature matching, the association between the same cell and different focal planes is established, constructing basic data across the entire focal length dimension. Since the Z-stack image sequence is an imaging of the same field of view on different focal planes, the same cell will present slightly different contours at different focal lengths. Feature matching is needed to achieve contour association across focal lengths.
[0033] Cross-focal-plane contour association is achieved by applying a "centroid + area" matching rule to the contours of each focal plane. Specifically, the centroid coordinates of each contour are calculated using the geometric moment method, and the centroid coordinates are obtained by averaging the coordinates of all contour points. Simultaneously, the number of pixels enclosed by the contour is counted as the area value. Matching conditions are set: when the centroid distance between two contours is less than a first threshold (e.g., 5 pixels) and the area difference is less than a second threshold (e.g., 10%), they are determined to be different focal-plane contours of the same cell.
[0034] A unique cell identifier (cell ID) is assigned to each successfully matched contour, ultimately establishing a "cell ID-focal length Z-contour coordinate" association data table. This data table will serve as the foundation for all subsequent analysis steps, and its accuracy directly affects the final hierarchical judgment result. Accurate matching is achieved through the centroid and area—two relatively stable geometric features under different focal planes—effectively avoiding the problem of misassociating heterocellular contours.
[0035] Step S3: Use an ellipse fitting algorithm to complete the shape of the occluded cell outline and generate a complete geometric mask for the cell.
[0036] This step addresses the issue of outline breakage caused by stacking. It utilizes the natural circular or elliptical shapes of most cells (such as red blood cells and round epithelial cells) and restores the complete shape through an ellipse fitting algorithm.
[0037] In the baseline contour selection stage, the gradient values of each contour are calculated for the multifocal plane contour of each cell. The Sobel operator is used to calculate the gradient components in the x and y directions respectively, and the gradient magnitude is then used as a sharpness index. The contour with the largest gradient value is selected as the baseline for fitting. This contour corresponds to the optimal focus state of the cell, has the highest sharpness, the most complete morphology, and can provide the most reliable data support for subsequent ellipse fitting.
[0038] In the least-squares ellipse fitting stage, the selected set of clear contour points is used as input to construct an ellipse equation model. The general equation of an ellipse can be expressed as: The coefficients satisfy the elliptic constraint condition. By minimizing the distance error from the contour points to the ellipse using the least squares method, the coordinates of the ellipse's center can be obtained. Core parameters include major axis a, minor axis b, and rotation angle θ.
[0039] In the complete mask generation stage, a binary mask with the same size as the original image is generated based on the solved ellipse parameters. Pixel values in the elliptical regions of the mask are set to 1, and pixel values in the background regions are set to 0. This mask serves as a digital representation of the complete geometric extent of the cell, providing a precise basis for subsequent intersection relationship determination. Through morphological completion, even if the cell outline appears broken due to occlusion, complete geometric morphological information can still be obtained.
[0040] Step S4: Based on the complete geometric mask, screen for potential stacked candidate cell pairs with spatial intersection and locate the outline of the overlapping region of potential stacked candidate cell pairs.
[0041] This step uses spatial relationship analysis to identify potentially stacked cell pairs, narrowing the scope of subsequent analysis to improve computational efficiency, and accurately locating overlapping areas to define the scope for sharpness analysis.
[0042] In the overlapping cell pair determination phase, for any two cells A and B, a bitwise AND operation is performed on the binary mask corresponding to their fitted ellipse. The number of pixels with a value of 1 in the result is counted. If this number is greater than a third threshold (e.g., 8 pixels, which can be adjusted according to the image resolution; this threshold has the best fit at 1024×1024 resolution), then the cells are determined to be overlapping cell pairs. This determination is based on physical logic: the existence of an intersection in the mask regions indicates that the two cells may have a spatial stacking and occlusion relationship.
[0043] In the adjacent cell pair determination stage, for non-overlapping cell pairs, the center distance d between the two cell ellipses is calculated. If d is less than 1.2 times the sum of the major axes of the two cell ellipses, and the minimum Euclidean distance between all point pairs on the outlines of the two cells does not exceed 2 pixels, then they are determined to be closely adjacent cell pairs. Although closely adjacent cells do not have obvious mask overlap, they still need to be included in subsequent analysis due to their extremely close spatial distance.
[0044] Overlapping cell pairs and neighboring cell pairs are integrated to form a potential stacking candidate set S. Each record is associated with information such as "cell ID pair (A,B) - spatial relationship type - ellipse parameter - distance data". Cells without spatial intersection or proximity relationships cannot physically stack or occlude each other, so they are not included in the candidate set, thus effectively narrowing the scope of subsequent calculations.
[0045] To avoid irrelevant areas interfering with sharpness analysis, the overlap range of intersecting cell pairs in the candidate set needs to be accurately located. First, a bitwise AND operation is performed on the fitted elliptical mask of the two cells to obtain a binary mask of the theoretically overlapping area. Then, a morphological closing operation is performed on this mask to fill in tiny holes, using a circular structuring element with a radius of 2 pixels. Next, the complete outer contour point set of the theoretically overlapping area is obtained through Canny edge detection (low threshold 30, high threshold 90) and contour extraction algorithms.
[0046] Because there is a certain error between the fitted ellipse and the actual cell contour, directly using the theoretical overlapping area may introduce bias. Therefore, based on the original contour point sets of two cells A and B, the nearest neighbor matching method is used to associate each point on the outer contour of the theoretical overlapping area with the nearest original contour. If the minimum distance between a point and all original contour points exceeds a fourth threshold (e.g., 3 pixels), it is determined to be a fitting error point and is removed. Through this correction process, the actual contact edge contour point set corresponding to each cell is separated and output, achieving accurate locking of the overlapping area and removal of fitting errors.
[0047] Step S5: Calculate the outline sharpness of the overlapping area of each cell in the potential stacked candidate cell pair under multiple focal planes, determine the optimal focal length of each cell, and judge the hierarchical relationship of the cells based on the size relationship of the optimal focal length.
[0048] like Figure 3 and Figure 4 As shown, this step is the core judgment process, relying on the physical law that the spatial depth of cells corresponds to the optimal focal length to achieve accurate judgment. The core principle of this physical law is: upper-layer cells are at a higher spatial depth and require a larger focal length to achieve optimal focus; while lower-layer cells are at a lower spatial depth and can achieve peak sharpness with a smaller focal length. By quantitatively analyzing the sharpness changes of cell outlines at different focal lengths, the optimal focal length for each cell can be accurately located, thereby determining their spatial hierarchy.
[0049] In the sharpness evaluation region localization stage, the set of actual contact edge contour points output in step S4 is used as the sharpness analysis region. The reason for choosing this region is that the overlapping area is the core edge where two cells occlude each other, and the sharpness difference between the two cells is most significant within this region, best reflecting the hierarchical relationship. Limiting the analysis scope to this can avoid interference from irrelevant areas in the sharpness evaluation.
[0050] During the optimal focusing focal length localization stage, the gradient function is used as the sharpness evaluation index. For the overlapping region contours of cells A and B under each focal plane Z, their average gradient values are calculated. After traversing all focal planes, a sharpness sequence for each cell is formed. The focal length corresponding to the peak gradient value in the sequence is determined as the optimal focusing focal length for the cell. The optimal focusing focal length of cell A is denoted as . The optimal focal length for cell B is denoted as .
[0051] In the hierarchical relationship determination stage, determination rules are established based on the optimal focal length. An error threshold of ±0.5μm is set (which can be adjusted according to the focal length acquisition interval), and the determination rules are as follows: If... If cell A is in the upper layer and blocks cell B, the blocking flow direction is A→B; If cell B is in the upper layer and blocks cell A, the blocking flow direction is B→A; If the distance is ≤0.5μm, the two cells are determined to be in the same layer, meaning they are at similar spatial depths and have no clear occlusion relationship. A cell pair occlusion relationship table is generated, recording the sharpness sequence, optimal focus length, and judgment result for each pair of cells.
[0052] Step S6: Construct the property graph and perform topological sorting to output the global stacking level sequence.
[0053] When multiple stacked cells exist within the field of view, step S5 yields the local occlusion relationships between pairs of cells. These local relationships need to be integrated into a globally consistent hierarchical sequence. This step achieves this goal by constructing an attribute graph and performing a topological sorting of the improved Kahn algorithm.
[0054] In terms of node definition, each cell is treated as a node in the graph, and node attributes include: cell identifier (cell ID), ellipse parameters (center coordinates). (major axis a, minor axis b, rotation angle θ), optimal focusing focal length (Focal length corresponding to the peak sharpness of the overlapping area) and the maximum sharpness value of the overlapping area.
[0055] The edge construction rules are as follows: For cell pairs within the potential stacking candidate set S, if based on... If the difference indicates a clear occlusion relationship, a directed edge (marked as a blue edge) is created. The edge direction is from the upper cell to the lower cell, consistent with the occlusion flow. The edge weight is set to two cells. absolute value of the difference The larger the difference, the clearer the occlusion relationship. If based on... The difference is determined to be a same level relationship (i.e.) If the thickness is less than 0.5μm, then an undirected edge (which can be marked as a red edge) is created, with a weight of 0, indicating that the two cells are at the same level.
[0056] In the topological sorting phase of the improved Kahn algorithm, the following steps are performed: First, homogeneous group aggregation is performed, aggregating nodes connected by undirected edges into homogeneous groups. These nodes are physically located at similar spatial depths. The average of the optimal focal lengths of all cells within the group is calculated as the representative focal length of the hierarchy, which will be used to determine the relative position of the homogeneous group in the global sequence.
[0057] Then, the in-degree is calculated, counting the in-degree of each group within the same layer. The in-degree is defined as the number of directed edges pointing to that group. An in-degree of 0 indicates that the group has no upper-layer occlusion, meaning it is at the top layer. Next, the queue is iterated, enqueuing all groups within the same layer with an in-degree of 0, and sorting them in descending order by the focal length represented by the layer level, which follows the physical law that higher focal lengths are placed at higher layers. Finally, the first group within the same layer is retrieved from the queue and added to the sorting result, all outgoing edges corresponding to that group are deleted, and the in-degree of the pointed-to group is updated. If the in-degree of a group drops to 0, it is enqueued again according to the descending order of the focal length represented by the layer level. This iteration continues until the queue is empty.
[0058] For potential node loops (i.e., occlusion relationships forming a cycle), the nodes within the loop are sorted from largest to smallest based on their optimal focal length to ensure the determinism of the sorting result. The final output is a structured global stacking hierarchy sequence, formatted as [A,(B,D),C], indicating that cell A is at the top layer, cells B and D are in the same middle layer, and cell C is at the bottom layer. A visualization can also be output, using different colors to mark cells at each level, labeling the cell ID and optimal focal length value, and visually displaying the stacking structure.
[0059] The present invention also provides a stacked cell hierarchy determination system based on multifocal sharpness analysis. The system includes six functional modules, which work together to achieve automatic cell hierarchy determination.
[0060] The image acquisition and preprocessing module is responsible for acquiring Z-stack multi-focal-length image sequences of the same cell field of view, performing grayscale conversion, Gaussian filtering smoothing, and adaptive threshold binarization on the image sequences, and using an edge detection algorithm to extract cell contours at each focal plane. The contour association module is responsible for performing cross-focal-plane matching based on the centroid coordinates and area features of the contours, and establishing a contour association data table for the same cell at different focal planes. The morphological completion module is responsible for using a least-squares ellipse fitting algorithm to complete the morphological contours of occluded cells, generating a complete geometric mask for the cell.
[0061] The candidate selection and localization module is responsible for screening potential stacked candidate cell pairs with spatial intersection based on a complete geometric mask, and locating the contours of the overlapping regions of the candidate cell pairs through mask operations and morphological processing. The sharpness quantification and hierarchy determination module is responsible for calculating the sharpness of the overlapping region contours of each cell in the candidate cell pair under multiple focal planes using a gradient function as an evaluation metric, determining the optimal focusing focal length for each cell, and determining the hierarchical relationship of the cells based on the magnitude of the optimal focusing focal lengths. The topology sorting module is responsible for constructing an attribute graph with each cell as a node, establishing directed or undirected edges based on occlusion relationships, performing topology sorting using an improved Kahn algorithm, and outputting a global stacking hierarchy sequence.
[0062] This implementation method is based on the existing Z-stack imaging workflow and can be deployed simply by adding a software analysis module. Researchers do not need to be proficient in 3D reconstruction techniques to obtain cell hierarchical information from familiar multifocal data, making it suitable for the high-throughput analysis needs of basic laboratories. Through the aforementioned sequential steps, this invention adds a clear and practical hierarchical determination link to the existing Z-stack imaging and cell contour analysis workflow. This allows researchers to directly obtain crucial information about cell layer relationships and global stacking sequences from familiar multifocal image data without changing microscope equipment.
[0063] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described; only preferred embodiments of the present invention are illustrated. The descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. As long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0064] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this invention should be determined by the appended claims.
Claims
1. A method for determining stacked cell hierarchy based on multi-focal-length sharpness analysis, characterized in that, Includes the following steps: Step S1: Obtain a Z-stack multifocal image sequence of the same cell field of view, preprocess the Z-stack multifocal image sequence and extract the cell contours of each focal plane; Step S2: Based on the centroid coordinates and area features of the contour, establish a contour association data table for the same cell on different focal planes; Step S3: Use an ellipse fitting algorithm to complete the shape of the occluded cell contour and generate a complete geometric mask for the cell; Step S4: Based on the complete geometric mask, screen potential stacked candidate cell pairs that have spatial intersection, and locate the outline of the overlapping region of the potential stacked candidate cell pairs; Step S5: Calculate the outline sharpness of the overlapping area of each cell in the potential stacked candidate cell pair under multiple focal planes, determine the optimal focusing focal length of each cell, and determine the hierarchical relationship of the cells based on the size relationship of the optimal focusing focal length; Step S6: Construct the property graph and perform topological sorting to output the global stacking level sequence.
2. The method according to claim 1, characterized in that, In step S1, the method of obtaining the Z-stack multifocal image sequence includes: taking multiple images of the same cell field of view along the optical axis at fixed focal length intervals using a biological microscope, wherein the focal length interval ranges from 0.1 μm to 0.5 μm, keeping the objective lens type, exposure time and light intensity consistent during shooting, and recording the focal length value corresponding to each image.
3. The method according to claim 1, characterized in that, In step S1, the preprocessing includes: grayscale conversion, Gaussian filtering smoothing, and adaptive threshold binarization; extracting the cell contours of each focal plane includes: using an edge detection algorithm to perform edge recognition on the preprocessed binary image and extracting the independent contour vertex set of each cell.
4. The method according to claim 1, characterized in that, In step S2, the method of establishing the contour association data table includes: calculating the centroid coordinates of each contour using the geometric moment method, counting the number of pixels enclosed by the contour as the area value; setting the matching condition as when the distance between the centroids of two contours is less than a first threshold and the area difference is less than a second threshold, determining them as different focal plane contours of the same cell, assigning a unique cell identifier to the successfully matched contours, and establishing an association data table of cell identifier, focal length value and contour coordinates.
5. The method according to claim 1, characterized in that, In step S3, the ellipse fitting algorithm adopts the least squares ellipse fitting algorithm, including: calculating the gradient value of the multi-focal plane contour of each cell, and selecting the contour with the largest gradient value as the fitting basis; using the contour point set of the fitting basis as input, constructing an ellipse equation model, and solving the center coordinates, major axis, minor axis and rotation angle parameters of the ellipse by minimizing the distance error from the contour point to the ellipse; and generating a binary mask with the same size as the original image based on the parameters as the complete geometric mask.
6. The method according to claim 1, characterized in that, In step S4, the method for screening potential stacking candidate cell pairs includes: performing a bitwise AND operation on the complete geometric mask of any two cells; if the number of pixel values of 1 in the operation result is greater than a third threshold, they are determined to be overlapping cell pairs; for non-overlapping cell pairs, the straight-line distance between the centers of the two cell ellipses and the minimum Euclidean distance between the contour point pairs are calculated; if the preset proximity condition is met, they are determined to be neighboring cell pairs; the overlapping cell pairs and the neighboring cell pairs are integrated to form a potential stacking candidate set.
7. The method according to claim 1, characterized in that, In step S4, the method for locating the contour of the overlapping region includes: performing a bitwise AND operation on the complete geometric mask of the potential stacked candidate cell pairs to obtain a theoretical overlapping region mask; performing a morphological closing operation on the theoretical overlapping region mask to fill the holes; obtaining the outer contour point set through edge detection and contour extraction; based on the original contour point set of the cells, using the nearest neighbor matching method to associate each point on the outer contour point set with the nearest original contour, eliminating error points whose distance exceeds a fourth threshold, and outputting the true contact edge contour point set of each cell as the contour of the overlapping region.
8. The method according to claim 1, characterized in that, In step S5, the gradient function is used as the evaluation index to calculate the sharpness of the overlapping region contour. The method to determine the optimal focal length includes: calculating the average gradient value of the overlapping region contour of the cells under each focal plane to form a sharpness sequence, and determining the focal length corresponding to the peak value of the gradient value in the sharpness sequence as the optimal focal length. The method to determine the hierarchical relationship includes: setting an error threshold; if the optimal focal length of the first cell is greater than the sum of the optimal focal length of the second cell and the error threshold, it is determined that the first cell occludes the second cell in the upper layer; if the absolute value of the difference between the optimal focal lengths of the two cells is less than or equal to the error threshold, it is determined that they are in the same layer.
9. The method according to claim 1, characterized in that, In step S6, the method of constructing the attribute graph includes: treating each cell as a node, with node attributes including cell identifier, ellipse parameters, and optimal focal length; for cell pairs with a clear occlusion relationship, establishing directed edges from the upper layer cell to the lower layer cell, with the weight of the edge being the absolute value of the difference between the optimal focal lengths of the two cells; for cell pairs with a same layer relationship, establishing undirected edges; and performing topological sorting includes: aggregating nodes connected by undirected edges into same-layer groups, calculating the average value of the optimal focal lengths within the group as the layer representative focal length, counting the in-degree of each same-layer group, enqueuing same-layer groups with an in-degree of zero in descending order of the layer representative focal length, iteratively retrieving same-layer groups and adding them to the sorting result and updating the in-degree, and outputting the global stacked layer sequence.
10. A stacked cell hierarchy determination system based on multi-focal length sharpness analysis, characterized in that, include: The image acquisition and preprocessing module is used to acquire Z-stack multifocal image sequences of the same cell field of view, preprocess the Z-stack multifocal image sequences, and extract the cell contours of each focal plane. The contour association module is used to establish contour association data tables for the same cell on different focal planes based on the centroid coordinates and area features of the contour. The morphological completion module is used to complete the morphological outline of the occluded cells using an ellipse fitting algorithm, generating a complete geometric mask for the cells. The candidate screening and localization module is used to screen potential stacked candidate cell pairs with spatial intersection based on the complete geometric mask, and to locate the outline of the overlapping region of the potential stacked candidate cell pairs. The clarity quantification and hierarchy judgment module is used to calculate the outline clarity of each cell in the potential stacked candidate cell pair under multiple focal planes, determine the optimal focusing focal length of each cell, and judge the hierarchy relationship of the cells based on the size relationship of the optimal focusing focal length. The topology sorting module is used to construct a property graph and perform topology sorting, outputting a global stacking hierarchy sequence.