Space coordinate expansion and reconstruction method, device, medium

By constructing an unfolded coordinate system, the skeleton path of the curled tissue is automatically identified and reconstructed, solving the coordinate distortion problem of the curled tissue, realizing high-precision reconstruction of spatial representation points, and improving the accuracy and visualization effect of spatial omics analysis.

CN121120814BActive Publication Date: 2026-04-17GUANGDONG HOSPITAL OF TRADITIONAL CHINESE MEDICINE
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG HOSPITAL OF TRADITIONAL CHINESE MEDICINE
Filing Date
2025-08-08
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies suffer from severe distortion of two-dimensional coordinates and difficulty in restoring the true spatial structure when processing curled tissues. This is particularly problematic in spatial omics analysis, affecting the reproducibility and accuracy of the data and making it impossible to accurately determine the spatial relationship between cells inside the tissue structure and external microorganisms.

Method used

By automatically generating complete skeleton paths and high-smoothness edge curves, and utilizing image processing and geometric projection techniques, an unfolding coordinate system is constructed to achieve automatic identification and high-precision coordinate unfolding of curly tissues, thereby reconstructing the true position of spatial representation points.

Benefits of technology

It effectively restores the true spatial location of the spatial expression points of hosts and microorganisms, improves the structural consistency of spatial group data and the accuracy of subsequent visualization and analysis tasks, and supports high-resolution reconstruction of multiple types of spatial group data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121120814B_ABST
    Figure CN121120814B_ABST
Patent Text Reader

Abstract

This invention discloses a method, apparatus, and medium for spatial coordinate unfolding and reconstruction, comprising: extracting spatial expression points labeled as target tissue types from spatial group data to generate a standardized binary image; performing a closing operation and smoothing edges, extracting multiple contour regions and merging them into a main contour, and performing an image skeletonization algorithm on the main contour to generate a skeleton path map; selecting the longest path from the shortest paths as the central main path; backprojecting the central main path in the image coordinates to the original spatial coordinate system to determine the central main path and its starting and ending points; constructing a tangent-normal coordinate system and calculating the distance from the spatial expression points to a first reference point; generating edge reference lines; projecting all spatial expression points to the unfolded coordinate system to determine the projection target; and projecting according to the projection target to obtain the unfolded coordinates. This invention automatically generates complete skeleton paths and highly smooth edge curves, effectively restoring the true spatial positions of the host and / or microorganisms and spatial expression points.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of bioinformatics technology, and in particular to methods, devices, and media for spatial coordinate unfolding and reconstruction. Background Technology

[0002] Against the backdrop of the rapid development of space omics, space transcriptomics technology has become an important tool for studying the tissue microenvironment, cell localization, and gene expression. By obtaining transcriptional information at the in situ level of tissues, researchers can reveal key life processes such as cell distribution, tissue structure, and transcellular signaling patterns. Especially in cases where organ tissues have complex structures and rich spatial hierarchies, this type of technology demonstrates powerful anatomical and functional analysis capabilities.

[0003] For organs with elongated tubular structures such as the small intestine and colon, researchers typically use the "Swiss roll" technique to process the tissue. This method rolls the tubular tissue into a spiral shape along its longitudinal axis, thus preserving information from multiple different longitudinal levels simultaneously in a single two-dimensional slice. While this preparation method greatly increases the tissue information density, it also introduces problems such as severe distortion of two-dimensional coordinates and difficulty in reconstructing the true spatial structure, thereby limiting its in-depth application in spatial omics analysis.

[0004] To address the problem of distorted coordinates in curled tissues, some studies have attempted to manually draw tissue edge lines to construct unfolding reference axes and reconstruct an approximately linear coordinate system. However, this method is highly dependent on manual operation, resulting in low efficiency, strong subjectivity, and often drastic fluctuations in the fitted curves. This can easily lead to problems such as cell structure fragmentation and spatial compression distortion, severely affecting the reproducibility and accuracy of the data.

[0005] Furthermore, with the continuous enhancement of the capabilities of spatial omics platforms, some next-generation platforms can simultaneously acquire spatial expression information of extra-tissue elements such as host cells and microorganisms in tissue sections. For this type of multimodal data, if it is still in a raw, curled state, it will not only be impossible to accurately determine the spatial relationship between cells inside the tissue structure and external microorganisms, but it will also affect neighborhood analysis, enrichment analysis, and the construction of spatial interaction pathways.

[0006] Therefore, there is an urgent need for a method that can automatically identify coiled tissue structures and perform high-precision coordinate unfolding without human intervention. This method should effectively preserve tissue anatomical structures, support high-resolution reconstruction, and be applicable to various types of spatial ensemble data. In particular, for Swiss roll samples, it should be able to reconstruct their true spatial path, construct a unified, continuous, and anatomically sound unfolding coordinate system, thereby providing a solid spatial foundation for downstream spatial statistical analysis and biological function research. Summary of the Invention

[0007] Based on the shortcomings of the existing technology, the present invention provides a method, device and medium for spatial coordinate unfolding and reconstruction, which automatically generates a complete skeleton path and a high-smoothness edge curve, effectively restoring the true spatial location of the host and / or microbial spatial expression points.

[0008] To address the aforementioned technical problems, the first aspect of this invention discloses a method for spatial coordinate unfolding and reconstruction, the method comprising:

[0009] Spatial representation points labeled with the target organization type are extracted from the spatial group data. An adjacency graph is constructed based on the spatial location of the spatial representation points, and the largest connected cluster is extracted. Clusters with an area smaller than a preset threshold or too far from the main cluster are filtered out. The coordinates of the filtered spatial representation points are normalized to generate a standardized binary image.

[0010] The binary image is closed and the edges are smoothed. Multiple contour regions are extracted and merged into the main contour. The main contour is then processed by an image skeletonization algorithm to generate a skeleton path map.

[0011] The pixels in the skeleton path graph are constructed into a graph structure, with each pixel as a node and edges established between adjacent pixels. Endpoints are identified and endpoint pairs are constructed. The shortest path between all endpoint pairs is calculated, and the longest path is selected from the shortest paths as the central main path.

[0012] Based on the image normalization parameters, the central main path in the image coordinates is back-projected to the original spatial coordinate system to determine the central main path and its starting and ending points.

[0013] A tangent-normal coordinate system is constructed based on the central main path. All spatial representation points are projected along the normal direction, and the distance from the spatial representation point to the first reference point is calculated. In the region of negative normal direction, the local minimum point is identified as the edge spatial representation point by the sliding window method. All the edge spatial representation points are connected to generate a smooth curve. The edge reference line is generated by spline interpolation fitting.

[0014] Construct an expanded coordinate system with the cumulative arc length of the edge reference line as the horizontal axis and the normal distance from the spatial representation point to the second reference point as the vertical axis. Project all spatial representation points onto the expanded coordinate system and determine the projection target based on the spatial geometric relationship between the spatial representation points and the reference points.

[0015] Project the target object to obtain the unfolded coordinates.

[0016] In some embodiments, the spatial expression point includes cell points or microbial points, and determining the projection target based on the spatial geometric relationship between the spatial expression point and the second reference point includes:

[0017] Calculate the Euclidean distance from each of the spatial representation points to the second reference point, and determine the nearest matching reference point;

[0018] Candidate projection points are determined from the matching reference points based on the candidate projection conditions;

[0019] From all the candidate projection points, the candidate reference point with the smallest Euclidean distance to the spatial representation point is selected as the projection target.

[0020] In some implementations, the candidate projection conditions include: the direction of the normal vector of the spatial representation point is consistent with that of the second reference point, and the angle between the spatial representation point and the normal is not greater than a preset angle.

[0021] In some implementations, the process of projecting onto a target to obtain unfolded coordinates further includes:

[0022] Write the expanded coordinates of all spatial representation points into the expanded coordinate matrix field of the spatial data object;

[0023] Based on the expanded coordinates in the field, an original coordinate map and an expanded coordinate map are generated for comparison and display, and the spatial expression points are rendered into multiple layers according to cell type, partition or microbial type.

[0024] In some implementations, the image normalization parameters include canvas size, edge size, and maximum and minimum values ​​of coordinates;

[0025] The central principal path in the image coordinate system is back-projected to the original spatial coordinate system based on the image normalization parameters, including:

[0026] The scale value is calculated based on the image normalization parameters, and the central main path in the image coordinates is back-projected to the original spatial coordinate system based on the scale value.

[0027] In some implementations, the first reference point is the point on the skeleton path that is closest to the spatial representation point; the second reference point is a fitted sampling point on the edge reference line, used to match the target point when the spatial representation point is projected into the unfolded coordinate system.

[0028] In some implementations, the pixels in the skeleton path graph are constructed into a graph structure, with pixels as nodes and edges established between adjacent pixels, and endpoints are identified and endpoint pairs are constructed. The method further includes:

[0029] For path segments with breakpoints in the skeleton path graph, calculate the Euclidean distance between breakpoint pairs. When the distance threshold condition is met, use the Bresenham algorithm to perform path bridging repair at the pixel level.

[0030] If the distance threshold is not met, a specified endpoint pair is obtained for repair; the distance threshold condition is that it is less than the distance of the preset maximum connection.

[0031] In a second aspect, a computer device is disclosed, characterized in that it comprises: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the steps of the spatial coordinate unfolding and reconstruction method as described above.

[0032] Thirdly, a computer storage medium is disclosed, on which a computer program is stored, which, when executed by a processor, implements the spatial coordinate unfolding and reconstruction method as described in any of the above.

[0033] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0034] This invention provides a method, device, and medium for spatial coordinate unfolding and reconstruction. By extracting the target tissue region, constructing the tissue outline and central path, and mapping all cells and microbial points to an unfolded coordinate system based on edge reference lines through orthogonal projection, the relative positional relationships of spatial expression points in two-dimensional space are reconstructed. This method achieves planar unfolding of coiled tissue structures, maintains the spatial adjacency characteristics of tissue hierarchy and expression points, and effectively improves the structural consistency of spatial group data and the accuracy of subsequent visualization and analysis tasks. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of the spatial coordinate unfolding and reconstruction method provided by the present invention;

[0036] Figure 2 This is a schematic diagram of muscle cell extraction and filtering in the spatial coordinate unfolding and reconstruction method provided by the present invention.

[0037] Figure 3 This is a schematic diagram of muscle layer cell tissue contour extraction and skeleton path map generation in the spatial coordinate unfolding and reconstruction method provided by the present invention.

[0038] Figure 4 This is a schematic diagram illustrating the skeleton path map construction, endpoint pair identification, main path extraction, and breakpoint repair of the spatial coordinate unfolding and reconstruction method provided by the present invention.

[0039] Figure 5 This is a schematic diagram of the skeleton path back projection to the original spatial coordinate system for the spatial coordinate unfolding and reconstruction method provided by the present invention;

[0040] Figure 6 A schematic diagram illustrating the calculation of the projection of cell points along the normal direction and the distance from the normal in the spatial coordinate unfolding and reconstruction method provided by this invention;

[0041] Figure 7 A comparison diagram of the edge cell point identification and spline function fitting reference line for the spatial coordinate unfolding and reconstruction method provided by the present invention before and after;

[0042] Figure 8a A diagram of the original Swiss roll-shaped intestinal cell structure in the spatial expression points of the spatial coordinate unfolding and reconstruction method provided by the present invention;

[0043] Figure 8b The diagram shows the intestinal cell structure after the spatial expression point is expanded to the coordinates of the spatial coordinate expansion and reconstruction method provided by this invention.

[0044] Figure 8c A magnified view of a specified range of spatial representation points for the spatial coordinate unfolding and reconstruction method provided by this invention;

[0045] Figure 9a A schematic diagram of the original projection method of microbial points based on the nearest upper reference point in the spatial coordinate unfolding and reconstruction method provided by the present invention;

[0046] Figure 9b The microbial points in the spatial coordinate unfolding and reconstruction method provided by this invention are straightened and magnified based on the projection method of the nearest upper reference point;

[0047] Figure 10a The visualization results of the spatial coordinate unfolding and reconstruction method provided by this invention and the downstream analysis application scenarios are illustrated. Figure 1 ;

[0048] Figure 10b The visualization results of the spatial coordinate unfolding and reconstruction method provided by this invention and the downstream analysis application scenarios are illustrated. Figure 2 ;

[0049] Figure 10c The visualization results of the spatial coordinate unfolding and reconstruction method provided by this invention and the downstream analysis application scenarios are illustrated. Figure 3 . Detailed Implementation

[0050] To better understand and implement this invention, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0051] The terms “comprising” and “having” and any variations thereof in this invention are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to such processes, methods, products or devices.

[0052] The embodiments of the present invention disclose a spatial coordinate unfolding and reconstruction method, which automatically generates a complete skeleton path and a high-smoothness edge curve, effectively restoring the true spatial position of the host and spatial expression points.

[0053] It should be noted that the "Swiss roll" is a common two-dimensional slicing technique in tissue preparation, primarily used for processing tubular or elongated tissues with distinct longitudinal structures. This method involves rolling the tissue into a spiral shape along its longitudinal axis, allowing the originally linearly extended structure to exhibit multiple anatomical layers within a single slice, significantly improving spatial information density and structural observation efficiency. Besides the small intestine and colon, the Swiss roll structure is also widely used in slices of various tissues with long-axis structures, such as the fallopian tube, esophagus, blood vessels, umbilical cord, nerve bundles, and pancreatic duct, making it particularly suitable for pathological, spatial omics, or microenvironment studies that require simultaneous visualization of multiple longitudinal regions.

[0054] This method is not only applicable to Swiss roll-shaped intestinal slices, but can also be extended to other tissue samples or microorganisms with similar coiled structures. It enables coordinate unfolding and spatial reconstruction of compressed structures in two-dimensional slices, thereby supporting more accurate spatial expression analysis, cell localization, and microenvironment interaction studies. This application uses intestinal muscular cells as the primary example, but it is equally applicable to any other tissue type with coiled or spiral slice structures; its application should not be limited to the intestine.

[0055] like Figure 1 As shown, this method includes:

[0056] Step S1: Extract spatial representation points labeled as target organization type from spatial group data; construct an adjacency graph based on the spatial location of the spatial representation points and extract the largest connected cluster; filter clusters with an area smaller than a preset threshold or too far from the main cluster; normalize the coordinates of the filtered spatial representation points to generate a standardized binary image.

[0057] In this application, spatial expression points refer to data points obtained in spatial omics experiments that possess two-dimensional or three-dimensional spatial location information. These spatial expression points include, but are not limited to, cellular expression points within tissues and microbial expression points outside tissues. Cellular expression points typically originate from the spatial transcriptome sequencing results of host cells, while microbial expression points are derived from microbial RNA or DNA signals detected in samples.

[0058] To perform subsequent coordinate unfolding and spatial reconstruction operations, such as Figure 2 As shown, preliminary screening of the spatial representation points and standardization of their spatial coordinates are required. Specifically:

[0059] Import the spatial transcriptome data file (.h5ad format), read the corresponding spatial objects, and extract all expression points with spatial coordinates. The spatial transcriptome data h5ad file is an anndata object. adata.obsm stores the coordinate information of each spatial expression point, and an adjacency graph is constructed based on these coordinates. adata.obs stores basic information for each spatial expression point, including cell type or spatial cell group, obtained through manual or automatic annotation, cell spatial clustering, etc. Based on the cell type annotation information, cell expression points belonging to a specific target tissue type, such as muscle cells, are selected. Here, cell annotation fields are used to filter the cell types in .obs to ensure that the selected spatial points are located in anatomically significant tissue regions.

[0060] An adjacency graph is constructed based on the two-dimensional spatial coordinates of selected cell expression points. Each spatial expression point is treated as a node, and connecting edges are established when the distance between points is less than a preset neighborhood radius, forming a graph structure. Generally, the neighborhood radius (radius) is set to a Euclidean distance of 300. This distance unit is a relative scale, the same as the coordinate unit used in the calculation; when the coordinate unit is micrometers, this distance unit is micrometers. Alternatively, it can be simply understood as the distance unit of pixels. The largest connected cluster in the graph is extracted through connectivity analysis to represent the main tissue region. Based on this, non-main connected clusters in the adjacency graph, such as small branches, isolated clusters, or stray points, are further filtered by area and distance. If the number of points in a connected cluster is less than a set threshold, and the minimum distance between all points in the cluster and the main cluster is greater than the distance threshold, then the connected cluster is removed. In this application, the threshold for the number of connected cluster points (area_thresh) can be set to 10 points, and the distance threshold (distance_thresh) can be set to 300, which helps to exclude "polyp-like" or noisy clusters and ensure the anatomical continuity of the constructed region.

[0061] After filtering, the retained spatial representation points undergo coordinate normalization. The normalization operation, based on global minimum and maximum values, linearly maps the original spatial coordinates to a fixed-size image canvas (default size 1000×1000 pixels) with a 10-pixel margin at the edges to ensure all representation points are fully displayed within the canvas. Finally, the normalized coordinates are rendered into a binary image, where the representation point positions are marked as foreground pixels and the rest as background, providing standard input for subsequent image processing.

[0062] It is worth noting that in this method, spatial expression points include not only cellular expression points within tissues but also microbial expression points outside tissues. During subsequent coordinate unfolding, these microbial points will participate in coordinate mapping operations with cellular points, preserving their relative spatial positions in the unfolded coordinate system. This supports more comprehensive spatial analysis and host-microbe interaction studies.

[0063] Step S2: Perform a closing operation on the binary image and smooth the edges, extract multiple contour regions and merge them into the main contour, and perform an image skeletonization algorithm on the main contour to generate a skeleton path map.

[0064] like Figure 3 As shown, after completing the selection of spatial representation points and standardized image rendering, the process proceeds to the contour extraction and skeleton generation stage of the tissue structure. The overall contour representing the boundary of the muscle layer tissue is identified from the normalized binary image, and the central skeleton of the structure is further extracted.

[0065] First, a binary image is used as input, where foreground pixels represent the location distribution of muscle cells, and background pixels are 0. A morphological closing operation is then performed on the binary image to fill in the gaps between pixels caused by sparse representation or edge defects, and to smooth the jagged structure of tissue edges. The closing operation uses a two-dimensional convolution kernel with a default kernel size of 5×5 and a square structuring element, which closes small holes without excessively blurring tissue boundaries.

[0066] After the closing operation is completed, the central skeleton is extracted based on the contour region using an image skeletonization algorithm such as skimage, generating an initial skeleton map composed of pixel paths and obtaining multiple candidate contour regions. Since the spatial representation points are distributed within the tissue, there are natural breaks and local gaps, resulting in more than one extracted contour. To avoid noise interference or edge fragments participating in the analysis, all contours are sorted by area from largest to smallest, and the top N contour regions by area are merged. In some implementations, the top 10 contour regions by area can be merged to form the main contour region representing the entire tissue structure. This merging operation is performed through a logical OR operation of the contour pixels, outputting a unified binary contour map.

[0067] Based on the binary contour map, an image skeletonization algorithm such as skimage.morphology.skeletonize is used to refine the internal regions of the contour at the pixel level, generating a central skeleton path map with a single pixel width. The skeletonization algorithm gradually removes non-central pixels while preserving the main contour of the tissue morphology, for example, retaining only the main features of the intestinal muscle layer structure, thus obtaining a skeleton network that is structurally as close as possible to the geometric centerline. The generated skeleton path preserves the general orientation of the muscle layer region, representing the main spiral unfolding trend of intestinal tissue in the "Swiss roll" structure. This step of main contour extraction and skeleton generation ensures that the method has tissue structure awareness capabilities, avoiding the traditional reliance on manually drawing paths or edges, and improving the automation and repeatability of unfolding path generation.

[0068] Step S3: Construct a graph structure from the pixels in the skeleton path graph, establish edges between adjacent pixels with pixels as nodes, identify endpoints and construct endpoint pairs; calculate the shortest path between all endpoint pairs, and select the longest path from the shortest paths as the central main path.

[0069] After obtaining the skeleton path diagram, to extract the central path that represents the main direction of tissue expansion, the skeleton path diagram is further converted into a graph structure, and the optimal path is identified through a traversal strategy. Specifically, such as... Figure 4 As shown in the left image, each pixel in the skeleton path graph is treated as a node in the graph, and each node is identified by its two-dimensional coordinates (x, y) in the image. For each pair of adjacent pixels with pixel connectivity, an edge is established between their corresponding nodes to form a complete graph structure, preserving all pixel connections in the skeleton path. All nodes with a degree of 1, i.e., endpoint nodes, are traversed to identify possible start and end points of the skeleton path. All endpoint pairs are constructed by pairwise combinations, and the shortest path between each pair of endpoints is calculated using the shortest path algorithm from the NetworkX graph processing library. To select the most representative main path, the longest path from all candidate paths is chosen as the central main path for the current sample.

[0070] In practical applications, due to complex organizational boundaries or image discontinuities, skeleton paths may be broken, meaning that some path segments are interrupted and cannot be connected by existing edges to form a complete path. Therefore, for path segments with breaks in the skeleton path graph, a breakpoint bridging mechanism is set up, including:

[0071] Calculate the Euclidean distance between breakpoint pairs, and when the distance threshold condition is met, use the Bresenham algorithm to perform path bridging repair at the pixel level;

[0072] If the distance threshold is not met, a specified endpoint pair is obtained for repair; the distance threshold condition is that it is less than the distance of the preset maximum connection.

[0073] like Figure 4 As shown in the right figure, endpoint pairs between all isolated skeleton segments are detected. If the Euclidean distance between endpoint pairs is less than a set distance threshold, a continuous pixel line segment is generated using the Bresenham pixel interpolation algorithm to connect the two endpoints. The path is then drawn at the image level to ensure pixel-level connectivity of the bridging path and to preserve the orientation of the tissue structure. In this application, the distance threshold can be set to 40 pixels, but the specific value is not limited in this application.

[0074] For cases where the distance threshold is not met, such as when there is topological ambiguity in the path, overlapping branches, or when domain knowledge is needed to determine the connection direction, user-interactively specified endpoint pairs can be used as bridging objects. The Bresenham algorithm is also used to generate the path, ensuring consistency with the automatic bridging logic. The final extracted main path consists of several pixels, which are serialized into a .pkl file, such as results.p, as a path point sequence, which can be directly loaded and called by subsequent reference line construction and coordinate expansion modules. This step significantly improves the automation of center path extraction while allowing users to fine-tune it in special cases, balancing robustness and flexibility.

[0075] Step S4: Based on the image standardization parameters, backproject the central main path in the image coordinates to the original spatial coordinate system to determine the central main path and its starting and ending points.

[0076] The image normalization parameters include canvas size, edge dimensions, and the maximum and minimum values ​​of coordinates. To transform the central master path in the image coordinate system back to the original spatial coordinate system, a reverse coordinate transformation is required based on the image normalization parameters. For example... Figure 5 As shown, the pixel image coordinates in the left image and the original spatial coordinates in the right image are compared. Assuming a canvas size of 1000, a margin of 10, and the maximum and minimum values ​​of the x and y coordinates, the scale value is calculated and then reversed. The scale value is calculated using the following formula:

[0077]

[0078] Where canvas_size is the side length of the image canvas, margin is the pixel margin reserved at the image edge, and Xmax, Xmin, Ymax, and Ymin are the maximum and minimum values ​​of the original spatial coordinates on the x and y axes, respectively. This calculation method considers the maximum span between the target canvas size and the actual organization coordinate range, ensuring that the organization structure is scaled proportionally to the maximum side in image space.

[0079] Through the above transformation, each pixel in the central main path is precisely mapped back to its corresponding original spatial position. Maintaining coordinate accuracy at the pixel level ensures that the central main path aligns with the original coordinates of the cell points and microbial points, facilitating the unified construction of the unfolded coordinate system. Simultaneously, the start and end points of the central path are recorded; these two endpoints of the central main path are the start and end points, used for subsequent construction of the tangent-normal coordinate system and determination of the unfolding direction.

[0080] Step S5: Construct a tangent-normal coordinate system based on the central main path, project all spatial representation points along the normal direction, and calculate the distance from the spatial representation points to the first reference point; in the region of negative normal direction, identify the local minimum point as the edge spatial representation point by the sliding window method, connect all the edge spatial representation points to generate a smooth curve, and generate the edge reference line by spline interpolation fitting;

[0081] like Figure 6 As shown, after obtaining the original spatial coordinates of the central main path, a tangent-normal coordinate system is constructed based on the path point sequence. The main path is sequentially numbered, and each pair of adjacent path points is treated as a local line segment. The direction of this line segment is defined as the tangent direction at that point, and the unit vector perpendicular to the tangent direction is defined as the normal direction. The normal is strictly perpendicular to the tangent. If the skeleton path has curvature changes such as bending, the normal direction will be dynamically adjusted with the path.

[0082] After construction, all spatial representation points are projected along the normal direction to the first reference point. The first reference point is the point on the skeleton path that is closest to the spatial representation point, and its normal direction distance is calculated, which is the projection scalar. Points with a projection distance less than 0, that is, points in the negative normal direction, are retained to form the candidate point set on the outer side of the tissue.

[0083] To identify clear edge structures, a sliding window method is used to select cell points closest to the edge from a candidate point set on the outer side of the tissue. Specifically, a sliding window is established along the central path's principal axis, with a default window width of 10. Within each window region, the expression point with the smallest normal distance (y-value) is selected and recorded as the local edge point. All edge points are sorted along the central path's principal axis to form an edge point column. After constructing the initial edge point column, a cubic spline interpolation function is used to fit the edge points to improve continuity and smoothness. The fitting uses an unbiased fitting parameter of smoothing=0 to maintain the original boundary trend, selecting 400 points at equal intervals, which can be adjusted according to actual needs, and the number of interpolation points can be expanded to a high resolution. In this application, high resolution refers to the number of points corresponding to the total cumulative arc length, ultimately forming a continuous, differentiable edge reference line. The edge reference line replaces the central principal path as the baseline for constructing the final unfolded coordinate system, which can better fit the true boundary of the tissue, adapt to complex spiral structures such as the intestine, and avoid unfolding errors caused by internal offsets of the principal path. Figure 7 The left image shows a jagged edge line formed by connecting the original edge points. Figure 7 The right figure shows a continuous reference edge line generated after smoothing with a spline function, which has higher structural fidelity and coordinate consistency.

[0084] Step S6: Construct an expanded coordinate system with the cumulative arc length of the edge reference line as the horizontal axis and the normal distance from the spatial representation point to the second reference point as the vertical axis. Project all spatial representation points onto the expanded coordinate system and determine the projection target based on the spatial geometric relationship between the spatial representation points and the reference points.

[0085] Based on the reference edge line obtained in step S5, an unfolded coordinate system is constructed, and the spatial representation points are orthogonally projected from the original organizational structure to this coordinate system to realize the planar unfolding and spatial reconstruction of the Swiss roll structure.

[0086] Specifically, all interpolation points in the edge reference line are numbered sequentially, and their cumulative arc length along the line is calculated as the horizontal axis of the expanded coordinate system. Let the reference line point list be... The arc length coordinates of the j-th second reference point are calculated as follows:

[0087]

[0088] x j Indicates the second reference point R j In the expanded coordinate system, the horizontal axis represents the spatial distance from the starting point of the edge reference line to a certain point. A tangent-normal coordinate system is established at the nearest second reference point, and the spatial representation point Q is orthogonally projected onto the normal direction to obtain the vertical axis coordinates:

[0089]

[0090] n j The second reference point R j The unit normal vector, whose direction is determined by the local geometry of the edge reference line. The coordinate pair (x) obtained by projection. j ,y j This represents the position of the represented point in the expanded coordinate system. The vertical axis of the expanded coordinate system represents the position of the spatial represented point after projection along the normal direction.

[0091] To improve the spatial fidelity of the unfolded coordinates, the projection target corresponding to each spatial representation point needs to be determined before projection. Determining the projection target based on the spatial geometric relationship between the spatial representation point and the second reference point includes:

[0092] Calculate the Euclidean distance from each of the spatial representation points to the second reference point, and determine the nearest matching reference point;

[0093] Candidate projection points are determined from the matching reference points based on the candidate projection conditions;

[0094] From all the candidate projection points, the candidate reference point with the smallest Euclidean distance to the spatial representation point is selected as the projection target.

[0095] Calculate the Euclidean distance between each cell point and the interpolated reference points on all edge reference lines, i.e., the second reference points, and initially screen out a batch of matching reference points that are closest to the cell point.

[0096] Next, for each candidate reference point, it is further determined whether it meets the candidate projection conditions: first, the normal vector of the cell point is in the same direction as that of the reference point, that is, the dot product of the vector difference and the normal vector is greater than zero; second, the angle between the cell point and the normal vector does not exceed a preset upper limit, such as 30°, that is, the cosine value of the angle is greater than or equal to cos(30°). Only when both of the above conditions are met simultaneously is the reference point included in the final candidate projection point set.

[0097] like Figure 8a The image shown is a diagram of the original Swiss roll-shaped intestinal cell structure. Figure 8b The image shown is a diagram of the intestinal cell structure after unfolding the coordinates, as follows: Figure 8c The image shown is a magnified partial view within a specified range. Among all candidate projection points that satisfy the directional and angle conditions, the reference point with the smallest Euclidean distance to the cell point is selected as the projection target of that cell point in the unfolded coordinate system. The arc length of this point is used as the abscissa, and the projection value of the normal direction is used as the ordinate to construct the two-dimensional coordinates of the cell point in the unfolded space.

[0098] like Figure 9a , 9b As shown, this projection method can better maintain the spatial geometric correspondence between microbial points and tissue edges, and maintain a relatively consistent anatomical layering relationship in samples with different folded structures. It avoids cross-structure mismatch caused by directly using Euclidean nearest points, which is beneficial for subsequent bioinformatics tasks such as host-microbe neighborhood analysis and spatial enrichment.

[0099] Step S7: Project the target object to obtain the unfolded coordinates.

[0100] This includes: writing the expanded coordinates of all spatial representation points into the expanded coordinate matrix field of the spatial data object;

[0101] Based on the expanded coordinates in the field, an original coordinate map and an expanded coordinate map are generated for comparison and display, and the spatial expression points are rendered into multiple layers according to cell type, partition or microbial type.

[0102] After completing the projection operations for all cell and microbial points, the position of each spatial expression point in the unfolded coordinate system is written into the original spatial data object to support downstream analysis and visualization. Specifically, the unfolded coordinate data is stored in the .obsm field of the AnnData object as a two-dimensional matrix, with the key name set to unrolled spatial. Each row corresponds to a spatial expression point, and each column records its horizontal axis (arc length along the edge reference line) and vertical axis (projection distance along the normal direction) in the unfolded coordinate system.

[0103] After expanding the coordinates and writing them into the data structure, as follows: Figure 10a , 10b As shown in Figure 10c, it can be directly used for analysis and result display in various downstream tasks. The visualization module supports calling graphics libraries such as matplotlib or plotly to compare and display the spatial distribution structure in the original coordinate system and the unfolded coordinate system. Users can view the expression point distribution of tissues in the original structure, such as a Swiss roll-shaped intestinal slice, and in the unfolded state side-by-side in the same graphics window, clearly demonstrating the effect of spatial reconstruction.

[0104] Simultaneously, spatial expression points can be rendered in layers based on cell type annotations, tissue partition labels, or microbial classification information to assist users in identifying local structures, layered tissues, or microbial aggregation phenomena. Multiple layers of expression points can be overlaid in the expanded coordinate graph, and different types of point sets can be distinguished by color, shape, or transparency, further enhancing the visual interpretability of anatomical structures and spatial relationships.

[0105] Furthermore, the unfolded coordinate data can also be used as input for a range of spatial omics analysis tasks, including but not limited to cell density estimation, local tissue stratification identification, host-microbe neighborhood analysis, spatial enrichment analysis, and receptor-ligand interaction modeling. The unfolded coordinates preserve the consistency of the anatomical hierarchy in two-dimensional space, making previously distorted or overlapping regions linear and resolvable, greatly improving the computability and biological interpretability of spatial expression data.

[0106] This invention provides a spatial coordinate unfolding and reconstruction method. By extracting the target tissue region, constructing the tissue outline and central path, and mapping all cells and microbial points to an unfolded coordinate system based on edge reference lines through orthogonal projection, the relative positional relationships of spatial expression points in two-dimensional space are reconstructed. This method achieves planar unfolding of coiled tissue structures, maintains the spatial adjacency characteristics of tissue hierarchy and expression points, and effectively improves the structural consistency of spatial group data and the accuracy of subsequent visualization and analysis tasks.

[0107] Based on the same inventive concept, the present invention also provides a computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the steps of the spatial coordinate unfolding and reconstruction method described above.

[0108] The processing methods for computer devices can be referred to the description of the methods above, and will not be repeated here.

[0109] This application also provides a non-transitory machine-readable storage medium storing an executable program, which, when run by a microprocessor, causes the processor to execute the method provided in the above embodiments.

[0110] This invention discloses a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform the described methods.

[0111] This invention discloses a computer program product including a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform the described method.

[0112] The embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0113] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0114] Finally, it should be noted that the embodiments disclosed in this invention are merely preferred embodiments of this invention and are only used to illustrate the technical solutions of this invention, not to limit it. Although this invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this invention.

Claims

1. A method for spatial coordinate unfolding and reconstruction, characterized by, The method includes: Spatial representation points labeled with the target organization type are extracted from the spatial group data. An adjacency graph is constructed based on the spatial location of the spatial representation points, and the largest connected cluster is extracted. Clusters with an area smaller than a preset threshold or too far from the main cluster are filtered out. The coordinates of the filtered spatial representation points are normalized to generate a standardized binary image. The binary image is closed and the edges are smoothed. Multiple contour regions are extracted and merged into the main contour. The main contour is then processed by an image skeletonization algorithm to generate a skeleton path map. The pixels in the skeleton path graph are constructed into a graph structure, with each pixel as a node and edges established between adjacent pixels. Endpoints are identified and endpoint pairs are constructed. The shortest path between all endpoint pairs is calculated, and the longest path is selected from the shortest paths as the central main path. Based on the image normalization parameters, the central main path in the image coordinates is back-projected to the original spatial coordinate system to determine the central main path and its starting and ending points. A tangent-normal coordinate system is constructed based on the central main path. All spatial representation points are projected along the normal direction, and the distance from the spatial representation point to the first reference point is calculated. In the region of negative normal direction, the local minimum point is identified as the edge spatial representation point by the sliding window method. All the edge spatial representation points are connected to generate a smooth curve. The edge reference line is generated by spline interpolation fitting. Construct an expanded coordinate system with the cumulative arc length of the edge reference line as the horizontal axis and the normal distance from the spatial representation point to the second reference point as the vertical axis. Project all spatial representation points onto the expanded coordinate system and determine the projection target based on the spatial geometric relationship between the spatial representation points and the reference points. Project the target object to obtain the unfolded coordinates.

2. The method of space coordinate unwrapping and reconstruction according to claim 1, wherein, The spatial expression points include cellular points or microbial points, and the projection target is determined based on the spatial geometric relationship between the spatial expression points and the second reference point, including: Calculate the Euclidean distance from each of the spatial representation points to the second reference point, and determine the nearest matching reference point; Candidate projection points are determined from the matching reference points based on the candidate projection conditions; From all the candidate projection points, the candidate reference point with the smallest Euclidean distance to the spatial representation point is selected as the projection target.

3. The method of space coordinate unwrapping and reconstruction according to claim 2, wherein, The candidate projection conditions include: the direction of the normal vector of the spatial representation point is consistent with that of the second reference point, and the angle between the spatial representation point and the normal is not greater than a preset angle.

4. The method of space coordinate unwrapping and reconstruction of claim 2, wherein, Projecting onto the target object yields the unfolded coordinates, which also includes: Write the expanded coordinates of all spatial representation points into the expanded coordinate matrix field of the spatial data object; Based on the expanded coordinates in the field, an original coordinate map and an expanded coordinate map are generated for comparison and display, and the spatial expression points are rendered into multiple layers according to cell type, partition or microbial type.

5. The method of space coordinate unwrapping and reconstruction of claim 3, wherein, The image normalization parameters include the canvas size, edge size, and the maximum and minimum values ​​of the coordinates; The central principal path in the image coordinate system is back-projected to the original spatial coordinate system based on the image normalization parameters, including: The scale value is calculated based on the image normalization parameters, and the central main path in the image coordinates is back-projected to the original spatial coordinate system based on the scale value.

6. The method of space coordinate unwrapping and reconstruction of claim 5, wherein, The first reference point is the point on the skeleton path that is closest to the spatial representation point; the second reference point is the fitting sampling point on the edge reference line, which is used to match the target point when the spatial representation point is projected into the unfolded coordinate system.

7. The spatial coordinate unfolding and reconstruction method according to claim 1, characterized in that, The process of constructing a graph structure from the pixels in the skeleton path graph, establishing edges between adjacent pixels with pixels as nodes, identifying endpoints and constructing endpoint pairs, also includes: For path segments with breakpoints in the skeleton path graph, calculate the Euclidean distance between breakpoint pairs. When the distance threshold condition is met, use the Bresenham algorithm to perform path bridging repair at the pixel level. If the distance threshold is not met, a specified endpoint pair is obtained for repair; the distance threshold condition is that it is less than the distance of the preset maximum connection.

8. A computer device, characterized in that, include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the steps of the spatial coordinate unfolding and reconstruction method as claimed in any one of claims 1-7.

9. A computer storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the steps of the spatial coordinate unfolding and reconstruction method as claimed in any one of claims 1-7.

Citation Information

Patent Citations

  • System for processing whole slice image WSI of biopsy

    CN115151956A

  • Space curved surface imaging method based on ultrasonic imaging data and electronic equipment

    CN115731234A