A cell segmentation method and device based on spatial transcriptome data and a storage medium
Patent Information
- Application Number
- CN202611139169.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-16
AI Technical Summary
[0006]针对现有技术存在的空间转录组细胞分割高度依赖人工标注且单模态信息利用不足导致分割精度低的问题,本申请通过一种基于空间转录组数据的细胞分割方法、设备及存储介质,实现无需人工标注的高精度双模态细胞分割
第一,本申请通过基于染色图像形态学先验自动生成包含空间方向标签的无监督训练样本,从根本上摆脱了现有深度学习方法对大规模人工标注数据的依赖。与现有技术中需要将转录组学读出密度图作为额外通道输入并依赖标注数据训练机器学习模型的方式不同,本申请利用细胞核在染色图像中的固有形态学特征自动构建监督信号,实现了真正的无监督学习,显著提升了模型在不同组织类型、染色条件及测序平台间的泛化能力,可直接应用于新产生的、缺乏标注的空间转录组数据。
Smart Images

Figure CN122928893A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of bioinformatics and medical imaging computing technology, specifically to a cell segmentation method, device, and storage medium based on spatial transcriptome data. Background Technology
[0002] Spatial transcriptomics technology can simultaneously acquire gene expression and spatial location information from tissue sections, providing core support for analyzing the tissue microenvironment, cellular heterogeneity, and spatial expression patterns. Precise cell segmentation is a key step in upgrading site-level data to single-cell resolution, directly determining the reliability of subsequent cell typing, expression analysis, and spatial structure resolution.
[0003] Existing spatial transcriptome cell segmentation methods are mainly divided into two categories: one category is based solely on gene expression data for spatial clustering, without utilizing image morphology information, resulting in blurred cell boundary localization and insufficient segmentation accuracy; the other category relies solely on stained images, employing traditional algorithms or deep learning models such as watershed, Cellpose, and StarDist. Its performance is highly dependent on image resolution and staining quality, and it must rely on a large number of manually labeled samples for training, leading to a significant decrease in segmentation performance on unlabeled datasets.
[0004] Some existing technologies attempt to combine morphological markers with transcriptomics data for multimodal fusion. For example, they acquire multichannel protein images through high dynamic range scanning and use transcriptomics readout density maps as an additional input channel, then utilize machine learning algorithms for subcellular segmentation. However, these methods have the following technical limitations: First, they rely on existing cell segmentation results and lack cell segmentation capabilities themselves, only performing feature extraction and data association based on existing segmentation boundaries. Second, multimodal fusion remains at the data-level association level, simply splicing protein statistical features and transcriptomics data at the single-cell level without deep fusion at the feature level. Third, they still require a large amount of manually labeled data to train the segmentation model, limiting their generalization ability across different tissue types, staining conditions, or sequencing platforms. Finally, methods based on traditional segmentation algorithms or simple threshold clustering still fail to effectively address issues such as incomplete capture of cytoplasmic regions, low recognition rate of high-brightness stained regions, and poor gene expression consistency among cells of the same type.
[0005] In summary, the industry currently lacks a spatial transcriptome cell segmentation method that can deeply integrate bimodal information at the feature level without manual annotation and automatically generate continuous and complete cell boundaries, which severely restricts the accurate analysis of high-resolution spatial omics. Summary of the Invention
[0006] To address the problems of low segmentation accuracy caused by the high dependence on manual annotation and insufficient utilization of single-modal information in existing spatial transcriptome cell segmentation technologies, this application proposes a cell segmentation method, device, and storage medium based on spatial transcriptome data to achieve high-precision dual-modal cell segmentation without manual annotation.
[0007] To achieve the above objectives, this application adopts the following technical solution: A first aspect of this application provides a cell segmentation method based on spatial transcriptome data, comprising: acquiring spatial transcriptome data of a target tissue, the spatial transcriptome data including staining images and gene expression data; automatically generating unsupervised training samples containing spatial direction labels pointing from sampling points to the center of the cell nucleus based on morphological priors of the staining images; fusing gene expression features and local image morphological features of the sampling points using a bimodal feature extraction network, and jointly predicting the probability that the sampling points belong to the cell and the direction category pointing to the center of the cell nucleus; determining a direction vector based on the direction category, and converging the sampling points to the center of the cell nucleus through gradient flow iterative tracking to generate a cell segmentation result.
[0008] The above scheme eliminates the reliance on manually labeled data by constructing an unsupervised training sample generation mechanism and a dual-modal feature fusion prediction mechanism, and improves the accuracy and completeness of cell boundary localization by utilizing complementary information from gene expression and image morphology.
[0009] As one implementation, the automatic generation of unsupervised training samples containing spatial orientation labels pointing from sampling points to the center of the cell nucleus, based on the morphological prior of the stained image, includes: identifying the cell nucleus region in the stained image using a label-controlled watershed algorithm, and labeling sampling points within the cell nucleus region as positive samples; filtering negative samples from sampling points outside the cell nucleus region based on the staining signal intensity and the distance to the center of the cell nucleus; and generating spatial orientation labels pointing from sampling points to the center of the cell nucleus based on the spatial positional relationship between the sampling points and the center of the cell nucleus. This implementation utilizes image morphological priors to automatically construct positive and negative samples and orientation supervision signals, solving the bottleneck of deep learning models lacking labeled data in the field of spatial transcriptomics, while introducing orientation labels to enhance the model's perception of cellular spatial structures.
[0010] As one implementation method, a dual-modal feature extraction network is used to fuse gene expression features and local image morphological features of sampling points, and jointly predict the probability that the sampling point belongs to the cell and the directional category pointing to the cell nucleus center. This includes: extracting global gene expression features based on the gene expression sequence of the sampling point and its neighborhood through a first feature extraction branch; extracting local image morphological features based on a local image patch centered on the sampling point through a second feature extraction branch; concatenating the global gene expression features and local image morphological features along the channel dimension, and jointly outputting the probability and directional category through a fully connected layer. This implementation method captures expression consistency at the molecular level and morphological structure information at the physical level through a parallel dual-branch architecture, and performs deep fusion at the feature level, making the prediction results both consistent with biological expression patterns and closely resemble real cell morphology.
[0011] As one implementation method, a direction vector is determined based on the direction category, and sampling points are converged towards the cell nucleus center through gradient flow iterative tracking to generate cell segmentation results. This includes: mapping the direction category to a two-dimensional direction vector; iteratively updating the position of the sampling points based on the two-dimensional direction vector, causing the sampling points to move towards the cell nucleus center; stopping tracking when a preset termination condition is met, and grouping sampling points converged to the same cell nucleus center into the same cell, thus generating cell segmentation results. This implementation method transforms discrete classification prediction into continuous geometric flow field tracking, adaptively reconstructing cell boundaries through a gradient flow convergence mechanism, effectively solving the problem of incomplete segmentation in the cytoplasmic region in traditional methods.
[0012] As one implementation method, as described in the above-described unsupervised training sample generation method, negative samples are screened from sampling points outside the cell nucleus region based on the staining signal intensity and the distance to the cell nucleus center. This includes: identifying sampling points whose staining signal intensity is less than a first preset threshold and whose Euclidean distance to any cell nucleus center is greater than a second preset threshold as negative samples; and generating spatial direction labels pointing from the sampling points to the cell nucleus center based on the spatial positional relationship between the sampling points and the cell nucleus center. This includes: uniformly dividing a preset angle range into multiple direction intervals, and discretizing the direction pointing from the sampling points to the cell nucleus center into corresponding direction intervals, which serve as spatial direction labels. This implementation method screens high-confidence negative samples through dual constraints, avoiding interference from ambiguous boundary regions on training. Simultaneously, discretizing continuous directions to adapt to the output format of the classification network ensures the robustness of direction prediction.
[0013] As one implementation method, as described in the above implementation of the bimodal feature extraction network, the first feature extraction branch employs a Transformer encoder, which calculates the query matrix, key matrix, and value matrix through a self-attention mechanism to obtain global gene expression features. The second feature extraction branch employs a U-Net network structure, which includes an encoder downsampling layer, a decoder upsampling layer, and skip connection layers connecting the encoder downsampling layer and the decoder upsampling layer to extract local image morphological features. This implementation combines the advantages of Transformer in global long-range dependency modeling with the advantages of U-Net in local detail recovery, ensuring the comprehensiveness and accuracy of bimodal feature extraction.
[0014] As one implementation method, as described in the gradient flow iterative tracing implementation above, the position of the sampling points is iteratively updated based on the two-dimensional direction vector to move the sampling points towards the cell nucleus center. This includes: rounding the normalized two-dimensional direction vector to discretize the spatial grid, and updating the position coordinates of the sampling points based on the rounded direction vector; stopping tracing when a preset termination condition is met, and grouping the sampling points converging at the same cell nucleus center into the same cell to generate the cell segmentation result, including: determining that the cell nucleus center has been reached and stopping tracing when the angle between the gradient vectors corresponding to two consecutive iterations is greater than a preset angle threshold; post-processing the set of sampling points grouped into the same cell, removing cells with an area smaller than a preset area threshold, and merging cells with a center distance smaller than a preset distance threshold, and outputting the final cell segmentation mask. This implementation method prevents trajectory divergence in continuous space through discretized grid updates, and further improves the continuity and biological rationality of the cell segmentation mask by combining the angle termination condition and morphological post-processing.
[0015] As one implementation method, as described above, before fusing the gene expression features and local image morphological features of the sampling points using a bimodal feature extraction network, the method further includes: selecting the first preset number of genes with the highest total expression levels to construct a gene expression vector for each sampling point; and selecting a second preset number of spatially nearest sampling points along with the sampling point as the center to construct a gene expression sequence. This implementation method reduces noise and redundancy in the input data by screening for highly variable genes and constructing spatial neighborhood sequences, highlighting biologically discriminative feature information.
[0016] In addition, this application also provides a cell segmentation device based on spatial transcriptome data, including: a processor; a memory for storing a computer program; the processor executes the computer program to implement the cell segmentation method based on spatial transcriptome data as described above.
[0017] In addition, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the cell segmentation method based on spatial transcriptome data as described above.
[0018] The technical solution provided in this application has the following outstanding advantages compared with the prior art: First, this application fundamentally eliminates the dependence of existing deep learning methods on large-scale manually labeled data by automatically generating unsupervised training samples containing spatial orientation labels based on the morphological prior of stained images. Unlike existing technologies that require transcriptomic readout density maps as additional input channels and rely on labeled data to train machine learning models, this application automatically constructs supervised signals using the inherent morphological features of cell nuclei in stained images, achieving true unsupervised learning. This significantly improves the model's generalization ability across different tissue types, staining conditions, and sequencing platforms, and can be directly applied to newly generated, unlabeled spatial transcriptomic data.
[0019] Second, this application employs a dual-modal feature extraction network to parallelly fuse the global consistency of gene expression with the local structural information of image morphology, overcoming the low information utilization caused by simple channel splicing in existing technologies. Specifically, a Transformer encoder is used to globally model the gene expression sequence in the neighborhood of the sampling point, capturing the molecular expression consistency within the cell; a U-Net network is used to extract the morphological features of local image patches, perceiving the texture and contour of the cell; the two are deeply fused at the feature level and jointly predicted, making the prediction results both consistent with biological expression patterns and closely resemble the real cell morphology, resulting in more accurate intracellular probability prediction and orientation vector estimation.
[0020] Third, this application utilizes a gradient flow iterative tracking mechanism to transform discrete prediction results into a continuous cell boundary reconstruction process, which has significant technical advantages compared to existing methods based on traditional segmentation algorithms or simple threshold clustering. By mapping the predicted direction category to a two-dimensional direction vector, a vector field covering the entire tissue slice is constructed, and a discretized grid update strategy is adopted to prevent trajectory drift caused by floating-point cumulative errors. This ensures that sampling points belonging to the same cell can stably converge to the same cell nucleus center, not only completely capturing cytoplasm and extranuclear transcripts, but also effectively improving the segmentation robustness in high-brightness stained areas and weak boundary scenarios.
[0021] Fourth, this application further improves the segmentation quality through post-processing optimization, including removing noisy cells with too small an area and merging over-segmented cells with too close center distances, effectively filtering false cells caused by staining artifacts or signal sparsity, and correcting the situation where the same cell is split into multiple parts due to excessive segmentation in the initial cell nucleus detection. The final single-cell data has a higher gene detection rate and consistency with the expression of the same type of cells, providing a reliable data foundation for downstream cell typing, interaction analysis, and spatial resolution. Attached Figure Description
[0022] Figure 1 This is a flowchart / architecture diagram of the cell segmentation method (referred to as UTseg) based on spatial transcriptome data according to an embodiment of this application. a is a schematic diagram of the overall process / framework, b is a structural diagram of the Transformer gene expression feature integration module, and c is a network structure diagram of the improved U-Net module for image morphological feature extraction. Figure 2 These are comparison images of the cell segmentation results of the UTseg method used in this application embodiment and the existing SCS, Watershed, StarDist, and Cellpose methods on different datasets. a is an overview of the global segmentation results of the Seq-scope mouse liver dataset, b is an overview of the global segmentation results of the Stereo-seq mouse brain dataset, c is a magnified comparison of the segmentation results in the Seq-scope dataset, and d is a magnified comparison of the segmentation results in the Stereo-seq dataset. Figure 3 These are statistical graphs showing the analysis of the biological characteristics of cell segmentation using the UTseg method employed in the embodiments of this application and the existing SCS, Watershed, StarDist, and Cellpose methods. a is a bar graph of transcript allocation rate, b is a bar graph of cell number, c–d are box plots of single-cell transcript number and gene number, and e–f are scatter plots of gene expression ratio. Figure 4 This is a performance evaluation curve of the UTseg method used in the embodiments of this application and the cell segmentation algorithms of SCS, Watershed, StarDist and Cellpose in the prior art. a is a schematic diagram of the evaluation strategy, b-c are correlation violin plots, and d-e are pixel classification ratios in different gray ranges within the cell.
[0023] The modules are as follows: 101 - Input image for staining, 102 - Input gene expression data (center spot + neighbor spot), 103 - Unsupervised sample generation module, 104 - Transformer encoder, 105 - U-Net feature extractor, 106 - Feature fusion and joint prediction module, 107 - Gradient flow tracing module, and 108 - Cell segmentation mask output. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0026] Example 1 like Figure 1 As shown, this embodiment provides a cell segmentation method based on spatial transcriptome data. This method achieves high-precision single-cell analysis by performing multi-dimensional processing on biological tissue data with physical properties. It is a dual-modal deep learning cell segmentation framework (referred to as UTseg) that integrates image morphological features and gene expression features, and specifically includes the following steps.
[0027] Step S100: Obtain spatial transcriptome data of the target tissue. The spatial transcriptome data includes staining images and gene expression data.
[0028] Step S200: Based on the morphological prior of the stained image, automatically generate unsupervised training samples containing spatial orientation labels of sampling points pointing to the center of the cell nucleus.
[0029] Step S300: The dual-modal feature extraction network is used to fuse the gene expression features and local image morphology features of the sampling points, and jointly predict the probability that the sampling point belongs to the cell and the direction category pointing to the center of the cell nucleus.
[0030] Step S400: Determine the direction vector based on the direction category, and converge the sampling points to the center of the cell nucleus through gradient flow iterative tracing to generate cell segmentation results.
[0031] Specifically, in step S100, the spatial transcriptome data is not an abstract set of numbers, but a physical representation of real biological tissue sections. Among these, stained images (such as...) Figure 1 The input image (a) is obtained by imaging tissue sections using an optical microscope or fluorescence scanner, reflecting the morphological characteristics and spatial distribution of microscopic structures such as the cell nucleus and cytoplasm; gene expression data (e.g.) Figure 1 The example of filled spots (solid circles in image a) was obtained through in situ sequencing or probe hybridization techniques, recording the types and abundance of transcripts at specific spatial locations. In this embodiment, the staining image and gene expression data are registered and aligned in a spatial coordinate system, ensuring that each gene expression sampling point corresponds to a specific pixel location in the staining image. This physical alignment of multimodal data is the basis for subsequent fusion processing, ensuring the consistency of biological and morphological information in the same spatial dimension, thereby avoiding segmentation deviations caused by data misalignment.
[0032] Specifically, in step S200, since spatial transcriptome data typically lacks large-scale manual pixel-level annotation, this embodiment utilizes the inherent morphological prior knowledge of cell nuclei in stained images to construct a supervisory signal. Morphological priors refer to the fact that cell nuclei in stained images are usually characterized as bright, compact regions with certain geometric regularities; this physical characteristic can be automatically identified without relying on specific manual labels. Based on this, the system can automatically distinguish potential cell nucleus regions from background regions and calculate a spatial orientation label pointing to the center of its respective cell nucleus for each sampling point. This orientation label is essentially a geometric constraint, indicating the orientation of the sampling point relative to the cell center. Training samples generated in this way completely eliminate the dependence on manual annotation, belonging to an unsupervised or self-supervised learning paradigm. This not only significantly reduces data preparation costs but also enables the model to adapt to data from different staining conditions and tissue types, significantly improving the generalization ability of the method.
[0033] Specifically, in step S300, single image features are easily affected by staining quality, while single gene features lack fine spatial boundary information. This embodiment uses a dual-modal feature extraction network to process two types of data in parallel (e.g., Figure 1(a) The transformer and Unet extract gene expression features from the neighborhood of the sampling point to capture the molecular consistency within the cell. Simultaneously, they extract local image morphological features centered on the sampling point to perceive the cell's texture and contour. After deep fusion at the feature level, the network outputs two dimensions of prediction results: first, the probability that the sampling point is located within the cell, used to determine whether the point belongs to a valid cell region; and second, the direction category of the sampling point pointing towards the cell nucleus, used to indicate the point's relative position within the cell. This joint prediction mechanism allows the model to learn "whether it is a cell" and "which part of the cell" simultaneously, achieving complementary enhancement of molecular and morphological information, effectively solving the recognition challenges in areas with weak boundaries or low signal-to-noise ratios.
[0034] Specifically, in step S400, since the directional category output in step S300 is a discrete classification result, this embodiment maps it to a continuous two-dimensional directional vector, constructing a vector field covering the entire tissue slice. Based on this, a gradient flow iterative tracking algorithm is used to allow each sampling point to move gradually along the directional vector. During the iteration process, sampling points belonging to the same cell will gradually converge towards the same cell nucleus center, like flowing into a valley. When a preset termination condition is met, all sampling points converging to the same center are classified as the same cell instance, thus generating the final cell segmentation mask. This clustering mechanism based on geometric flow fields transforms discrete pixel-level prediction into continuous instance-level segmentation, not only naturally forming smooth, closed cell boundaries but also completely capturing cytoplasmic regions and extranuclear transcripts, overcoming the shortcomings of traditional semantic segmentation methods that easily produce fragmented masks or miss cytoplasmic regions.
[0035] It should be understood that, although Figure 1 The sequential execution flow of the above steps is illustrated. However, in practical applications, as long as the logical causal relationship of the data flow is maintained, the specific implementation of each step can be flexibly adjusted. For example, the specific architecture of the bimodal feature extraction network can be diverse, and the iterative strategy of gradient flow tracing can also be adapted according to the data resolution. As long as the mapping function from multimodal data to cell instance segmentation can be achieved, it falls within the protection scope of this embodiment.
[0036] More specifically, such as Figure 1The overall process shown in Figure a involves selecting the 50 spatial nearest neighbor sampling points (hollow spots) for the target sampling point to be predicted (filled spot). Gene expression information and spatial coordinate information are input into the Transformer encoder to extract gene expression feature vectors. Simultaneously, a 64×64 local stained image patch is cropped centered on the target sampling point, and image morphological feature vectors are extracted using U-Net. After concatenating the two feature vectors, two fully connected layers are used to predict whether the sampling point is located inside the cell (binary classification) and its direction pointing towards the cell nucleus center (16-class classification).
[0037] More specifically, such as Figure 1 b shows the Transformer gene expression feature integration module (Transformermodule / Transformer module), x0, x1, ..., x 50 These are the gene expression vectors of the central sampling point and its 50 neighboring sampling points, respectively; s0, s1, …, s 50 This provides the spatial coordinates of each sampling point. After global modeling by the Transformer encoder, the feature vector z0 corresponding to the central sampling point is extracted from the output as the gene expression feature.
[0038] More specifically, such as Figure 1 The improved U-Net network structure (U-Netmodule) shown in c for image morphological feature extraction consists of an encoder on the left, containing three downsampling modules (with 64, 128, and 256 convolutional kernels respectively); a bottom layer with 512 convolutional kernels; and a decoder on the right, containing three upsampling modules. The feature maps of the corresponding layers of the encoder are fused through skip connections, and finally, a 64-dimensional image feature vector is obtained through global max pooling.
[0039] It should be understood that the specific number of sampling points, convolutional kernels, and feature vector dimensions in this embodiment are exemplary and should not be construed as the sole limitation on the specific implementation of the solution. Specific implementations using other quantities or dimensions under the same or similar architecture as this embodiment are all within the protection scope of this embodiment.
[0040] Example 2 In this embodiment, the specific generation mechanism of unsupervised training samples and orientation labels in step S200 is described in detail.
[0041] As one implementation method, based on the morphological prior of the stained image, unsupervised training samples containing spatial orientation labels pointing from sampling points to the center of the cell nucleus are automatically generated, including: using a label-controlled watershed algorithm to identify the cell nucleus region in the stained image and marking the sampling points within the cell nucleus region as positive samples; filtering negative samples from sampling points outside the cell nucleus region based on the staining signal intensity and the distance to the center of the cell nucleus; and generating spatial orientation labels pointing from sampling points to the center of the cell nucleus according to the spatial positional relationship between the sampling points and the center of the cell nucleus.
[0042] Specifically, in step S201, the label-controlled watershed algorithm is used to identify the cell nucleus region in the stained image, and sampling points within the cell nucleus region are labeled as positive samples. The label-controlled watershed algorithm is an image segmentation method based on morphological gradients. Its core idea is to treat the image as a terrain surface, with pixel grayscale values representing altitude, and to find catchment basins by simulating a flood inundation process. In this embodiment, since the cell nucleus in the stained image typically appears as a locally bright and compact region, the algorithm can automatically use these bright regions as seed points (markers), expanding along the gradient descent direction until it encounters a boundary, thereby accurately segmenting the cell nucleus mask. Sampling points located inside this mask are assigned a positive sample label (e.g., a label value of 1). This process relies entirely on the physical morphological features of the image itself, requiring no manual annotation, fundamentally solving the problem of the lack of pixel-level ground truth labels in spatial transcriptome data, and providing a reliable source of supervisory signals for subsequent model training.
[0043] Step S202: Determine the coordinates of the cell nucleus center. Given the potential irregularity in cell nucleus shape, this embodiment employs a weighted centroid method to calculate the geometric center of each cell nucleus region, replacing a simple arithmetic mean. This improves the robustness of center localization to staining inhomogeneities. The specific calculation logic is as follows: For each identified cell nucleus region, all sampling points within that region are traversed. Using the staining signal intensity of each sampling point as a weight, the spatial coordinates of each sampling point are weighted and averaged. The resulting weighted average is the center coordinate of the cell nucleus. This calculation method makes the center point more likely to fall at the location of the deepest staining, most likely the true physical center of the cell nucleus, rather than merely at the center of the geometric outline. This effectively avoids center offset caused by weak staining at the cell nucleus edges or shape distortion, providing a precise reference origin for subsequent directional label calculations.
[0044] Step S203: Based on the staining signal intensity and the distance to the center of the cell nucleus, negative samples are screened from sampling points outside the cell nucleus region. Further, sampling points with staining signal intensity less than a first preset threshold and an Euclidean distance to any cell nucleus center greater than a second preset threshold are identified as negative samples. This dual screening condition has clear physical significance and technical considerations. First, the condition of staining signal intensity less than the first preset threshold (e.g., grayscale value less than 10) is used to exclude background noise regions, because although the true cytoplasm region is darker than the cell nucleus, it still has a certain staining signal, while pure background regions often have extremely low and random signals. Second, the condition of an Euclidean distance to any cell nucleus center greater than the second preset threshold (e.g., 30 pixels) is used to exclude uncertain boundary regions between cell nuclei, because the belonging relationship between two adjacent cell nuclei is often ambiguous. Forcibly labeling these sampling points as negative samples would cause the model to learn incorrect boundary features. Only sampling points that simultaneously meet both conditions are identified as high-confidence extracellular background negative samples (e.g., label value of 0). This rigorous negative sample construction strategy ensures the semantic purity of positive and negative samples in the training set, enabling the model to clearly distinguish between "intracellular" and "deterministic background" rather than causing confusion in ambiguous areas, thus significantly improving the model's discrimination ability in complex tissue environments.
[0045] Step S204: Based on the spatial relationship between the sampling point and the center of the cell nucleus, generate a spatial direction label pointing from the sampling point to the center of the cell nucleus. Specifically, the preset angle range is uniformly divided into multiple direction intervals, and the direction pointing from the sampling point to the center of the cell nucleus is discretized into the corresponding direction intervals, serving as spatial direction labels. In actual processing, the azimuth angle of each positive sample sampling point relative to its respective cell nucleus center is first calculated. This azimuth angle is a continuous value from 0 to 360 degrees. To adapt to the classification output format of deep learning networks, the continuous angle space needs to be discretized. As a preferred implementation, 360 degrees is uniformly divided into 16 direction intervals, each interval covering 22.5 degrees. The direction label of the sampling point is the interval index (0 to 15) into which its azimuth angle falls. It should be understood that 16 directions is only a preferred example that balances directional resolution and classification difficulty. In other embodiments, 8, 12, 24, 32, or even more direction intervals can be selected according to cell size, image resolution, or model capacity. A smaller number of intervals (e.g., 8) reduces classification complexity but sacrifices boundary fineness, while a larger number of intervals (e.g., 32) improves boundary fitting accuracy but increases training difficulty. Regardless of the chosen granularity, the essence is to transform a continuous geometric vector field into discrete semantic categories, enabling the network to learn spatial orientation information through the standard cross-entropy loss function, thereby providing the necessary vector guidance for subsequent gradient flow tracing.
[0046] The specific mechanism for generating the unsupervised training samples and orientation labels described above can be illustrated by the following steps: 1) Cell nucleus region identification: For the input stained image, the label control watershed algorithm is used to segment the cell nucleus region, and the spatial transcriptome sampling points corresponding to the pixels in the cell nucleus region are labeled as positive samples (label = 1).
[0047] 2) Negative sample screening rules: Negative samples must simultaneously meet the following conditions: The corresponding pixel coloring signal intensity (grayscale value) is <10; The Euclidean distance to the center of any cell nucleus is greater than 30. Sampling points that meet the conditions are marked as negative samples (label = 0).
[0048] 3) Calculation of cell nucleus center coordinates: Assume the cell nucleus contains n sampling points with coordinates as follows: The center of the cell nucleus ( for: .
[0049] 4) Generation of 16-directional labels: Divide 360° evenly into 16 directional categories, and assign a directional label d to the sampling point pointing to the center of the cell nucleus. i Calculate using the following formula: Where i is the index number of the sampling point within the cell nucleus, ranging from 1 to n, and n is the total number of sampling points contained within the current cell nucleus region. The coordinates of the cell nucleus center ( It is calculated from the arithmetic mean of the coordinates of all sampling points in the region.
[0050] Example 3 In this embodiment, the data preprocessing, network architecture, and specific implementation of the bimodal feature extraction network in step S300 are described in detail. As one implementation method, before fusing the gene expression features and local image morphological features of the sampling points using the bimodal feature extraction network, the method further includes: selecting the first preset number of genes with the highest total expression levels to construct the gene expression vector for each sampling point; and selecting the second preset number of spatially nearest sampling points along with the center sampling point to construct the gene expression sequence.
[0051] Specifically, raw spatial transcriptome data typically contains tens of thousands of gene loci, many of which are low-expressed or background noise. Directly inputting these into a network not only results in massive computational redundancy but also introduces interference signals. This embodiment selects the top 100 genes (e.g., 2000) with the highest total expression levels, retaining the most biologically variable and discriminative high-variability genes, thereby reducing data dimensionality while highlighting effective molecular features. Furthermore, considering that gene counts at individual sampling points often exhibit sparsity and dropout phenomena, single-point information alone is insufficient to accurately characterize cell states. Therefore, this embodiment selects a second 1000 spatially nearest neighbor sampling points (e.g., 50) centered on the target sampling point, which, together with the central sampling point, constitute a local gene expression sequence. This sequence construction method transforms discrete point data into sequence data with spatial context, enabling subsequent feature extraction modules to perceive expression gradients and continuity within the microenvironment, effectively mitigating the noise problem of single-point data and laying a data foundation for capturing the expression consistency within cells.
[0052] Building upon this, a dual-modal feature extraction network is used to fuse gene expression features and local image morphological features of sampling points, and jointly predict the probability that a sampling point belongs to a cell and the direction category pointing towards the cell nucleus center. This process is specifically implemented through two parallel feature extraction branches. The first feature extraction branch extracts global gene expression features based on the gene expression sequences of the sampling point and its neighborhood. As a preferred implementation, the first feature extraction branch employs a Transformer encoder, which calculates the query matrix, key matrix, and value matrix through a self-attention mechanism to obtain global gene expression features. Specifically, the Transformer encoder maps the aforementioned constructed gene expression sequence into three sets of matrices: query, key, and value, and calculates the association weights between sampling points within the sequence through a scaled dot product attention mechanism. This self-attention mechanism breaks the local receptive field limitation of traditional convolutional networks, enabling the capture of long-range dependencies across the entire neighborhood sequence. This allows sampling points belonging to the same cell to establish strong associations through similar expression patterns, even if they are spatially distant, thereby extracting global gene expression features that characterize the overall cell identity. It should be understood that the Transformer encoder is only a preferred implementation. In other embodiments, bidirectional LSTM, GRU or other neural networks with sequence modeling capabilities can be used instead, as long as they can achieve the function of extracting global contextual features from the neighborhood sequence.
[0053] As a more specific implementation, the aforementioned first feature extraction branch (Transformer encoder) can be illustrated / principled as follows and implemented: 1) Gene Screening: First, the sum of transcript counts for each gene across all sampling points is calculated as the total expression level of that gene. All genes are then sorted in descending order of total expression level, and the top 2000 genes with the highest total expression levels are selected for subsequent feature construction. After selecting these 2000 genes, a 2000-dimensional gene expression vector is constructed for each sampling point, where each dimension represents the transcript count of the corresponding gene detected within that sampling point region. This is denoted as: , .
[0054] 2) Neighborhood sequence construction: Centered on the target sampling point, select 50 spatial nearest neighbor sampling points, totaling 51 points including the center point, and embed them into a 64-dimensional matrix to form the input matrix: .
[0055] 3) Self-attention calculation: Generate query matrix Q, key matrix K, and value matrix V: , in: The Query weight matrix maps the input vector to a query vector, which represents the information that needs to be "queried" at the current sampling point. The Key weight matrix maps the input vector to a key vector, which represents the features that can be "matched" at each sampling point; The Value weight matrix maps the input vector to a value vector, representing the actual information content carried by each sampling point.
[0056] , , These are all trainable parameter matrices that the model learns automatically during training. Each row of the input matrix R represents a sampling point. After linear transformation, each row of Q, K, and V corresponds to the query vector, key vector, and value vector of the corresponding sampling point, respectively.
[0057] Attention weight calculation: , Where d k dk is the dimension of the key vector, and its value is equal to the dimension of the input embedding vector. In this invention, each sampling point is mapped to a 64-dimensional embedding vector, hence dk = 64. Dividing by dk scales the dot product result, preventing the dot product value from becoming too large when dk is large, which could cause the Softmax function to enter the saturation region and thus cause the gradient vanishing problem.
[0058] K T:K T Let Q represent the transpose of the bond matrix K. T Matrix multiplication (Q × K) T The unnormalized attention score between the query vector of each sampling point and the key vector of all sampling points was calculated.
[0059] The softmax function is defined as follows: for an input vector x = (x1, x2, …, x…) n The output of its i-th component is: , This function transforms each row of the attention score matrix into a probability distribution, ensuring that the sum of all elements in each row is 1. The attention weights, normalized by Softmax, are then used to perform a weighted summation of the value matrix V, achieving adaptive aggregation of relevant sampling point information.
[0060] 4) Feedforward Neural Network (MLP): Where W1 and W2 are weight matrices, and b1 and b2 are bias terms. The ReLU (Rectified Linear Unit) activation function is defined as: ReLU(x) = max(0, x). That is, it outputs 0 when the input value is negative and outputs its original value when the input value is positive. Its function is to introduce non-linear transformation capabilities into neural networks, enabling the model to learn complex feature representations. At the same time, its simple form helps alleviate the gradient vanishing problem in deep networks and accelerates training convergence.
[0061] 5) Feature Output: The Transformer encoder consists of eight identical encoder layers stacked sequentially. The computation process for each encoder layer is as follows: (1) The input is normalized by layer and then fed into the multi-head self-attention module. The Q, K, V matrices and attention-weighted output are calculated according to the above formula. (2) The self-attention output and the input are connected by a residual connection and then normalized by layer. (3) The normalization result is fed into the feedforward neural network (MLP) and subjected to two linear transformations and ReLU activation. (4) The MLP output and the normalization result of step (2) are connected by a residual connection again to obtain the final output of the encoder layer, which is used as the input of the next encoder layer.
[0062] After being processed sequentially by 8 layers of encoders, the final output matrix is obtained.
[0063] The Transformer output matrix is: , Its size is consistent with the input matrix R, which can be regarded as consisting of 51 vectors z0, z1, z2, ..., z 50 The sequence consists of vectors that represent the gene expression feature vectors of the sampled points after fusing global information. The study selects the vector z0 corresponding to the sampled point to be classified for subsequent model prediction and classification tasks. At this point, the feature vectors of the sampled point to be classified have been optimized using the model, while also incorporating the associated feature information from other local sampled points.
[0064] Simultaneously, a second feature extraction branch extracts local image morphological features based on local image patches centered on sampling points. As a preferred implementation, the second feature extraction branch employs a U-Net network structure, which includes an encoder downsampling layer, a decoder upsampling layer, and skip connection layers connecting the encoder downsampling layer and the decoder upsampling layer to extract local image morphological features. Specifically, the encoder progressively extracts high-level semantic features of the image and expands the receptive field through multi-level convolution and pooling operations; the decoder progressively restores the spatial resolution of the feature map through upsampling operations. To address the issue of detail loss during decoding, this embodiment specifically utilizes skip connection layers to directly transmit and stitch the high-resolution feature maps of corresponding layers in the encoder to the feature map of the decoder. This design enables the network to recover high-frequency detail information such as edges and textures from the encoder while restoring the spatial dimensions, thereby accurately perceiving microscopic morphological structures such as cell membranes and cytoplasm. It should be noted that although this embodiment uses U-Net as an example, in practical applications, any convolutional neural network with an encoder-decoder structure and a multi-scale feature fusion mechanism (such as ResNet-U-Net, EfficientNet-UNet, etc.) can be used as an alternative to the second feature extraction branch. Its core purpose is to balance semantic understanding and boundary localization capabilities.
[0065] As a more specific implementation, the aforementioned second feature extraction branch (U-Net network) can be exemplarily / in principle described and implemented as follows: 1) Image input: A 64×64 local image patch centered on the target sampling point is cropped and input into U-Net.
[0066] The 64×64 local image patch, after pixel value normalization (scaling the grayscale values to the [0, 1] range), is directly used as the initial input tensor X0 of the U-Net encoder, i.e., the input of the first layer of the encoder. X0 has dimensions of 1×64×64 (single-channel grayscale image, 64 pixels high and 64 pixels wide). X0 does not come from the output of other steps in this method, but is directly obtained from the raw image data cropped from the original stained image.
[0067] 2) Encoder downsampling: , Where X i For the input tensor of each layer, X i+1 For the output tensor, Conv3×3(.) represents a 3×3 convolutional layer, and MaxPool2×2(.) represents a max pooling layer.
[0068] The number of convolutional kernels are 64, 128, and 256, respectively; Low-level output: .
[0069] 3) Decoder upsampling and skip connections: 4) Image feature output Global max pooling yields a 64-dimensional image feature vector: .
[0070] After completing dual-path feature extraction, global gene expression features and local image morphological features are concatenated along the channel dimension, and the probabilities and orientation categories are jointly output through a fully connected layer. Specifically, the channel-dimensional concatenation achieves positive interaction between molecular and morphological information: when image features are blurred due to uneven staining, gene features can provide reliable identity verification; conversely, when gene expression is missing due to technical noise, image features can maintain the integrity of the boundaries. The concatenated fused feature vector is fed into a shared fully connected layer for multi-task learning, simultaneously outputting binary intracellular probabilities and multi-class orientation categories. This joint prediction mechanism forces the network to find common representations between the two tasks during the learning process, avoiding single-task overfitting and significantly improving the model's robustness and generalization ability in complex tissue scenarios.
[0071] As a more specific implementation, the aforementioned dual-modal feature fusion and joint prediction steps can be exemplarily described and implemented as follows: 1) Feature splicing: Gene expression features and image features are spliced together in the channel dimension to form a unified high-dimensional representation vector.
[0072] 2) Dual-task prediction: Synchronous output through two fully connected layers: Binary classification: the probability y that the sampling point is located inside the cell. i ; 16. Classification: Direction pointing towards the center of the cell nucleus (Category d) i .
[0073] 3) Post-processing: For probability y i Perform 3×3 neighborhood smoothing and filter y i Sampling points with a value <0.1 are considered extracellular regions.
[0074] Example 4 In this embodiment, the specific implementation process of determining the direction vector based on the direction category and generating the cell segmentation result through gradient flow iterative tracing in step S400 is described in detail. As one implementation method, the direction vector is determined based on the direction category, and the sampling points are converged towards the center of the cell nucleus through gradient flow iterative tracing to generate the cell segmentation result. This process essentially transforms the discrete semantic prediction output by the deep learning model into an instance clustering process in a continuous geometric space, aiming to solve the problem that traditional semantic segmentation methods struggle to handle cell adhesion and boundary ambiguity.
[0075] Specifically, the process includes the following sub-steps. Step S401: Mapping the orientation category to a two-dimensional orientation vector. In the aforementioned embodiment, the model outputs a discrete orientation category index (e.g., an integer from 0 to 15). To perform displacement calculations in a continuous image coordinate system, this needs to be converted into a unit vector with a defined geometric orientation. Specifically, for each sampling point, based on its predicted orientation category index... Calculate the corresponding two-dimensional unit vector using trigonometric functions. ,in This is the center angle of the interval corresponding to this directional category. This mapping mechanism establishes a bridge between the discrete classification space and the continuous physical space, enabling each sampling point to obtain a definite motion trend.
[0076] Step S402: Iteratively update the position of the sampling point based on the two-dimensional direction vector, causing the sampling point to move towards the center of the cell nucleus. During this process, to prevent trajectory drift caused by accumulated floating-point operation errors and ensure that the sampling points can accurately converge to discrete pixel grid points, this embodiment employs a discretized grid update strategy. Specifically, the normalized two-dimensional direction vector is rounded to discretize the spatial grid, and the position coordinates of the sampling point are updated based on the rounded direction vector. For example, if the current sampling point position is... The predicted unit direction vector is Then the position at the next moment Updated to ,in This indicates that the vector components are rounded to the nearest integer. The key technical effect of this design is that spatial transcriptome data is essentially defined on a discrete grid. If floating-point numbers are used directly for position updates, the trajectory of the sampling points may wander in the gaps between pixels and fail to converge stably to the same integer coordinate point, resulting in a large number of fragmented pseudo-cells during the final clustering. By introducing the rounding operation, the sampling points are forced to jump only between valid grid nodes, geometrically ensuring that sampling points belonging to the same cell will inevitably converge to the exact same sink coordinates, thereby significantly improving the connectivity and integrity of the segmentation results.
[0077] Step S403: When a preset termination condition is met, tracking stops, and sampling points converging at the same cell nucleus center are grouped into the same cell, generating a cell segmentation result. To accurately determine whether a sampling point has reached the target sink and avoid oscillations caused by noise or local extrema, this embodiment sets a dynamic termination criterion based on the vector angle. Specifically, when the angle between the gradient vectors corresponding to two consecutive iterations is greater than a preset angle threshold, it is determined that the cell nucleus center has been reached and tracking stops. In other words, if in the... The displacement vector at the next iteration With the The displacement vector at the next iteration The angle between Exceeding the preset threshold (e.g.) or close to This indicates that the direction of motion of the sampling point has been drastically reversed or has entered a stable attraction region near the sink, at which point the tracking can be considered complete. Compared to termination strategies that rely solely on displacement magnitude or a fixed number of iterations, the criterion based on the vector angle is more adaptable to cells of different sizes and shapes, effectively preventing invalid oscillations near the cell center or premature truncation before reaching the center.
[0078] As a more specific implementation, the steps for cell segmentation using gradient flow tracing described above can be illustrated / principled as follows and implemented: 1) Direction Vector Mapping: Converts 16 types of directions into two-dimensional unit vectors: Where α is the central angle of the direction interval. (The central angle α of the direction interval is missing from the original text.) k The calculation method is as follows: Divide 360° (i.e., 2π radians) evenly into 16 directional intervals, each interval spanning 22.5° (i.e., π / 8 radians). For the k-th direction (k = 0, 1, 2, …, 15), the central angle corresponding to this directional interval is: α k = k × 22.5° = k × π / 8 radians.
[0079] For example, the central angle corresponding to direction 0 is 0° (directly to the right), the central angle corresponding to direction 4 is 90° (directly above), and so on. The two-dimensional unit vector for each direction is (cosα) k sinα k ).
[0080] 2) Gradient Flow Iterative Update: The gradient vector v(m) is derived from the 16 directional categories predicted by the model in Example 3. For sampling point m, the directional category d output by the model... i (i = 0, 1, …, 15) corresponds to a fixed two-dimensional unit direction vector: v(m) = (cosα i sinα i ), Where, α i The central angle of this direction interval (see α above). k (Calculation method). The direction of this vector points towards the center of the cell nucleus predicted by the model, and its magnitude is 1. After assigning corresponding direction vectors to all sampling points to be classified, a diffusion gradient vector field is formed, in which all gradient vectors converge towards the sink point corresponding to each cell nucleus.
[0081] Sink determination: During gradient flow tracing, the current position of sampling point m is p. m The gradient vector is v(m). The next tracking position is p'. m Determined by the following formula: .
[0082] 3) Termination condition: The angle θ between the gradient vectors of two consecutive points: , When θ > π / 2 (90°), it indicates a sharp reversal of the gradient vector direction, meaning the gradient flow from the initial sampling point has reached the sink. The sink typically corresponds to the region where the cell nucleus is located and is a local convergence point in the gradient vector field. It should be noted that multiple sampling points near the same sink may trace highly clustered endpoints in space, but they may not completely overlap at the pixel level (depending on the discretization accuracy of the gradient field); in actual computation, convergence points with a spatial distance of less than 2 pixels are considered the same sink.
[0083] After completing gradient flow tracing for all sampling points, morphological post-processing is required on the initially generated set of cell instances to further improve segmentation quality. Specifically, post-processing is performed on the set of sampling points grouped into the same cell, removing cells with an area smaller than a preset area threshold and merging cells with a center-to-center distance smaller than a preset distance threshold, outputting the final cell segmentation mask. Removing small-area cells aims to eliminate false-positive regions formed by background noise or isolated outliers; for example, regions containing fewer than 10 sampling points can be directly filtered out. Merging overly close cells addresses oversegmentation caused by multiple local brightness peaks within the cell nucleus; for example, when the Euclidean distance between the centers of two cell instances is less than 5 pixels, they are merged into one cell instance. It should be understood that the aforementioned area and distance thresholds are merely illustrative examples. In practical applications, these thresholds can be adaptively adjusted or set as adjustable parameters based on the resolution of the spatial transcriptome data, the average cell size, and staining characteristics. Any function that can remove noise and correct oversegmentation falls within the scope of this application. Through the synergistic effect of gradient flow tracing and post-processing described above, this embodiment can robustly transform discrete pixel-level predictions into continuous cell segmentation masks that conform to biological morphological laws.
[0084] More specifically, the cell allocation and post-processing steps can be described as follows: When sampling points converge at the same sink point and are grouped into the same cell, the condition for removing excessively small cells is set as follows: If the number of sampling points aggregated at a sink point is less than a preset minimum cell area threshold (exemplarily set to 10 sampling points in this embodiment, corresponding to a physical area of approximately 2.5 μm²), then the sink point and its aggregated sampling points are considered noise or fragmented regions and are not included in any cell. This step can effectively filter out false cells caused by staining artifacts or signal sparsity, improving the biological reliability of the segmentation results.
[0085] Meanwhile, the merging condition for closely spaced cells is set as follows: if the spatial Euclidean distance between two sinks is less than a preset merging threshold (exemplarily set to 5 pixels, or approximately 2.5 μm, in this application), then the two are merged into the same cell sink, and the aggregated sampling points are classified into the same cell. This step can correct the situation where the same cell is split into multiple parts due to over-segmentation in the initial cell nucleus detection, thereby improving the continuity and integrity of cell boundaries.
[0086] The impact of the above post-processing steps on the overall algorithm result is reflected in: (1) Remove excessively small cells: filter out noise fragments, avoid introducing false positive cell types in subsequent analysis, and improve the consistency of gene expression of the same type of cells (outline coefficient, Calinski-Harbasz score, etc.). (2) Merging cells that are too close together: reducing excessive segmentation, making the transcript capture of a single cell more complete, and increasing the number of genes detected and the transcript capture rate of a single cell.
[0087] (3) Improve the robustness of threshold setting: The minimum cell area threshold (10 sampling points) and merging distance threshold (5 pixels) set by example in this application have been experimentally verified to be stable on both Stereo-seq and Seq-scope datasets; they can be adjusted proportionally according to the typical cell size on different platforms or tissue types.
[0088] Example 5 This embodiment provides a cell segmentation device based on spatial transcriptome data. This device is a hardware platform that brings the cell segmentation methods described in embodiments 1 to 4 to life, aiming to achieve automated analysis of biological tissue slice data through a specific physical device. Specifically, the device includes a processor and a memory. The memory stores a computer program, and the processor executes the computer program to implement the cell segmentation method based on spatial transcriptome data as described in any of the foregoing embodiments.
[0089] In terms of specific hardware implementation, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor, etc., or a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. Considering that the bimodal feature extraction network involved in this application contains a large number of matrix operations and convolution operations, as a preferred implementation, the processor can be a graphics processing unit (GPU) or a neural network processor, or a heterogeneous combination architecture of a CPU and a GPU. This hardware selection can significantly accelerate the execution efficiency of steps such as self-attention mechanism computation, U-Net encoding and decoding, and gradient flow iterative tracing, shortening the analysis process that originally required several hours to minutes or even seconds. The memory can include volatile memory, such as random access memory (RAM); or it can include non-volatile memory, such as flash memory, hard disk, or solid-state drive. The computer program stored in the memory is divided into multiple functional modules or instruction sequences. When these instructions are loaded into the processor's registers and cache and scheduled for execution by the control unit, they drive the hardware circuitry to perform substantial physical transformations on the input spatial transcriptome data.
[0090] Furthermore, the device also includes a system bus for data transmission and communication control between the processor, memory, and various input / output interfaces. The input interfaces are configured to receive raw spatial transcriptome data from a sequencer, scanner, or external database, including high-resolution staining image files and gene expression counting matrices; the output interfaces are used to transmit the generated cell segmentation masks, single-cell expression profiles, and visualization analysis results to a display terminal, storage array, or downstream analysis platform. It should be understood that although this embodiment uses a single-machine device as an example, the device's form factor is highly adaptable in practical applications. For example, it can be an embedded computing unit integrated within a spatial transcriptome sequencer, enabling real-time processing of data output and analysis; it can also be a standalone high-performance workstation for researchers to perform offline fine analysis of batch data; or it can be a server cluster deployed in the cloud, providing flexible segmentation services to multiple users through virtualization technology. Regardless of the deployment form, as long as it contains a processor executing the methods of this application and a memory storing the corresponding program, it falls within the protection scope of this embodiment.
[0091] Example 6 This embodiment provides a computer-readable storage medium. As one implementation, the computer-readable storage medium stores a computer program that, when executed by a processor, implements the cell segmentation method based on spatial transcriptome data as described in any of the foregoing embodiments.
[0092] Specifically, in this embodiment, a computer-readable storage medium refers to any tangible medium capable of containing, storing, communicating, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device. To fully support the scope of protection of this application and meet the requirements for subject matter eligibility in examination practice, the storage medium should be understood as a non-transitory physical device, excluding transient propagation signals themselves (e.g., electrical carrier waves or optical pulses). In practical applications, the specific form of the storage medium is highly diverse. For example, it can be a semiconductor-based memory, such as read-only memory (ROM), random access memory (RAM), electrically erasable programmable read-only memory (EEPROM), flash memory, or solid-state drive (SSD); it can also be an optical-based storage disk, such as optical disc read-only memory (CD-ROM), digital versatile optical disc (DVD), or Blu-ray disc; or it can be a magnetic-based storage device, such as a floppy disk, hard disk drive (HDD), or magnetic tape. It should be understood that the above examples are merely illustrative. With the development of storage technology, any new physical storage medium with non-volatile or machine-readable characteristics that emerges in the future, as long as it can carry program instructions for implementing the method of this application, should be covered within the protection scope of this embodiment.
[0093] Example 7 To verify the effectiveness and generalization ability of the cell segmentation method based on spatial transcriptome data provided in the aforementioned embodiments, this embodiment utilizes two representative high-resolution spatial transcriptome datasets for multi-platform application verification and effect comparison. This verification process aims to demonstrate the robustness of the proposed technical solution under different staining conditions, different tissue types, and different sequencing platforms through a combination of qualitative and quantitative analysis, and to quantitatively showcase the substantial technical effects brought about by unsupervised learning, bimodal feature fusion, and gradient flow tracing mechanisms.
[0094] Specifically, the validation experiments selected the Stereo-seq mouse brain dataset and the Seq-scope mouse liver dataset as test subjects. The Stereo-seq dataset uses nuclear fluorescence staining with a sampling point resolution of 0.5 micrometers, where pixels correspond one-to-one with sampling points, representing a high signal-to-noise ratio but relatively simple morphological imaging scenario. The Seq-scope dataset uses H&E staining, also with a 0.5-micrometer resolution, but its rich color information and complex background represent a more realistic application scenario closer to clinical pathological slides. The method provided in this application (hereinafter referred to as the UTseg method) was comprehensively compared with the traditional Watershed algorithm, the spatial transcriptome automatic segmentation method SCS, the deep learning-based nuclear segmentation method StarDist, and the general cell segmentation model Cellpose.
[0095] like Figure 2As shown, the comparison of cell segmentation performance of different methods on two datasets is illustrated. (a–b) provides an overview of the global segmentation results for the Seq-scope mouse liver dataset (a) and the Stereo-seq mouse brain dataset (b); (c–d) shows magnified comparisons of local segments. From a visual qualitative analysis perspective, the cell segmentation mask generated by the UTseg method (marked with blue lines in the figure) significantly outperforms other comparative methods in terms of morphological integrity and boundary smoothness, clearly distinguishing adjacent cells even in densely populated cell regions. Specifically, in H&E-stained images from the Seq-scope dataset, the traditional Watershed algorithm tends to produce oversegmentation fragments (marked with green lines in the figure), while Cellpose, although able to identify cell nuclei, often misses irregularly shaped cytoplasmic regions (marked with purple lines in the figure). The UTseg method, however, accurately delineates complete cell outlines, maintaining good segmentation integrity for irregularly shaped, non-circular cells in brain tissue, including elongated processes and irregular cytoplasmic edges. Other methods suffer from boundary breaks or excessively small cell regions. This visual advantage stems directly from the bimodal feature fusion and gradient flow tracing mechanism described in the preceding embodiments: the U-Net branch captures fine morphological textures, the Transformer branch maintains global representational consistency, and gradient flow iterative tracing naturally converges discrete prediction points into continuous geometric entities, thereby avoiding the jagged edges and breaks common in threshold-based or simple clustering methods. It should be understood that, although... Figure 2 Only the comparison results under a specific field of view are shown, but this morphological advantage determined by the algorithm's inherent mechanism is universal across the entire dataset.
[0096] Figure 2 Overall, the UTseg method demonstrates superior performance in the following ways: (i) Segmentation integrity: UTseg covers a larger physical area of cells, completely covering the nucleus and perinuclear cytoplasm; (ii) Boundary continuity: The segmentation edges are smooth and continuous, without obvious breaks; (iii) Dense region resolution: It can still accurately distinguish adjacent cells in high cell density areas.
[0097] Furthermore, such as Figure 3As shown, quantitative statistical analysis of biological characteristics was performed on the segmented single-cell data. (a) is a bar chart of transcript allocation rate, (b) is a bar chart of cell number, (c–d) are box plots of single-cell transcript count versus gene count, and (e–f) are scatter plots of gene expression ratio. The results show that the UTseg method achieved optimal or tied-optimal performance in both transcript capture rate and single-cell gene detection count. For example, as shown in Figures (a)–(b), in the Stereo-seq dataset, the transcript capture efficiency achieved by the UTseg method was significantly higher than Watershed and StarDist, and comparable to the SCS method. In the Seq-scope dataset, it detected a moderate number of cells but captured the most transcripts, while StarDist detected the most cells but had the lowest transcript capture rate, indicating that it tends to segment small cell fragments. As shown in Figures (c)–(d), in the Seq-scope dataset, its median gene detection was also at a leading level, verifying its ability to effectively integrate high-transcriptional-signal sampling points into single cells. The underlying mechanism behind this result lies in the fact that precise cytoplasmic segmentation allows extranuclear transcripts, which would otherwise be excluded from the nuclear mask, to be correctly assigned, thus significantly improving the integrity and information content of single-cell data. In contrast, methods relying solely on nuclear segmentation systematically lose molecules located in the cytoplasm, leading to biases in downstream differential expression analysis or trajectory inference. Furthermore, Figure 3 (e)-(f) also show scatter plots of gene expression proportions. The data points (blue scatter plots) of the UTseg method are more closely clustered near the diagonal, forming the outermost distribution on both datasets. This indicates that the proportion of gene detection in whole cells is systematically higher than that of detection in cell nuclei only, and its segmentation results have higher biological fidelity.
[0098] Figure 3 Overall, the UTseg method demonstrates superior performance: (i) high transcript capture efficiency; (ii) rich single-cell gene expression information; and (iii) effective capture of cytoplasmic and extranuclear transcripts, overcoming the shortcomings of methods that rely solely on staining images and are insufficient in detecting extranuclear regions.
[0099] Beyond basic segmentation accuracy, the consistency of gene expression among cells of the same type is a high-order indicator for evaluating the quality of spatial transcriptome segmentation. Inaccurate segmentation boundaries can lead to signal contamination between adjacent cells, or spurious heterogeneity due to excessive background noise within the same cell type. As shown in Tables 1 and 2, on the Seq-scope dataset, the UTseg method achieved a silhouette coefficient (0.5722), measuring cluster compactness and separation, and a Calinski-Harbasz score (10497.57), the highest among all comparative methods. On the Stereo-seq dataset, its Calinski-Harbasz score and Pearson correlation coefficient (measuring the linear correlation of gene expression among cells of the same type) also reached optimal levels. These data strongly demonstrate that the proposed technical solution can not only "separate" cells but also "segment" them accurately, ensuring that the segmented single-cell expression profile truly reflects the biological state rather than technical artifacts, indicating higher biological reliability and stability of the segmentation results. This high degree of consistency is crucial for subsequent cell subpopulation identification, spatial domain resolution, and intercellular communication analysis.
[0100] Table 1: Cell classification results of five segmentation methods on the Seq-scope dataset and evaluation metrics of gene expression similarity among similar cells. Table 2: Cell classification results of five segmentation methods on the Stereo-seq dataset and evaluation indicators of gene expression similarity among similar cells. like Figure 4 As shown, the performance of the cell segmentation algorithm was further evaluated. Figure 4 (a) shows a schematic diagram of the evaluation strategy: using the intersection region (usually the cell nucleus region) of the segmentation results of the two methods as a reference benchmark, the gene expression correlation coefficient between the difference region and the intersection region is calculated to quantify the segmentation accuracy. Figure 4 The correlation violin plot (bc) shows that UTseg achieved significantly higher correlation coefficients than other methods on both datasets (P-values were calculated using the Mann-Whitney rank-sum test), indicating that the gene expression consistency between the segmented cytoplasmic and nuclear regions was the highest. Figure 4(de) shows the intracellular pixel classification ratio in different grayscale ranges: UTseg maintains a high intracellular classification ratio in all grayscale ranges, especially in the highest grayscale range (200, 255], where UTseg correctly classifies 91.51% (Seq-scope) of pixels as intracellular, significantly outperforming SCS (89.93%), Watershed (80.40%), Cellpose (18.92%), and StarDist (14.93%). This demonstrates UTseg's superior performance in recognizing highly stained regions, its high boundary localization accuracy, and its robustness.
[0101] Finally, it is worth emphasizing the cross-platform generalization characteristic of the method in this application. During testing on the two datasets mentioned above, the UTseg method was trained or fine-tuned without using any manually labeled data, relying solely on the morphological priors of stained images to automatically generate supervisory signals. This means that the method can be directly applied to newly generated, unlabeled spatial transcriptome data, maintaining stable high-performance output regardless of whether it is fluorescence staining or bright-field staining, or whether it is brain or liver tissue. In contrast, deep learning methods such as Cellpose often require re-labeling and retraining to achieve ideal results when faced with new data with significantly different distributions from the training set. This application, through unsupervised sample generation and bimodal complementary enhancement, fundamentally solves the bottleneck problem of scarce labeled data in the field of spatial transcriptomics, providing a standardized analytical tool for large-scale, multi-center spatial omics research.
[0102] In summary, this embodiment, through multi-dimensional experimental data verification, confirms that the cell segmentation method based on spatial transcriptome data described in the aforementioned embodiment has significant technical advantages in terms of segmentation integrity, boundary accuracy, biological fidelity, and generalization ability, and can effectively support the needs of high-precision single-cell spatial transcriptome analysis.
[0103] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. For example, the number of directional interval divisions, the specific topology of the feature extraction network, the termination criterion threshold for gradient flow tracing, and the dual constraint conditions for negative sample screening mentioned in the foregoing embodiments are all preferred examples for achieving the purpose of this application, not the only implementation path. Without departing from the core concept of this application regarding unsupervised directional label generation, dual-modal feature fusion prediction, and geometric flow field convergence segmentation, equivalent transformations, adaptive parameter adjustments, or module combination reconstructions of the above technical features should all be considered equivalent technical solutions of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.
Claims
1. A cell segmentation method based on spatial transcriptome data, characterized in that, include: Acquire spatial transcriptome data of the target tissue, wherein the spatial transcriptome data includes staining images and gene expression data; Based on the morphological prior of the stained images, unsupervised training samples containing spatial orientation labels pointing from sampling points to the center of the cell nucleus are automatically generated. A dual-modal feature extraction network is used to fuse gene expression features and local image morphological features of the sampling points, and jointly predict the probability that the sampling point belongs to the cell and the direction category pointing to the center of the cell nucleus. Based on the direction category, a direction vector is determined, and the sampling points are converged towards the center of the cell nucleus through gradient flow iterative tracing to generate cell segmentation results.
2. The method according to claim 1, characterized in that, The morphological prior based on the stained image automatically generates unsupervised training samples containing spatial orientation labels pointing from sampling points to the center of the cell nucleus, including: The label-controlled watershed algorithm is used to identify the cell nucleus region in the stained image, and the sampling points in the cell nucleus region are marked as positive samples; Negative samples are selected from the sampling points outside the cell nucleus region based on the staining signal intensity and the distance to the center of the cell nucleus. Based on the spatial relationship between the sampling point and the center of the cell nucleus, a spatial direction label pointing from the sampling point to the center of the cell nucleus is generated.
3. The method according to claim 1, characterized in that, The method of fusing gene expression features and local image morphological features of the sampling points using a dual-modal feature extraction network, and jointly predicting the probability that the sampling point belongs to a cell and the directional category pointing to the center of the cell nucleus, includes: Through the first feature extraction branch, global gene expression features are extracted based on the gene expression sequences of the sampling points and their neighborhoods; Through the second feature extraction branch, local image morphological features are extracted based on local image blocks centered on the sampling points; The global gene expression features and the local image morphological features are concatenated along the channel dimension, and the probability and the direction category are jointly output through a fully connected layer.
4. The method according to claim 1, characterized in that, The step of determining the direction vector based on the direction category and converging the sampling points towards the center of the cell nucleus through gradient flow iterative tracing to generate cell segmentation results includes: Map the direction category to a two-dimensional direction vector; The position of the sampling point is iteratively updated based on the two-dimensional direction vector, causing the sampling point to move towards the center of the cell nucleus; When the preset termination condition is met, the tracking stops, and the sampling points that converge to the same cell nucleus center are classified as the same cell, generating the cell segmentation result.
5. The method according to claim 2, characterized in that, The step of screening negative samples from sampling points outside the cell nucleus region based on staining signal intensity and distance to the center of the cell nucleus includes: Sampling points whose staining signal intensity is less than a first preset threshold and whose Euclidean distance to any of the cell nuclei centers is greater than a second preset threshold are identified as negative samples. The step of generating a spatial direction label pointing from the sampling point to the center of the cell nucleus based on the spatial positional relationship between the sampling point and the center of the cell nucleus includes: The preset angle range is evenly divided into multiple directional intervals, and the direction from the sampling point to the center of the cell nucleus is discretized into corresponding directional intervals, which serve as the spatial direction labels.
6. The method according to claim 3, characterized in that, The first feature extraction branch uses a Transformer encoder to calculate the query matrix, key matrix, and value matrix through a self-attention mechanism to obtain the global gene expression features; The second feature extraction branch adopts a U-Net network structure, which includes an encoder downsampling layer, a decoder upsampling layer, and a skip connection layer connecting the encoder downsampling layer and the decoder upsampling layer to extract the local image morphological features.
7. The method according to claim 4, characterized in that, The step of iteratively updating the position of the sampling point based on the two-dimensional direction vector, causing the sampling point to move towards the center of the cell nucleus, includes: The normalized two-dimensional direction vector is rounded to discretize the spatial grid, and the position coordinates of the sampling point are updated based on the rounded direction vector. The process of stopping tracking when a preset termination condition is met, and grouping sampling points converging at the same cell nucleus center into the same cell to generate the cell segmentation result includes: When the angle between the gradient vectors corresponding to two consecutive iterations is greater than a preset angle threshold, it is determined that the center of the cell nucleus has been reached and the tracking stops. The set of sampling points grouped into the same cell is post-processed to remove cells with an area smaller than a preset area threshold and merge cells with a center distance smaller than a preset distance threshold, and the final cell segmentation mask is output.
8. The method according to claim 1, characterized in that, Before fusing the gene expression features and local image morphological features of the sampling points using a dual-modal feature extraction network, the method further includes: Select the first preset number of genes with the highest total expression levels to construct the gene expression vector for each sampling point; The gene expression sequence is constructed by selecting a second preset number of spatially nearest neighbor sampling points along with the central sampling point.
9. A cell segmentation device based on spatial transcriptome data, characterized in that, include: processor; Memory, used to store computer programs; When the processor executes the computer program, it implements the cell segmentation method based on spatial transcriptome data as described in any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the cell segmentation method based on spatial transcriptome data as described in any one of claims 1 to 8.