A gastroscopic biopsy site intelligent repositioning method and system

CN122597516APending Publication Date: 2026-08-18DONGFANG HOSPITAL BEIJING UNIV OF CHINESE MEDICINE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610791717.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-03
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

筛查获取的位点数量繁杂,无用干扰位点占比偏高,后续位点甄别工作会耗费大量人力与时间,位点匹配贴合度较差

Benefits of technology

[0066] Based on a segmentation mask utilizing the gastric anatomical structure, historical biopsy site coordinate mapping is achieved. The segmentation mask is used to delineate the effective gastric region within the gastroscopy image, eliminating non-gastric background interference pixels. Combining the spatial distribution relationships of the gastric anatomical structure, image coordinate system transformations are performed under different imaging conditions, correcting the positions of the original biopsy sites in historical records. This approach mitigates positional interference caused by physiological deformation of the stomach, shooting angle shifts, and changes in shooting distance, enabling the replication of biopsy site positions in new image sequences from different examination periods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122597516A_ABST
    Figure CN122597516A_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent relocation method and system for gastroscopy biopsy sites, belonging to the field of medical image detection technology. The method includes acquiring gastroscopy image sequences and historical biopsy site records of the target patient; performing anatomical structure segmentation on the image sequences to obtain a gastric region segmentation mask; mapping the original biopsy sites to coordinates based on the segmentation mask to generate mapped site coordinates adapted to the current image sequence; employing an improved nearest neighbor search algorithm with embedded spatiotemporal continuity constraints to filter and obtain a set of candidate relocation sites; performing spatial clustering on the candidate set to finally output the coordinates of the target relocation site. This method combines gastric anatomical structure to complete coordinate conversion, utilizes the spatiotemporal correlation characteristics of images to optimize site selection, adapts to scenarios of gastric deformation and changing shooting angles, and is suitable for clinical gastroscopy biopsy site retrospective localization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of medical image detection technology, specifically a method and system for intelligent relocation of biopsy sites in gastroscopy. Background Technology

[0002] Endoscopic biopsy is a common diagnostic and treatment method for screening and pathological diagnosis of gastric lesions. During clinical follow-up, it is necessary to repeatedly locate and observe the sites of previous biopsies. Currently, the relocation of endoscopic biopsy sites largely relies on manual identification and comparison by operators, while automated localization methods mostly use simple pixel matching algorithms to process images. This type of processing mode only collects surface pixel information of the image and does not combine the inherent anatomical features of the stomach to perform coordinate conversion. Therefore, the site data in historical biopsy records cannot establish a spatial correspondence with the currently captured endoscopic image.

[0003] During gastroscopy, the stomach undergoes physiological peristaltic deformation, and the shooting angle and distance dynamically change with the operation. Simple pixel matching is easily affected by image distortion and background interference, resulting in coordinate shifts. Conventional site retrieval algorithms only select nearby sites based on spatial distance, without considering the temporal correlation features formed by continuous imaging of gastroscopy images. The spatiotemporal correlation attributes between images are not utilized. The number of sites obtained through screening is large and complex, with a high proportion of useless and interfering sites. Subsequent site identification work consumes a lot of manpower and time, and the site matching accuracy is poor. Summary of the Invention

[0004] This invention aims to solve at least one of the technical problems existing in the prior art;

[0005] Therefore, this invention proposes a smart relocation method for endoscopic biopsy sites, comprising:

[0006] Obtain the gastroscopy image sequence of the target patient and the corresponding biopsy site history;

[0007] The gastroscopy image sequence is processed to segment the gastric anatomy structure, resulting in a gastric region segmentation mask;

[0008] Based on the gastric region segmentation mask, coordinate mapping processing is performed on each original biopsy site in the biopsy site history to generate the mapped site coordinates of each original biopsy site in the current gastroscopy image sequence;

[0009] An improved nearest neighbor search algorithm is invoked, which is based on the spatiotemporal continuity constraint between the mapped site coordinates and the gastroscopy image sequence to select a set of candidate relocation sites from the gastroscopy image sequence.

[0010] Spatial clustering is performed on the candidate relocation site set to filter the results and output the coordinates of the target relocation site.

[0011] Further, the step of performing gastric anatomical structure segmentation processing on the gastroscopy image sequence to obtain a gastric region segmentation mask specifically includes:

[0012] Each frame of the gastroscopy image sequence is input into a pre-trained gastric anatomy segmentation network;

[0013] The encoder of the gastric anatomy segmentation network performs multi-scale feature extraction processing on each frame of gastroscopy image to generate image feature maps of multiple scales.

[0014] The decoder of the gastric anatomy segmentation network performs upsampling and fusion processing on the image feature maps of the multiple scales to generate a pixel-level classification probability map with the same resolution as each frame of gastroscopy image.

[0015] A threshold binarization operation is performed on the classification probability of each pixel in the pixel-level classification probability map. Pixels with a classification probability greater than a preset threshold are marked as stomach tissue regions, and pixels with a classification probability less than or equal to the preset threshold are marked as non-stomach tissue regions.

[0016] The set of all pixels marked as stomach tissue regions is used as the stomach region segmentation mask.

[0017] Further, the step of performing coordinate mapping processing on each original biopsy site in the biopsy site history based on the gastric region segmentation mask to generate the mapped site coordinates of each original biopsy site in the current gastroscopy image sequence specifically includes:

[0018] Read the historical image identifier and historical pixel coordinates of each original biopsy site from the biopsy site history record;

[0019] Based on the historical image identifier, retrieve the corresponding historical gastroscopy image from the historical gastroscopy image database, and obtain the historical gastric region segmentation mask corresponding to the historical gastroscopy image;

[0020] Calculate the affine transformation matrix between the historical gastric region segmentation mask and the gastric region segmentation mask. The affine transformation matrix is ​​used to transform the pixel coordinates in the historical gastric region segmentation mask to the coordinate system of the current gastroscopy image sequence.

[0021] Multiply the historical pixel coordinates of each original biopsy site by the affine transformation matrix to obtain the initial mapped coordinates of each original biopsy site in the current gastroscopy image sequence.

[0022] Determine whether each initial mapping coordinate falls within the gastric tissue region of the gastric region segmentation mask. If it does, use the initial mapping coordinate as the mapping site coordinate of the original biopsy site.

[0023] If the initial mapping coordinates do not fall within the target area, the initial mapping coordinates are moved along the gradient direction to the nearest boundary point of the gastric tissue region of the gastric region segmentation mask, and the coordinates of the nearest boundary point are used as the mapping site coordinates of the original biopsy site.

[0024] Furthermore, the step of invoking the improved nearest neighbor search algorithm, which is based on the spatiotemporal continuity constraints between the mapped site coordinates and the gastroscopy image sequence, to select a set of candidate relocation sites from the gastroscopy image sequence, specifically includes:

[0025] The coordinates of the mapping sites corresponding to each frame of the gastroscopy image sequence are arranged in the order of the frame index to form a spatiotemporal mapping site trajectory.

[0026] The displacement vector between the coordinates of the mapping sites corresponding to two adjacent frames of gastroscopy images is extracted from the spatiotemporal mapping site trajectory to form a displacement vector sequence.

[0027] The displacement vector sequence is subjected to sliding window mean filtering to obtain a smooth displacement vector sequence;

[0028] Based on the smooth displacement vector sequence, the spatiotemporal mapping site trajectory is forward-predicted to generate the predicted site coordinates corresponding to the current frame of the gastroscopy image;

[0029] A search window is constructed centered on the predicted site coordinates. Within the search window, all pixels in the current frame of the gastroscopy image are traversed in ascending order of distance. The first pixel located within the gastric tissue region is taken as a candidate relocation site.

[0030] The set of all candidate repositioning sites in the current frame of the gastroscopy image is taken as the candidate repositioning site set.

[0031] Furthermore, the working process of the improved nearest neighbor search algorithm specifically includes:

[0032] The displacement change rate between two adjacent frames is calculated based on the smoothed displacement vector sequence to obtain the displacement change rate sequence;

[0033] Identify the locations of abrupt change frames where the displacement change rate exceeds a preset change rate threshold from the displacement change rate sequence, and mark the coordinates of the mapping site corresponding to the abrupt change frame location as an unstable mapping point;

[0034] When the Euclidean distance between the predicted site coordinates and the unstable mapping point is less than a preset distance threshold, the radius of the search window is increased to twice the initial radius;

[0035] When the Euclidean distance between the predicted site coordinates and the unstable mapping point is greater than or equal to a preset distance threshold, the radius of the search window is kept at the initial radius.

[0036] Within the expanded search window or the initial search window, all pixels are traversed in ascending order of distance, skipping pixels that have been marked as contraindicated areas for biopsy, and the first pixel located within the gastric tissue region that has not been marked as a contraindicated area for biopsy is taken as a candidate relocation site.

[0037] Further, the step of performing spatial clustering filtering on the candidate relocation site set and outputting the coordinates of the target relocation site specifically includes:

[0038] Map all candidate repositioning sites in the candidate repositioning site set to the pixel coordinate system of the current frame gastroscopy image to obtain the candidate point coordinate set;

[0039] Randomly select an unvisited candidate point from the set of candidate point coordinates as the initial cluster center;

[0040] Calculate the spatial distance between each un-clustered candidate point in the candidate point coordinate set and the initial cluster center, and classify the candidate points whose spatial distance is less than the preset cluster radius into the current cluster;

[0041] Update the center point of the current cluster to the arithmetic mean center of the coordinates of all candidate points within the cluster, and repeat the inclusion operation until the current cluster no longer absorbs new candidate points;

[0042] The current cluster is marked as a visited cluster, and the next initial cluster center is selected from the remaining unvisited candidate points until all candidate points have been visited.

[0043] Calculate the cluster density value for each cluster, where the cluster density value is the ratio of the number of candidate points in the cluster to the spatial area occupied by the cluster.

[0044] Select the cluster with the highest cluster density value, and use the center point of the cluster as the coordinates of the target relocation site.

[0045] Furthermore, after outputting the coordinates of the target relocation site, the method also includes a confidence-weighted correction operation for different gastric regions, specifically including:

[0046] Obtain the gastric anatomical structure labels in the gastric region segmentation mask, wherein the gastric anatomical structure labels include gastric fundus region labels, gastric body region labels, gastric antrum region labels, and cardia region labels;

[0047] Preset biopsy confidence weight values ​​were assigned to each gastric anatomical structure label, with the highest biopsy confidence weight value corresponding to the gastric antrum region label, followed by the gastric body region label, and the lowest biopsy confidence weight values ​​corresponding to the gastric fundus region label and the cardia region label.

[0048] Determine the gastric anatomical structure label to which the coordinates of the target relocation site belong in the gastric region segmentation mask, and obtain the biopsy confidence weight value corresponding to the gastric anatomical structure label as the site confidence weight;

[0049] The historical number of successful biopsies for each original biopsy site is counted from the biopsy site history records, and the average number of successful biopsies for all original biopsy sites is calculated as a reference number of successful biopsies.

[0050] The product of the site confidence weight and the number of reference successes is used as the weighted confidence score of the target relocation site coordinates. When the weighted confidence score is lower than a preset score threshold, the center point of the cluster with the second largest cluster density value is used as the corrected target relocation site coordinates.

[0051] Furthermore, after outputting the target relocation site coordinates, the method also includes a site dynamic tracking operation based on respiratory motion compensation, specifically including:

[0052] The area change sequence of the gastric region segmentation mask in multiple consecutive frames of gastroscopy images in the gastroscopy image sequence is acquired in real time.

[0053] The area change sequence is subjected to frequency domain transformation processing to extract the main frequency component of the area change sequence, and the frequency value of the main frequency component is used as the patient's respiratory rate value.

[0054] A respiratory motion displacement model is constructed based on the respiratory frequency value. The respiratory motion displacement model describes the functional relationship between the displacement of the stomach tissue and the phase angle during the respiratory cycle.

[0055] Obtain the current phase angle relative to the start of the respiratory cycle at the current moment, substitute the current phase angle into the respiratory motion displacement model, and calculate the respiratory motion displacement vector at the current moment;

[0056] Add the respiratory motion displacement vector to the target repositioning point coordinates to generate the dynamic repositioning point coordinates after respiratory compensation.

[0057] The coordinates of the dynamically repositioned site are output to the gastroscopy navigation interface in real time for dynamic marking and display.

[0058] Further, the step of constructing a respiratory motion displacement model based on the respiratory frequency value, wherein the respiratory motion displacement model describes the functional relationship between the displacement of gastric tissue and the phase angle during the respiratory cycle, specifically includes:

[0059] Optical flow field calculations are performed on the gastric region segmentation mask in multiple consecutive respiratory cycles in the gastroscopy image sequence to obtain the displacement trajectory of each pixel in the respiratory cycle;

[0060] The displacement sequence of the geometric center point of the stomach region segmentation mask is extracted from the displacement trajectory and used as the overall displacement reference trajectory of the stomach. The overall displacement reference trajectory of the stomach is segmented and aligned according to the respiratory cycle to obtain multiple single-cycle displacement trajectory segments.

[0061] The average displacement trajectory is obtained by arithmetically averaging the displacement values ​​of the multiple single-cycle displacement trajectory segments at the same phase angle.

[0062] The average displacement trajectory is fitted into a Fourier series form, where the fundamental frequency of the Fourier series is equal to the respiratory frequency value, the constant term of the Fourier series represents the DC bias of the respiratory displacement, and the first harmonic coefficient and the second harmonic coefficient of the Fourier series represent the main displacement components of the respiratory motion.

[0063] The Fourier series is used as the respiratory motion displacement model.

[0064] Furthermore, the present invention also includes an intelligent relocation system for gastroscopy biopsy sites. The gastroscopy biopsy navigation system includes a processor and a memory. The memory is connected to the processor and is used to store programs, instructions, or code. The processor is used to run the programs, instructions, or code in the memory to implement the intelligent relocation method for gastroscopy biopsy sites as described above.

[0065] Compared with the prior art, the beneficial effects of the present invention are:

[0066] Based on a segmentation mask utilizing the gastric anatomical structure, historical biopsy site coordinate mapping is achieved. The segmentation mask is used to delineate the effective gastric region within the gastroscopy image, eliminating non-gastric background interference pixels. Combining the spatial distribution relationships of the gastric anatomical structure, image coordinate system transformations are performed under different imaging conditions, correcting the positions of the original biopsy sites in historical records. This approach mitigates positional interference caused by physiological deformation of the stomach, shooting angle shifts, and changes in shooting distance, enabling the replication of biopsy site positions in new image sequences from different examination periods.

[0067] By embedding spatiotemporal continuity constraints into the nearest neighbor search algorithm and combining the temporal and spatial correlation characteristics of continuously acquired gastroscopy images, the algorithm's internal site retrieval and judgment logic is adjusted. Sites that fit the imaging pattern are selected based on mapped site coordinates, reducing the number of non-associative interference sites included. Spatial clustering is performed on the selected candidate site set, eliminating scattered and discrete abnormal sites and aggregating sites with similar spatial attributes, thus compressing the site selection range, simplifying the site identification process, and better aligning with the actual application scenarios of dynamic gastroscopy imaging. Attached Figure Description

[0068] Figure 1 This is a flowchart of a method for intelligent relocation of biopsy sites during gastroscopy, as described in this invention.

[0069] Figure 2 A flowchart illustrating the mapping of the original biopsy site coordinates;

[0070] Figure 3 A flowchart for generating the set of candidate relocation sites. Detailed Implementation

[0071] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0072] See Figure 1 A method for intelligent relocation of endoscopic biopsy sites is disclosed, with the following specific implementation: The gastroscopy image sequence and corresponding biopsy site history of the target patient are acquired. Gastric anatomical structure segmentation processing is performed on the gastroscopy image sequence to obtain a gastric region segmentation mask. Based on the gastric region segmentation mask, coordinate mapping processing is performed on each original biopsy site in the biopsy site history to generate mapped site coordinates for each original biopsy site in the current gastroscopy image sequence. An improved nearest neighbor search algorithm is invoked, which, based on the spatiotemporal continuity constraint between the mapped site coordinates and the gastroscopy image sequence, filters out a set of candidate relocation sites from the gastroscopy image sequence. Spatial clustering filtering processing is performed on the candidate relocation site set to output the coordinates of the target relocation site.

[0073] In one embodiment of the present invention, see [reference] Figure 2The process of performing gastric anatomical structure segmentation on the gastroscopy image sequence to obtain a gastric region segmentation mask is as follows: Each frame of the gastroscopy image sequence is input into a pre-trained gastric anatomical structure segmentation network. The encoder of the gastric anatomical structure segmentation network performs multi-scale feature extraction on each frame of the gastroscopy image, generating image feature maps at multiple scales. The decoder of the gastric anatomical structure segmentation network performs progressive upsampling and fusion processing on the image feature maps at multiple scales, generating a pixel-level classification probability map with the same resolution as each frame of the gastroscopy image. A threshold binarization operation is performed on the classification probability of each pixel in the pixel-level classification probability map. Pixels with a classification probability greater than a preset threshold are marked as gastric tissue regions, and pixels with a classification probability less than or equal to the preset threshold are marked as non-gastric tissue regions. The set of all pixels marked as gastric tissue regions is used as the gastric region segmentation mask.

[0074] In practice, after acquiring the gastroscopy image sequence of the target patient, each frame of the gastroscopy image sequence is input into a pre-trained gastric anatomy segmentation network, which employs an encoder-decoder architecture. The encoder of the gastric anatomy segmentation network performs multi-scale feature extraction processing on each frame of the gastroscopy image, generating image feature maps at multiple scales. The encoder contains multiple convolutional layers and pooling layers, with each scale of image feature map corresponding to a different spatial resolution.

[0075] The decoder of the gastric anatomy segmentation network performs upsampling and fusion processing on the image feature maps at multiple scales to generate a pixel-level classification probability map with the same resolution as each frame of the gastroscopy image. The value of each pixel in the pixel-level classification probability map represents the probability value of that pixel belonging to the gastric tissue category.

[0076] In some embodiments, a threshold binarization operation is performed on the classification probability of each pixel in the pixel-level classification probability map. Pixels with a classification probability greater than a preset threshold are marked as stomach tissue regions, and pixels with a classification probability less than or equal to the preset threshold are marked as non-stomach tissue regions. The preset threshold is set to 0.5. The set of all pixels marked as stomach tissue regions is used as the stomach region segmentation mask. The stomach region segmentation mask is a binary image, where the pixel value corresponding to the stomach tissue region is 1, and the pixel value corresponding to the non-stomach tissue region is 0. During the progressive upsampling fusion process, the decoder uses a transposed convolution operation at each upsampling level to double the feature map size and performs skip connections to fuse it with the image feature map of the corresponding level of the encoder.

[0077] Optionally, the multi-scale image feature map generated by the encoder includes four scales. The resolution of the first scale image feature map is half that of the original gastroscopy image, the resolution of the second scale image feature map is one-quarter that of the original gastroscopy image, the resolution of the third scale image feature map is one-eighth that of the original gastroscopy image, and the resolution of the fourth scale image feature map is one-sixteenth that of the original gastroscopy image. When the decoder performs progressive upsampling and fusion processing on the image feature maps of the four scales, it upsamples the image feature map of the fourth scale to obtain a feature map with the same resolution as the image feature map of the third scale. The upsampled feature map is then concatenated with the image feature map of the third scale and then convolved and fused. This process is repeated until the resolution of the original gastroscopy image is restored.

[0078] In specific implementation, the training process of the pre-trained gastric anatomy segmentation network uses a weighted sum of the Dice loss function and the cross-entropy loss function as the total loss function, with a weight of 0.6 for the Dice loss function and a weight of 0.4 for the cross-entropy loss function. The resolution width of the pixel-level classification probability map... and height The width and height of the input gastroscopy image should be consistent with the resolution, satisfying the requirements. and ,in This indicates the width in pixels of the input gastroscopy image. This represents the height in pixels of the input gastroscopy image. In some embodiments, the height in pixels of the gastroscopy image sequence is... After a frame of gastroscopy image is input into the gastric anatomy segmentation network, the gastric anatomy segmentation network outputs a pixel-level classification probability map corresponding to the t-th frame of gastroscopy image. The median coordinate is Classification probability value of pixels The calculation formula is:

[0079]

[0080] in: This represents the row index of a pixel, with a value ranging from 1 to... , The column index represents the pixel, with values ​​ranging from 1 to... , This indicates the number of convolutional kernels in the last convolutional layer of the gastric anatomy segmentation network. Indicates the first The weight parameters of each convolutional kernel, Indicates the first Each convolutional kernel is located at... Activation value at that location, Indicates the bias parameter. express Activation function. The threshold binarization operation will convert the classification probability value... Pixels with a probability value greater than 0.5 are labeled as stomach tissue regions, and the classification probability value is... Pixels with a value less than or equal to 0.5 are marked as non-gastric tissue regions.

[0081] Optionally, after obtaining the stomach region segmentation mask, a morphological closing operation is performed on the stomach region segmentation mask. The morphological closing operation uses a circular structuring element with a radius of 3 pixels. First, an expansion operation is performed on the stomach region segmentation mask, and then an erosion operation is performed on the expansion result to fill the small holes inside the stomach tissue region and connect the adjacent stomach tissue regions.

[0082] It is understood that the pixels marked as stomach tissue regions in the stomach region segmentation mask may contain multiple connected components. The connected component with the largest area is taken as the main stomach region, and connected components with an area smaller than a preset area threshold are removed. The preset area threshold is set to 5% of the total number of pixels in the stomach image. It is also understood that before performing the threshold binarization operation, the pixel-level classification probability map is subjected to Gaussian smoothing filtering with a Gaussian kernel size of 5×5 and a standard deviation of 1.0 to reduce the impact of noise points in the pixel-level classification probability map on the subsequent binarization results.

[0083] In one embodiment of the present invention, coordinate mapping processing is performed on each original biopsy site in the biopsy site history based on the gastric region segmentation mask, see [reference]. Figure 3 The process of generating the mapped coordinates of each original biopsy site in the current gastroscopy image sequence specifically involves: reading the historical image identifier and historical pixel coordinates of each original biopsy site from the historical biopsy site history record; retrieving the corresponding historical gastroscopy image from the historical gastroscopy image database based on the historical image identifier, and obtaining the historical gastric region segmentation mask corresponding to the historical gastroscopy image; calculating the affine transformation matrix between the historical gastric region segmentation mask and the gastric region segmentation mask, which is used to transform the pixel coordinates in the historical gastric region segmentation mask to the coordinate system of the current gastroscopy image sequence.

[0084] Multiply the historical pixel coordinates of each original biopsy site by the affine transformation matrix to obtain the initial mapped coordinates of each original biopsy site in the current gastroscopy image sequence. Determine whether each initial mapped coordinate falls within the gastric tissue region of the gastric region segmentation mask. If it does, the initial mapped coordinate is used as the mapped site coordinate of that original biopsy site. If it does not fall within the region, the initial mapped coordinate is moved along the gradient direction to the nearest boundary point of the gastric tissue region of the gastric region segmentation mask, and the coordinates of the nearest boundary point are used as the mapped site coordinates of that original biopsy site.

[0085] In specific implementation, the historical image identifier and historical pixel coordinates of each original biopsy site are read from the biopsy site history record. Based on the historical image identifier, the corresponding historical gastroscopy image is retrieved from the historical gastroscopy image database, and the historical gastric region segmentation mask corresponding to the historical gastroscopy image is obtained. An affine transformation matrix is ​​calculated between the historical gastric region segmentation mask and the gastric region segmentation mask. This affine transformation matrix is ​​used to transform the pixel coordinates in the historical gastric region segmentation mask to the coordinate system of the current gastroscopy image sequence. The historical pixel coordinates of each original biopsy site are multiplied by the affine transformation matrix to obtain the initial mapped coordinates of each original biopsy site in the current gastroscopy image sequence. The initial mapped coordinates (… , The formula for calculating ) is:

[0086]

[0087] in: This represents the horizontal coordinate value of the historical pixel coordinates. This represents the vertical coordinate value of the historical pixel coordinates. , , , , , The six affine transformation parameters are in the affine transformation matrix. This represents the horizontal coordinate value of the initial mapped coordinates. This represents the vertical coordinate value of the initial mapped coordinates.

[0088] In some embodiments, it is determined whether each initial mapping coordinate falls within the gastric tissue region of the gastric region segmentation mask. If it does, the initial mapping coordinate is used as the mapping site coordinate of the original biopsy site. If it does not, the initial mapping coordinate is moved along the gradient direction to the nearest boundary point of the gastric tissue region of the gastric region segmentation mask, and the coordinates of the nearest boundary point are used as the mapping site coordinates of the original biopsy site. In some embodiments, the gradient direction is obtained by calculating the distance transformation field of the gastric region segmentation mask. The value of each pixel in the distance transformation field represents the shortest Euclidean distance from that pixel to the boundary of the gastric tissue region. The movement is performed along the direction in which the distance transformation field value decreases the fastest, starting from the initial mapping coordinate and iteratively moving at a step size of one pixel distance until a pixel located within the gastric tissue region is reached.

[0089] Optionally, during the process of moving the initial mapped coordinates along the gradient direction to the nearest boundary point, the movement stops when the number of iterations exceeds a preset maximum step threshold, and the pixel within the gastric tissue region closest to the initial mapped coordinates in the current frame of the gastroscopy image is taken as the nearest boundary point. Optionally, when the initial mapped coordinates are located outside the gastric tissue region of the gastric region segmentation mask and the gradient direction of the distance transformation field points to a local minimum point, an eight-neighborhood breadth-first search is used instead of gradient direction movement. An eight-neighborhood expansion search is performed starting from the initial mapped coordinates until any pixel within the gastric tissue region is found. It can be understood that before calculating the affine transformation matrix, the resolution of the historical gastric region segmentation mask is unified to the same resolution as the gastric region segmentation mask using bilinear interpolation.

[0090] It is understood that a first set of feature points is extracted from the historical stomach region segmentation mask, a second set of feature points is extracted from the stomach region segmentation mask, and a random sampling consensus algorithm is used to filter matching point pairs. Then, the least squares method is used to solve for the six affine transformation parameters in the affine transformation matrix.

[0091] In one embodiment of the present invention, an improved nearest neighbor search algorithm is invoked. This improved nearest neighbor search algorithm, based on the spatiotemporal continuity constraint between the mapped site coordinates and the gastroscopy image sequence, specifically filters out a set of candidate repositioning sites from the gastroscopy image sequence as follows: The mapped site coordinates corresponding to each frame of the gastroscopy image sequence are arranged in frame index order to form a spatiotemporal mapped site trajectory. Displacement vectors between the mapped site coordinates of two adjacent frames of the gastroscopy image are extracted from the spatiotemporal mapped site trajectory to form a displacement vector sequence. A sliding window mean filtering process is performed on the displacement vector sequence to obtain a smoothed displacement vector sequence. Forward prediction is performed on the spatiotemporal mapped site trajectory based on the smoothed displacement vector sequence to generate predicted site coordinates corresponding to the current frame of the gastroscopy image. A search window is constructed centered on the predicted site coordinates. Within the search window, all pixels in the current frame of the gastroscopy image are traversed in ascending distance order, and the first pixel located within the gastric tissue region is taken as a candidate repositioning site. The set of all candidate repositioning sites in the current frame of the gastroscopy image is taken as the candidate repositioning site set.

[0092] The improved nearest neighbor search algorithm works as follows: The displacement change rate between two adjacent frames is calculated based on the smoothed displacement vector sequence to obtain a displacement change rate sequence. The positions of abruptly changed frames whose displacement change rate exceeds a preset threshold are identified from the displacement change rate sequence, and the coordinates of the corresponding mapping point at the abruptly changed frame position are marked as unstable mapping points. When the Euclidean distance between the predicted site coordinates and the unstable mapping point is less than a preset distance threshold, the radius of the search window is increased to twice the initial radius. When the Euclidean distance between the predicted site coordinates and the unstable mapping point is greater than or equal to the preset distance threshold, the radius of the search window remains at the initial radius. Within the expanded search window or the initial search window, all pixels are traversed in ascending order of distance, skipping pixels already marked as contraindicated areas for biopsy, and the first pixel located within the gastric tissue region that is not marked as a contraindicated area for biopsy is selected as a candidate relocation site.

[0093] In a specific implementation, the coordinates of the mapping sites corresponding to each frame of the gastroscopy image sequence are arranged in frame index order to form a spatiotemporal mapping site trajectory, which is represented as a sequence. ={ },in This represents the total number of frames in the gastroscopy image sequence. This represents the coordinates of the mapped site corresponding to the t-th frame of the gastroscopy image. The displacement vectors between the coordinates of the mapped sites corresponding to two adjacent frames of the gastroscopy image are extracted from the spatiotemporal mapped site trajectory, forming a displacement vector sequence, which is represented as... ={},in The displacement vector sequence is subjected to sliding window mean filtering to obtain a smoothed displacement vector sequence. The window width of the sliding window is 5 frames. The mean filtering is calculated by taking the arithmetic mean of the displacement vectors within the window. The smoothed displacement vector sequence is represented as follows: ={ Based on the smoothed displacement vector sequence, the spatiotemporal mapped site trajectory is forward-predicted to generate the predicted site coordinates corresponding to the current frame of the gastroscopy image. The calculation formula for the forward prediction is:

[0094]

[0095] in: This represents the predicted site coordinates corresponding to the (t+1)th frame of the gastroscopy image. This represents the coordinates of the mapped site corresponding to the t-th frame of the gastroscopy image. This represents the number of smoothed displacement vectors involved in the prediction. The value is 3. Indicates the first The smooth displacement vector corresponding to the frame, when When less than 1, take the boundary value. .

[0096] In some embodiments, a search window is constructed centered on the predicted site coordinates. Within this search window, all pixels in the current frame of the gastroscopy image are traversed in ascending order of distance. The first pixel located within the gastric tissue region is selected as a candidate relocation site. The search window is a square window with a side length equal to the initial radius multiplied by 2 plus 1 pixel, where the initial radius is 10 pixels. The set of all candidate relocation sites in the current frame of the gastroscopy image is used as the candidate relocation site set. This operation is performed independently on each frame of the current frame of the gastroscopy image to obtain the corresponding candidate relocation sites for each frame.

[0097] In specific implementation, the improved nearest neighbor search algorithm works as follows: It calculates the displacement change rate between two adjacent frames based on the smoothed displacement vector sequence, obtaining a displacement change rate sequence, which is represented as follows: ={ },in ε is set to 0.001 to prevent division by zero errors. The positions of abrupt change frames whose displacement change rate exceeds a preset change rate threshold (2.5) are identified from the displacement change rate sequence. The coordinates of the corresponding mapping point at the abrupt change frame position are marked as unstable mapping points. When the Euclidean distance between the predicted site coordinates and the unstable mapping point is less than a preset distance threshold, the radius of the search window is increased to twice the initial radius (20 pixels), and the preset distance threshold is 15 pixels. When the Euclidean distance between the predicted site coordinates and the unstable mapping point is greater than or equal to the preset distance threshold, the radius of the search window remains at the initial radius (10 pixels).

[0098] In some embodiments, within the expanded search window or the initial search window, all pixels are traversed in ascending distance order, skipping pixels already marked as contraindicated areas for biopsy. The first pixel located within the gastric tissue region that is not marked as a contraindicated area for biopsy is selected as a candidate relocation site. Contraindicated areas for biopsy include areas with prominent blood vessels, bleeding points, and areas with existing biopsy clipping marks. The ascending distance order refers to expanding outwards layer by layer from the center of the predicted site coordinates, with each layer consisting of a set of pixels with the same Manhattan distance, and traversing each layer in a clockwise direction.

[0099] Optionally, in the sliding window mean filtering process, when the length of the displacement vector sequence is less than the width of the sliding window, the first and last elements of the displacement vector sequence are repeatedly filled in a padding manner so that the sliding window can cover the entire sequence, and the padding value is taken as the boundary value of the displacement vector sequence.

[0100] Optionally, when multiple consecutive abrupt change frame positions are identified in the displacement change rate sequence, these multiple consecutive abrupt change frame positions are merged into a single abrupt change frame interval. The midpoint frame position between the start and end frame positions of the abrupt change frame interval is taken as a single abrupt change frame position marker for the unstable mapping point. It can be understood that during the process of traversing all pixels in ascending distance order, a distance hierarchy table is established. This distance hierarchy table pre-stores a list of pixel coordinates corresponding to each Manhattan distance centered on the predicted location coordinates. During traversal, the coordinate order in the distance hierarchy table is directly read, avoiding real-time distance calculation.

[0101] It is understood that the biopsy contraindication region is marked by maintaining a contraindication region mask. This mask has the same resolution as the gastroscopy image. A pixel with a value of 1 in the mask indicates that the pixel is in a biopsy contraindication region. During traversal, the corresponding value of each pixel in the mask is checked; if the value is 1, the pixel is skipped. Referring to Table 1, the configuration relationship of the search window radius adjustment parameters corresponding to different displacement change rate intervals is given. Table 1: Correspondence between Displacement Change Rate Intervals and Search Window Parameter Adjustment Table

[0102] [0,2.5) 1.0 1.0 [2.5,5.0) 1.5 1.2 [5.0,+∞) 2.0 1.5

[0103] The displacement change rate range is divided into three intervals with a preset change rate threshold of 2.5 as the lower bound. When the displacement change rate is in the interval [0, 2.5), the search window radius multiplier is 1.0; when the displacement change rate is in the interval [2.5, 5.0), the search window radius multiplier is 1.5; and when the displacement change rate is in the interval [5.0, +∞), the search window radius multiplier is 2.0. The preset distance threshold multiplier is positively correlated with the search window radius multiplier. When the search window radius multiplier is 1.0, the preset distance threshold multiplier is 1.0; when the search window radius multiplier is 1.5, the preset distance threshold multiplier is 1.2; and when the search window radius multiplier is 2.0, the preset distance threshold multiplier is 1.5. The initial value of the preset distance threshold is 15 pixels, which is multiplied by the corresponding multiplier and then rounded down to obtain the actual preset distance threshold.

[0104] In specific implementation, when the Euclidean distance between the predicted site coordinates and the unstable mapping point is less than the preset distance threshold, the coordinates of the mapping sites corresponding to the two frames preceding and following the mutation frame in the displacement change rate sequence are simultaneously marked as unstable mapping points, forming an unstable mapping point band to enhance the robustness of detecting localized violent movements. When traversing the expanded search window in ascending distance order, pixels marked as being within the unstable mapping point band are skipped and not considered candidate relocation sites, even if they are located within the gastric tissue region and are not marked as contraindicated areas for biopsy, to prevent unstable movements from interfering with the accuracy of candidate site selection.

[0105] In one embodiment of the present invention, the process of performing spatial clustering screening on the candidate relocation site set and outputting the coordinates of the target relocation site specifically involves: mapping all candidate relocation sites in the candidate relocation site set to the pixel coordinate system of the current frame gastroscopy image to obtain a candidate point coordinate set. A randomly selected unvisited candidate point from the candidate point coordinate set is used as the initial cluster center. The spatial distance between each unclustered candidate point in the candidate point coordinate set and the initial cluster center is calculated, and candidate points with a spatial distance less than a preset cluster radius are assigned to the current cluster. The center point of the current cluster is updated to the arithmetic mean center of the coordinates of all candidate points within the cluster, and this assignment operation is repeated until the current cluster no longer absorbs new candidate points. The current cluster is marked as a visited cluster, and the next initial cluster center is selected from the remaining unvisited candidate points until all candidate points have been visited. The cluster density value of each cluster is calculated, where the cluster density value is the ratio of the number of candidate points within the cluster to the spatial area occupied by the cluster. Select the cluster with the highest cluster density value, and use the center point of the cluster as the coordinates of the target relocation site.

[0106] After outputting the target relocation site coordinates, a confidence-weighted correction operation is performed for different gastric regions: Gastric anatomical structure labels are obtained from the gastric region segmentation mask. These labels include labels for the fundus, body, antrum, and cardia regions. A preset biopsy confidence weight value is assigned to each gastric anatomical structure label, with the antrum label having the highest weight, followed by the body label, and the fundus and cardia labels having the lowest weights. The gastric anatomical structure label to which the target relocation site coordinates belong in the gastric region segmentation mask is determined, and the biopsy confidence weight value corresponding to that label is obtained as the site confidence weight.

[0107] The historical biopsy success count for each original biopsy site is counted from the biopsy site history records, and the average number of successful biopsies for all original biopsy sites is calculated as a reference success count. The product of the site confidence weight and the reference success count is used as the weighted confidence score of the target relocation site coordinates. When the weighted confidence score is lower than a preset score threshold, the center point of the cluster with the second largest cluster density value is used as the corrected target relocation site coordinates.

[0108] In a specific implementation, all candidate repositioning sites in the candidate repositioning site set are mapped to the pixel coordinate system of the current frame of the gastroscopy image to obtain the candidate point coordinate set. Randomly select an unvisited candidate point from the set of candidate point coordinates as the initial cluster center. Calculate the relationship between each candidate point that is not clustered and The spatial distance between candidate points is calculated, and candidate points whose spatial distance is less than a preset clustering radius (12 pixels) are assigned to the current cluster. The center point of the current cluster is updated to the arithmetic mean center of the coordinates of all candidate points within the cluster. This assignment operation is repeated until the current cluster no longer absorbs new candidate points. The current cluster is marked as a visited cluster, and the next initial cluster center is selected from the remaining unvisited candidate points until all candidate points have been visited. The cluster density value of each cluster is calculated using the following formula:

[0109]

[0110] in: Indicates the first The cluster density value of each cluster. Indicates the first The number of candidate points within each cluster Indicates the first The spatial area occupied by each cluster. Select the cluster with the highest cluster density value, and use the center point of the cluster as the coordinates of the target relocation site.

[0111] In some embodiments, after outputting the target relocation site coordinates, a confidence-weighted correction operation is performed: Gastric anatomical structure labels are obtained from the gastric region segmentation mask, including labels for the fundus, body, antrum, and cardia regions. Preset biopsy confidence weight values ​​are assigned to each gastric anatomical structure label, where the weight for the antrum label is 0.45, for the body label is 0.35, for the fundus label is 0.12, and for the cardia label is 0.08. The weight corresponding to the gastric anatomical structure label to which the target relocation site coordinates belong is determined as the site confidence weight. The historical biopsy success count for each original biopsy site is counted from the biopsy site history records, and the average biopsy success count for all original biopsy sites is calculated as a reference success count. The product of the site confidence weight and the reference success number is used as the weighted confidence score. When the score is lower than the preset score threshold of 0.25, the center point of the cluster with the second largest cluster density value is used as the corrected target relocation site coordinates, see Table 2.

[0112] Table 2: Biopsy Confidence Weighting Parameters Corresponding to Gastric Anatomical Structure Labels

[0113] Antral region label 0.45 Stomach body region label 0.35 Gastric fundus area label 0.12 Cardia area label 0.08

[0114] In one embodiment of the present invention, after outputting the target repositioning site coordinates, a site dynamic tracking operation based on respiratory motion compensation is performed: The area change sequence of the gastric region segmentation mask in multiple consecutive frames of gastroscopy images in the gastroscopy image sequence is acquired in real time. Frequency domain transformation processing is performed on the area change sequence to extract the dominant frequency component, and the frequency value of the dominant frequency component is used as the patient's respiratory rate. A respiratory motion displacement model is constructed based on the respiratory rate value, which describes the functional relationship between the displacement of gastric tissue and the phase angle during the respiratory cycle. The current phase angle relative to the start of the respiratory cycle is obtained, and the current phase angle is substituted into the respiratory motion displacement model to calculate the respiratory motion displacement vector at the current moment. The target repositioning site coordinates are added to the respiratory motion displacement vector to generate the dynamically repositioning site coordinates after respiratory compensation. The dynamically repositioning site coordinates are output to the gastroscopy navigation interface in real time for dynamic marking and display.

[0115] The process of constructing a respiratory motion displacement model based on the respiratory frequency value is as follows: Optical flow field calculations are performed on the gastric region segmentation mask within multiple consecutive respiratory cycles in the gastroscopy image sequence to obtain the displacement trajectory of each pixel within the respiratory cycle. The displacement sequence of the geometric center point of the gastric region segmentation mask is extracted from the displacement trajectory and used as the overall gastric displacement reference trajectory. The overall gastric displacement reference trajectory is segmented and aligned according to the respiratory cycle to obtain multiple single-cycle displacement trajectory segments. The displacement values ​​of the multiple single-cycle displacement trajectory segments at the same phase angle are arithmetically averaged to obtain the average displacement trajectory. The average displacement trajectory is fitted into a Fourier series form, where the fundamental frequency of the Fourier series is equal to the respiratory frequency value, the constant term of the Fourier series represents the DC bias of the respiratory displacement, and the coefficients of the first and second harmonic terms of the Fourier series represent the main displacement components of the respiratory motion. The Fourier series is used as the respiratory motion displacement model.

[0116] In specific implementation, after outputting the target relocation site coordinates, a site dynamic tracking operation based on respiratory motion compensation is performed: The area change sequence of the gastric region segmentation mask in multiple consecutive frames of gastroscopy images in the gastroscopy image sequence is acquired in real time, and the area change sequence is denoted as... ,in Indicates the first The area and number of pixels of the gastric region segmentation mask in the frame of the gastroscopy image. Frequency domain transformation processing is performed on the area change sequence to extract the dominant frequency component. The frequency value of the dominant frequency component is used as the patient's respiratory rate. The frequency domain transformation processing uses Fast Fourier Transform to transform the area change sequence from the time domain to the frequency domain, and the frequency value corresponding to the amplitude spectrum peak in the frequency domain is found as the respiratory rate value. A respiratory motion displacement model is constructed based on the respiratory rate value. This model describes the functional relationship between the displacement of gastric tissue and the phase angle during the respiratory cycle. The current phase angle relative to the start of the respiratory cycle is obtained, and this current phase angle is substituted into the respiratory motion displacement model to calculate the respiratory motion displacement vector at the current moment. The target repositioning point coordinates are added to the respiratory motion displacement vector to generate the dynamically repositioning point coordinates after respiratory compensation. The dynamically repositioning point coordinates are output to the gastroscopy navigation interface in real time for dynamic marking and display.

[0117] In specific implementation, the process of constructing a respiratory motion displacement model based on the respiratory frequency value is as follows: Optical flow field calculation is performed on the gastric region segmentation mask within multiple consecutive respiratory cycles in the gastroscopy image sequence to obtain the displacement trajectory of each pixel within the respiratory cycle. The optical flow field calculation uses the Lucas-Kanade optical flow algorithm to calculate the optical flow vector of each pixel between two adjacent frames. The displacement sequence of the geometric center point of the gastric region segmentation mask is extracted from the displacement trajectory and used as the overall displacement reference trajectory of the stomach. The coordinates of the geometric center point are calculated using the centroid coordinates.

[0118] The overall stomach displacement reference trajectory is segmented and aligned according to the respiratory cycle to obtain multiple single-cycle displacement trajectory segments. The length of each single-cycle displacement trajectory segment corresponds to the number of frames in one respiratory cycle. The displacement values ​​of the multiple single-cycle displacement trajectory segments at the same phase angle are arithmetically averaged to obtain the average displacement trajectory. The average displacement trajectory is then fitted into a Fourier series form, where the fundamental frequency of the Fourier series is equal to the respiratory frequency value. The constant term of the Fourier series represents the DC bias of the respiratory displacement, and the first and second harmonic coefficients of the Fourier series represent the main displacement components of the respiratory motion. Using the Fourier series as the respiratory motion displacement model, the expression for the respiratory motion displacement model is:

[0119]

[0120] in: Indicates the phase angle is The displacement vector of respiratory motion at that time. This represents the phase angle of the current moment relative to the start of the respiratory cycle, and its value ranges from 0 to 2π. This represents the DC bias displacement vector, where m represents the harmonic order. The values ​​are 1 and 2. This represents the vector of cosine component coefficients of the m-th harmonic. This represents the vector of sinusoidal component coefficients of the m-th harmonic. This indicates the respiratory rate value.

[0121] In some embodiments, when acquiring the area change sequence of the gastric region segmentation mask in multiple consecutive frames of gastroscopy images in the real-time gastroscopy image sequence, the area change data corresponding to the most recent 5 respiratory cycles are taken. Within each respiratory cycle, area values ​​corresponding to 30 phase angles are uniformly sampled. During the extraction of the main frequency components, the area change sequence is first detrended preprocessed by subtracting the linear trend term of the sequence, and then the detrended sequence is windowed using a Hanning window to reduce spectral leakage. In some embodiments, when the dynamically repositioned site coordinates are output to the gastroscopy navigation interface for dynamic marking and display in real time, a color mapping method is used to distinguish the site positions under different respiratory phases. When the respiratory phase angle... When the respiratory phase angle is in the range of 0 to π, it is marked in green. When the position is in the range of π to 2π, it is marked in orange. The dynamic marker shows the position updated in real time with the video frame rate.

[0122] Optionally, during the construction of the respiratory motion displacement model, when the number of multiple single-cycle displacement trajectory segments is less than 3, the linear interpolation of the overall stomach displacement reference trajectory is directly used as the average displacement trajectory, and Fourier series fitting is no longer performed. The linear interpolation uses a piecewise linear function between two adjacent cycles.

[0123] Optionally, during the optical flow field calculation, for pixels at the boundary of the stomach region segmentation mask, since there are no corresponding pixel values ​​outside the boundary, the optical flow vector of the boundary pixel is set to a zero vector and does not participate in the displacement trajectory extraction. It can be understood that the calculation method for the current phase angle relative to the starting point of the respiratory cycle is as follows: record the moment when the area reaches its maximum value in the previous respiratory cycle as the starting point of the respiratory cycle; divide the time difference between the current moment and the starting point of the respiratory cycle by the length of the respiratory cycle to obtain the phase ratio; multiply by 2π to obtain the current phase angle.

[0124] It is understood that when the target repositioning point coordinates are added to the respiratory motion displacement vector to generate the dynamically repositioning point coordinates after respiratory compensation, the respiratory motion displacement vector is a two-dimensional vector containing a horizontal displacement component and a vertical displacement component, which are respectively added to the horizontal and vertical components of the target repositioning point coordinates. The value of the respiratory motion displacement vector is obtained by substituting the current phase angle into the respiratory motion displacement model and outputting a two-dimensional vector value.

[0125] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.

Claims

1. A method for intelligent relocation of endoscopic biopsy sites, characterized in that, The method includes: Obtain the gastroscopy image sequence of the target patient and the corresponding biopsy site history; The gastroscopy image sequence is processed to segment the gastric anatomy structure, resulting in a gastric region segmentation mask; Based on the gastric region segmentation mask, coordinate mapping processing is performed on each original biopsy site in the biopsy site history to generate the mapped site coordinates of each original biopsy site in the current gastroscopy image sequence; An improved nearest neighbor search algorithm is invoked, which is based on the spatiotemporal continuity constraint between the mapped site coordinates and the gastroscopy image sequence to select a set of candidate relocation sites from the gastroscopy image sequence. Spatial clustering is performed on the candidate relocation site set to filter the results and output the coordinates of the target relocation site.

2. The intelligent relocation method for endoscopic biopsy sites according to claim 1, characterized in that, The step of performing gastric anatomical structure segmentation processing on the gastroscopy image sequence to obtain a gastric region segmentation mask specifically includes: Each frame of the gastroscopy image sequence is input into a pre-trained gastric anatomy segmentation network; The encoder of the gastric anatomy segmentation network performs multi-scale feature extraction processing on each frame of gastroscopy image to generate image feature maps of multiple scales. The decoder of the gastric anatomy segmentation network performs upsampling and fusion processing on the image feature maps of the multiple scales to generate a pixel-level classification probability map with the same resolution as each frame of gastroscopy image. A threshold binarization operation is performed on the classification probability of each pixel in the pixel-level classification probability map. Pixels with a classification probability greater than a preset threshold are marked as stomach tissue regions, and pixels with a classification probability less than or equal to the preset threshold are marked as non-stomach tissue regions. The set of all pixels marked as stomach tissue regions is used as the stomach region segmentation mask.

3. The intelligent relocation method for gastroscopy biopsy sites according to claim 2, characterized in that, The step of performing coordinate mapping processing on each original biopsy site in the historical biopsy site record based on the gastric region segmentation mask to generate the mapped site coordinates of each original biopsy site in the current gastroscopy image sequence specifically includes: Read the historical image identifier and historical pixel coordinates of each original biopsy site from the biopsy site history record; Based on the historical image identifier, retrieve the corresponding historical gastroscopy image from the historical gastroscopy image database, and obtain the historical gastric region segmentation mask corresponding to the historical gastroscopy image; Calculate the affine transformation matrix between the historical gastric region segmentation mask and the gastric region segmentation mask. The affine transformation matrix is ​​used to transform the pixel coordinates in the historical gastric region segmentation mask to the coordinate system of the current gastroscopy image sequence. Multiply the historical pixel coordinates of each original biopsy site by the affine transformation matrix to obtain the initial mapped coordinates of each original biopsy site in the current gastroscopy image sequence. Determine whether each initial mapping coordinate falls within the gastric tissue region of the gastric region segmentation mask. If it does, use the initial mapping coordinate as the mapping site coordinate of the original biopsy site. If the initial mapping coordinates do not fall within the target area, the initial mapping coordinates are moved along the gradient direction to the nearest boundary point of the gastric tissue region of the gastric region segmentation mask, and the coordinates of the nearest boundary point are used as the mapping site coordinates of the original biopsy site.

4. The intelligent relocation method for endoscopic biopsy sites according to claim 1, characterized in that, The step of invoking the improved nearest neighbor search algorithm, which is based on the spatiotemporal continuity constraints between the mapped site coordinates and the gastroscopy image sequence, to filter out a set of candidate relocation sites from the gastroscopy image sequence, specifically includes: The coordinates of the mapping sites corresponding to each frame of the gastroscopy image sequence are arranged in the order of the frame index to form a spatiotemporal mapping site trajectory. The displacement vector between the coordinates of the mapping sites corresponding to two adjacent frames of gastroscopy images is extracted from the spatiotemporal mapping site trajectory to form a displacement vector sequence. The displacement vector sequence is subjected to sliding window mean filtering to obtain a smooth displacement vector sequence; Based on the smooth displacement vector sequence, the spatiotemporal mapping site trajectory is forward-predicted to generate the predicted site coordinates corresponding to the current frame of the gastroscopy image; A search window is constructed centered on the predicted site coordinates. Within the search window, all pixels in the current frame of the gastroscopy image are traversed in ascending order of distance. The first pixel located within the gastric tissue region is taken as a candidate relocation site. The set of all candidate repositioning sites in the current frame of the gastroscopy image is taken as the candidate repositioning site set.

5. The intelligent relocation method for endoscopic biopsy sites according to claim 4, characterized in that, The working process of the improved nearest neighbor search algorithm specifically includes: The displacement change rate between two adjacent frames is calculated based on the smoothed displacement vector sequence to obtain the displacement change rate sequence; Identify the locations of abrupt change frames where the displacement change rate exceeds a preset change rate threshold from the displacement change rate sequence, and mark the coordinates of the mapping site corresponding to the abrupt change frame location as an unstable mapping point; When the Euclidean distance between the predicted site coordinates and the unstable mapping point is less than a preset distance threshold, the radius of the search window is increased to twice the initial radius; When the Euclidean distance between the predicted site coordinates and the unstable mapping point is greater than or equal to a preset distance threshold, the radius of the search window is kept at the initial radius. Within the expanded search window or the initial search window, all pixels are traversed in ascending order of distance, skipping pixels that have been marked as contraindicated areas for biopsy, and the first pixel located within the gastric tissue region that has not been marked as a contraindicated area for biopsy is taken as a candidate relocation site.

6. The intelligent relocation method for gastroscopy biopsy sites according to claim 1, characterized in that, The steps of performing spatial clustering filtering on the candidate relocation site set and outputting the coordinates of the target relocation site specifically include: Map all candidate repositioning sites in the candidate repositioning site set to the pixel coordinate system of the current frame gastroscopy image to obtain the candidate point coordinate set; Randomly select an unvisited candidate point from the set of candidate point coordinates as the initial cluster center; Calculate the spatial distance between each un-clustered candidate point in the candidate point coordinate set and the initial cluster center, and classify the candidate points whose spatial distance is less than the preset cluster radius into the current cluster; Update the center point of the current cluster to the arithmetic mean center of the coordinates of all candidate points within the cluster, and repeat the inclusion operation until the current cluster no longer absorbs new candidate points; The current cluster is marked as a visited cluster, and the next initial cluster center is selected from the remaining unvisited candidate points until all candidate points have been visited. Calculate the cluster density value for each cluster, where the cluster density value is the ratio of the number of candidate points in the cluster to the spatial area occupied by the cluster. Select the cluster with the highest cluster density value, and use the center point of the cluster as the coordinates of the target relocation site.

7. The intelligent relocation method for gastroscopy biopsy sites according to claim 1, characterized in that, After outputting the coordinates of the target relocation site, the method also includes a confidence-weighted correction operation for different gastric regions, specifically including: Obtain the gastric anatomical structure labels in the gastric region segmentation mask, wherein the gastric anatomical structure labels include gastric fundus region labels, gastric body region labels, gastric antrum region labels, and cardia region labels; Preset biopsy confidence weight values ​​were assigned to each gastric anatomical structure label, with the highest biopsy confidence weight value corresponding to the gastric antrum region label, followed by the gastric body region label, and the lowest biopsy confidence weight values ​​corresponding to the gastric fundus region label and the cardia region label. Determine the gastric anatomical structure label to which the coordinates of the target relocation site belong in the gastric region segmentation mask, and obtain the biopsy confidence weight value corresponding to the gastric anatomical structure label as the site confidence weight; The historical number of successful biopsies for each original biopsy site is counted from the biopsy site history records, and the average number of successful biopsies for all original biopsy sites is calculated as a reference number of successful biopsies. The product of the site confidence weight and the number of reference successes is used as the weighted confidence score of the target relocation site coordinates. When the weighted confidence score is lower than a preset score threshold, the center point of the cluster with the second largest cluster density value is used as the corrected target relocation site coordinates.

8. The intelligent relocation method for gastroscopy biopsy sites according to claim 1, characterized in that, After outputting the target relocation site coordinates, the method also includes a site dynamic tracking operation based on respiratory motion compensation, specifically including: The area change sequence of the gastric region segmentation mask in multiple consecutive frames of gastroscopy images in the gastroscopy image sequence is acquired in real time. The area change sequence is subjected to frequency domain transformation processing to extract the main frequency component of the area change sequence, and the frequency value of the main frequency component is used as the patient's respiratory rate value. A respiratory motion displacement model is constructed based on the respiratory frequency value. The respiratory motion displacement model describes the functional relationship between the displacement of the stomach tissue and the phase angle during the respiratory cycle. Obtain the current phase angle relative to the start of the respiratory cycle at the current moment, substitute the current phase angle into the respiratory motion displacement model, and calculate the respiratory motion displacement vector at the current moment; Add the respiratory motion displacement vector to the target repositioning point coordinates to generate the dynamic repositioning point coordinates after respiratory compensation. The coordinates of the dynamically repositioned site are output to the gastroscopy navigation interface in real time for dynamic marking and display.

9. The intelligent relocation method for gastroscopy biopsy sites according to claim 8, characterized in that, Based on the respiratory frequency value, a respiratory motion displacement model is constructed. This model describes the functional relationship between the displacement of stomach tissue and the phase angle during the respiratory cycle. Specifically, the steps include: Optical flow field calculations are performed on the gastric region segmentation mask in multiple consecutive respiratory cycles in the gastroscopy image sequence to obtain the displacement trajectory of each pixel in the respiratory cycle; The displacement sequence of the geometric center point of the stomach region segmentation mask is extracted from the displacement trajectory and used as the overall displacement reference trajectory of the stomach. The overall displacement reference trajectory of the stomach is segmented and aligned according to the respiratory cycle to obtain multiple single-cycle displacement trajectory segments. The average displacement trajectory is obtained by arithmetically averaging the displacement values ​​of the multiple single-cycle displacement trajectory segments at the same phase angle. The average displacement trajectory is fitted into a Fourier series form, where the fundamental frequency of the Fourier series is equal to the respiratory frequency value, the constant term of the Fourier series represents the DC bias of the respiratory displacement, and the first harmonic coefficient and the second harmonic coefficient of the Fourier series represent the main displacement components of the respiratory motion. The Fourier series is used as the respiratory motion displacement model.

10. A smart repositioning system for endoscopic biopsy sites, characterized in that, The gastroscopy biopsy navigation system includes a processor and a memory. The memory is connected to the processor and is used to store programs, instructions, or code. The processor is used to run the programs, instructions, or code in the memory to implement the intelligent relocation method for gastroscopy biopsy sites as described in any one of claims 1 to 9.