A cervical cancer MRI multi-sequence image lesion automatic extraction method based on a MedSAM2 video segmentation base model

By standardizing the spatial alignment and sequence resolution of cervical cancer MRI data, and fine-tuning the MedSAM2 model, the issues of accuracy and privacy protection in cervical cancer MRI lesion segmentation were resolved, achieving efficient and accurate automatic lesion extraction.

CN122493044APending Publication Date: 2026-07-31HEILONGJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HEILONGJIANG UNIV
Filing Date
2026-04-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies for cervical cancer MRI multi-sequence lesion segmentation suffer from low segmentation accuracy, poor robustness, and inability to protect patient privacy in compliance with regulations, especially in cross-center, cross-device, and cross-sequence applications where their generalization is poor.

Method used

By acquiring and resampling MRI data to achieve spatial alignment between images and masks, desensitizing patient identifiers, and performing sequence resolution standardization, pseudo-video frame inputs are generated. MedSAM2 is used for model fine-tuning to output high-precision lesion segmentation results.

Benefits of technology

It achieves high-precision and reproducible automatic segmentation of cervical cancer lesions, reduces manual delineation time, ensures privacy protection, and provides scalable data adaptability and clinical applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122493044A_ABST
    Figure CN122493044A_ABST
Patent Text Reader

Abstract

This invention discloses an automatic lesion extraction method for cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model. Belonging to the field of medical image processing and AI-assisted diagnosis, it addresses the issues of low segmentation accuracy and robustness in cervical cancer lesion technology and the inability to compliantly protect patient privacy. The method includes: using the original image as a reference space and employing a nearest-neighbor interpolation spatial alignment method; specifying the most matching target space size according to the physical acquisition characteristics and imaging purpose of each sequence; synchronous bicubic interpolation of the image and mask; ensuring mask boundary fidelity; mapping the original patient folder name to a research ID for each sequence in lexicographical order; extracting continuous segments centered on the lesion; organizing them into pseudo-video frames according to physical location order using a frame sorting rule; and generating a bounding box prompt based on the bounding rectangle of each frame mask. This invention is applicable to the auxiliary diagnosis, staging assessment, treatment plan formulation, radiotherapy target delineation, and efficacy follow-up of cervical cancer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of medical image processing and artificial intelligence-assisted diagnosis, and in particular to an automatic segmentation method for cervical cancer lesion regions based on a visual foundation model in multi-sequence magnetic resonance imaging (MRI) images. Background Technology

[0002] Cervical cancer is the fourth most common malignant tumor among women worldwide. Early and accurate identification of the location and extent of lesions is crucial for developing individualized treatment plans and achieving precise radiotherapy, chemotherapy, and surgical planning. Magnetic resonance imaging (MRI) is the preferred imaging method for the clinical diagnosis and staging of cervical cancer due to its excellent soft tissue contrast. A complete cervical cancer MRI clinical examination typically includes multiple functional and structural sequences, including apparent diffusion coefficient mapping (ADC), diffusion-weighted imaging (DWI), multivariate T1-weighted imaging (such as tra, tra_F, tra_in, tra_opp, tra_W), and multidirectional T2-weighted imaging (tra, cor, sag), totaling approximately 10 sequences. Different sequences characterize lesion features from different dimensions, such as water molecule diffusion, fat distribution, and anatomical structure.

[0003] In clinical practice, the delineation of cervical cancer lesions still mainly relies on manual work by radiologists. Manual delineation has problems such as being time-consuming (usually 15-30 minutes per case), highly subjective, having poor consistency among physicians, and being difficult to carry out on a large scale, which seriously restricts the large-scale implementation of radiomics and artificial intelligence-assisted diagnosis.

[0004] In recent years, deep learning methods have made significant progress in the field of medical image segmentation. Convolutional neural network methods, represented by U-Net and its derivative models (U-Net++, Attention U-Net, nnU-Net, etc.), and Transformer / hybrid models, represented by Swin-UNet and TransUNet, have achieved high accuracy on various segmentation tasks. However, these methods generally suffer from the following shortcomings:

[0005] (1) It requires extensive labeling and training from scratch for each task, which is highly dependent on data and has limited accuracy in scenarios such as cervical cancer where clinical labels are scarce.

[0006] (2) It lacks zero-shot and promptable capabilities, and has poor generalization across centers, devices, and sequences;

[0007] (3) It was not specifically designed for the heterogeneity of multiple sequences in cervical cancer MRI, making it difficult to directly process clinically acquired heterogeneous image data.

[0008] Since 2023, visual foundational models, represented by the Segment Anything Model (SAM) and its video version SAM2, have provided a new paradigm for medical image segmentation thanks to their strong zero-shot segmentation capabilities obtained through pre-training on massive datasets. Its medical-adapted version, MedSAM2, introduces the memory attention mechanism of SAM2 into medical volume data processing, treating consecutive slices as video frames, thus demonstrating excellent performance on various general medical segmentation tasks.

[0009] However, directly applying MedSAM2 to lesion extraction from cervical cancer MRI multi-sequence images faces key unresolved issues in both engineering implementation and algorithm adaptation:

[0010] (a) There is a spatial misalignment between the clinical imaging data (.nii format) provided by the hospital and the segmentation annotations (.seg.nrrd format) drawn by radiologists in 3D Slicer. Furthermore, the patient folder name directly contains identifiable information and cannot be directly used for scientific research training. A standardized solution that combines annotation spatial alignment with patient identification desensitization is needed.

[0011] (b) The 10 sequences of cervical cancer MRI are highly heterogeneous in terms of spatial resolution, slice thickness, slice spacing, acquisition direction, file naming and metadata conventions. The sequence naming is not standardized under different devices and different acquisition protocols (the same functional sequence may be marked as tra, AX, axial or more complex combination names under different manufacturers). Directly feeding it to MedSAM2 will lead to input dimension mismatch or sequence semantic confusion.

[0012] (c) MedSAM2's native input interface requires continuous slices to be organized in the form of pseudo-video framesequence, and requires a matching bounding box or point prompt. Clinical annotations are provided in the .seg.nrrd format of 3D Slicer software, which has a significant format gap with the slice-level JPG image + NPY mask input required by MedSAM2;

[0013] (d) The 10 sequences showed significant differences in their expression of cervical cancer lesions. If all of them were input without screening, it would significantly increase the training and inference overhead and introduce redundant or even interfering signals, affecting the segmentation accuracy.

[0014] (e) MedSAM2 is pre-trained on general medical data. Its feature space is not optimized for the specific anatomical location and lesion texture (distinguishing between the cervix and the tumor, and the transition between the tumor and the surrounding endometrium / cervical stroma) of cervical cancer. Direct zero-shot inference makes it difficult to obtain segmentation accuracy that can be used for clinical assistance.

[0015] In summary, there is an urgent need for a complete method that can connect "clinical multi-sequence MRI raw data → MedSAM2 standardized input → precise extraction of cervical cancer lesions" to effectively utilize MedSAM2's pre-training priors while ensuring patient privacy and compliance, thereby achieving high-precision and reproducible automatic segmentation of cervical cancer lesions. Summary of the Invention

[0016] The purpose of this invention is to address the technical problems of low segmentation accuracy and robustness of existing cervical cancer lesion techniques and the inability to legally protect patient privacy. This invention provides an automatic extraction method for cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model.

[0017] The technical solution adopted by this invention to solve the above problems is: an automatic extraction method for cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model, the method comprising:

[0018] Step 1: Collect MRI data and lesion segmentation annotations of cervical cancer patients, resample the images and mask into the same geometric space, and obtain a standardized dataset with the images and segmentation mask space aligned and the patient identifiers desensitized and mapped.

[0019] Step 2: Perform sequence resolution standardization preprocessing on the normalized dataset obtained in Step 1. Specify the most matching target space size according to the physical acquisition characteristics and imaging purpose of each sequence to obtain slice-level images and slice-level masks for subsequent model training.

[0020] Step 3: Based on the slice-level image and slice-level mask obtained in Step 2, extract continuous segments centered on the lesion. Organize the extracted continuous slices into pseudo-video frame inputs required by MedSAM2 according to their physical position in the original volume data. Automatically generate bounding box prompts based on the bounding rectangle of each frame mask. Obtain the pseudo-video frame sequence and corresponding bounding box prompts that MedSAM2 can directly consume.

[0021] Step 4: Starting with the official pre-trained weights of MedSAM2, fine-tune the model on limited cervical cancer labeled data, and output the dedicated segmentation model weights for cervical cancer lesions.

[0022] Step 5: Postprocess the slice-level segmentation mask output by the model and calculate the quantitative indicators of clinical concern.

[0023] Furthermore, step 1 specifically includes:

[0024] Step 1.1: Raw Data Organization: The hospital provides data in two levels: patient and sequence. Each patient subdirectory contains the raw image .nii file generated from the same examination and the corresponding Segmentation_*.seg.nrrd segmentation file. The sequence set consists of 10 sequences: {ADC, DWI, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp, t1_tra_W, t2_tra, t2_cor, t2_sag}. Among them, ADC is the apparent diffusion coefficient map, DWI is magnetic resonance diffusion-weighted imaging, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp and t1_tra_W are multivariate T1-weighted imaging, and t2_tra, t2_cor and t2_sag are multi-directional T2-weighted imaging.

[0025] Step 1.2: Segmentation Label Space Alignment: The segmentation is resampled using the ResampleImageFilter provided by SimpleITK with the original image as the reference space. To avoid the label values ​​being corrupted by interpolation, the resampling interpolator uses nearest neighbor interpolation sitkNearestNeighbor and preserves the identity transformation. The resampled image and segmentation are exported in the same .nii.gz compressed format to form an aligned image-segmentation pair.

[0026] Step 1.3: Patient ID desensitization mapping: For each sequence, independently traverse all patient folders under that sequence, map the original patient IDs to the research IDs in lexicographical order, and write the mapping results of each sequence to the patient_folder_mapping_{sequence name}.txt file to form a one-to-one relationship between patient name and research ID;

[0027] Step 1.4: Reversible bidirectional mapping mechanism: The mapping table supports both forward and reverse queries from the original ID to the research ID, enabling modeling with anonymized research IDs during the research phase, and restoring the research IDs to the original folder names recognizable by the hospital side based on the reverse mapping table during the stage of sending the segmentation results back to the hospital.

[0028] Step 1.5: Data Storage: The output is reorganized into a two-level directory structure with the sequence name folder containing the patient study ID folder. Each patient directory contains a corresponding .nii.gz image and a .nii.gz segmentation mask file, forming a standardized dataset with consistent naming, spatial alignment, and direct access to subsequent preprocessing.

[0029] Further, step 2 includes:

[0030] Step 2.1: Loading NIfTI and slicing along the Z-axis: Load the .nii.gz image and corresponding .nii.gz mask for each patient separately. After passing the shape consistency check, extract the two-dimensional image and two-dimensional mask slice by slice along the Z-axis.

[0031] Step 2.2: Sequence-Specific Target Resolution Setting: Target spatial dimensions are set for each of the 10 sequences: The dimensions used for diffusion-type sequences ADC and DWI are matched to their lower native scan resolution; the dimensions used for T1-weighted subsequences t1_tra_F, t1_tra_W, t1_tra_in, and t1_tra_opp are matched to their medium-resolution Dixon-type reconstruction characteristics; the dimensions used for structural sequences t1_tra, t2_tra, and t2_sag are designed to preserve high-resolution structural details; the dimensions used for t2_cor strike a balance between coronal resolution and computational overhead. These resolution settings are applied in batches to the corresponding sequences using a lookup table.

[0032] Step 2.3: Bicubic Interpolation Unified Resize: For each slice of image and mask, apply bicubic interpolation to scale it to the target size corresponding to the sequence. During the resize stage, retain the sub-pixel level transition information at the lesion boundary, so that the floating-point interpolation result carries the soft transition intensity near the boundary. Then, round it to the nearest integer and truncate it to the effective range of uint8 [0, 255] to obtain the integer mask and obtain the boundary label.

[0033] Step 2.4: NaN and Inf numerical cleaning: Before normalization, perform np.nan_to_num cleaning on the image data to uniformly replace NaN, +Inf, and −Inf with 0;

[0034] Step 2.5: min-max 0-1 normalization: Perform min-max linear normalization independently on each slice to compress the values ​​to the [0,1] interval; if the maximum and minimum values ​​of a slice are equal, set them to zero directly;

[0035] Step 2.6: Slice-level disk saving: Multiply the normalized image by 255 to convert it to 8-bit grayscale, and save it in JPEG format as {slice index:04d}.jpg file; save the mask directly as uint8 type as {slice index:04d}.npy file; organize the output directory as a three-level directory of sequence name / image or mask / patient study ID, where / is the path separator within the folder, ensuring that the image and mask directories correspond completely one-to-one at the patient and slice levels;

[0036] Step 2.7: Slice Validity Statistics: For each slice, determine whether its mask contains non-zero foreground pixels. This will count the number of valid slices for each patient, providing a basis for sampling based on valid slices in the subsequent training phase and avoiding diluting the training signal with a large number of background slices.

[0037] Furthermore, step 3 includes:

[0038] Step 3.1: Core sequence screening: Determine the core sequence automatically extracted from cervical cancer lesions;

[0039] Step 3.2: Extraction of slices of interest: Based on the slice-level mask for each patient, determine the slice index interval containing the lesion according to the number of effective slices, and extend this interval upwards and downwards as needed as spatial context redundancy, and extract continuous slice segments centered on the lesion.

[0040] Step 3.3: Pseudo-video frame serialization: Organize the continuous slices centered on the lesion into pseudo-video frame inputs according to their physical location in the original volume data, with each slice corresponding to one frame in the pseudo-video.

[0041] Step 3.4: Automatic generation of bounding box prompt: Based on the binary mask corresponding to each slice, calculate the bounding rectangle of its foreground pixels as the bounding box prompt of that slice;

[0042] Step 3.5: Auxiliary Sequence Fusion Interface: Reserves an extension interface for other functional sequences as auxiliary inputs. Under the premise of the core sequence being dominant, it allows the introduction of supplementary information through multi-channel splicing or feature-level fusion, providing a unified data access protocol for subsequent model capability expansion for complex lesion scenarios.

[0043] Furthermore, the core sequence in step 3.1 is the sagittal T2-weighted sequence t2_sag.

[0044] Furthermore, step 4 includes:

[0045] Step 4.1: Model initialization: Load the pre-trained weights released by MedSAM2, retaining the complete structure of its Image Encoder, Memory Attention module, Memory Encoder and Mask Decoder;

[0046] Step 4.2: Training data organization: Using the pseudo video frame sequence and corresponding bbox prompt obtained in Step 3 as training samples, the training, validation and test sets are divided by patient to ensure that the same patient's slice does not cross sets and to avoid data leakage;

[0047] Step 4.3: Fine-tuning strategy configuration: Freeze some backbone parameters and only fine-tune the parameters of the prompt encoder and mask decoder to effectively prevent overfitting under limited annotation scale;

[0048] Step 4.4: Loss function design: A weighted combination of Dice Loss and Binary Cross-Entropy Loss is used as the overall optimization objective to balance the region overlap index and pixel-level classification accuracy;

[0049] Step 4.5: Data Augmentation and Regularization: During the training phase, data augmentation is performed on the pseudo-video frame sequence. The data augmentation includes random flipping, rotation, intensity perturbation, and slight bbox jitter to simulate the uncertainty of clinical collection and sketching.

[0050] Step 4.6: Training and Model Selection: Based on the Dice metric on the validation set, implement an early stopping strategy and select the model that performs best on the validation set as the dedicated segmentation model for cervical cancer lesions.

[0051] Furthermore, step 5 includes:

[0052] Step 5.1: Restoration of pseudo-video frames to 3D mask: Reassemble each frame mask output by MedSAM2 into a 3D mask volume according to the physical position order of the slices in Step 3, and map it back to the original space before preprocessing in Step 2 through the recorded coordinates.

[0053] Step 5.2: Morphological post-processing: Perform small connected component culling and morphological opening and closing operations on the 3D mask to eliminate isolated scattered points and edge spikes;

[0054] Step 5.3: Quantitative evaluation: Calculate the Dice similarity coefficients DSC, IoU, HD95, and ASD on the test set, with Dice being the primary evaluation metric;

[0055] Step 5.4: Output Results: Output the final mask in NIfTI format, and provide a visual overlay of each slice for user review.

[0056] Secondly, the present invention provides an automatic extraction system for cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation model. The system has program modules corresponding to the steps of the automatic extraction method for cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation model described above. When running, the system executes the steps in the automatic extraction method for cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation model.

[0057] Thirdly, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, it performs the steps of the method for automatic extraction of cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation basic model as described above.

[0058] Fourthly, the present invention provides a computer-readable storage medium for storing a computer program that executes the above-described method for automatic extraction of cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation model.

[0059] The beneficial effects of this invention are:

[0060] (1) Significantly improved end-to-end automation: This invention connects the entire process from clinical 3D Slicer annotation data (.nii image + .seg.nrrd segmentation) to the final three-dimensional lesion mask. Except for the parameter configuration during the initial deployment, the entire process does not require radiologists to manually click or interact with each slice. Compared with the current clinical approach that relies on manual delineation (average 15-30 minutes per case) or interactive clicking with SAM / SAM2, the manual time for delineating cervical cancer lesions per case is reduced to tens of seconds.

[0061] (2) The segmentation accuracy reaches a clinically acceptable level: On the independent test set based on the private cervical cancer MRI dataset of the Sixth Affiliated Hospital of China Medical University, the method of the present invention can achieve a Dice similarity coefficient (DSC) of about 88.24% using only the t2_sag single core sequence, which is significantly better than the result of zero-shot inference using MedSAM2 directly, and also better than U-Net-like methods trained from scratch under the same annotation scale;

[0062] (3) Balancing desensitization compliance and result feedback: Through the reversible bidirectional mapping mechanism of Module 1, the research stage uses the desensitized research ID for modeling, and the result feedback stage can restore the research ID to the original folder name of the hospital based on the reverse mapping table, ensuring the traceability of research results to the clinical side while meeting medical ethics compliance.

[0063] (4) Strong data adaptability and scalability: Through the unified naming and preprocessing interface design of 10 sequences, this invention can be used for efficient inference of a single t2_sag core sequence, and also reserves an expansion channel for fusion of functional sequences such as ADC / DWI, which facilitates the subsequent expansion of model capabilities for complex lesion scenarios.

[0064] (5) User-friendly for downstream clinical tasks: The high-quality lesion mask output by this invention can be directly used as a region of interest (ROI) extraction module for downstream radiomics analysis, lymph node metastasis (LNM) and vascular invasion (LVSI) prediction, laying the segmentation foundation for the whole process of cervical cancer precision diagnosis technology route.

[0065] (6) The prior of the basic model pre-training is effectively utilized: Compared with the scheme of training a dedicated segmentation network from scratch under limited clinical annotations, the present invention makes full use of the general visual representation learned by MedSAM2 on ultra-large-scale data through efficient parameter fine-tuning, and obtains higher segmentation accuracy and stronger generalization potential under the same annotation scale.

[0066] In terms of quantitative metrics, this invention achieved a Dice coefficient of 88.24% on the independent test set provided by the Sixth Affiliated Hospital of China Medical University. In comparison, existing U-Net-like methods typically achieve a Dice coefficient of 80%-85% under the same annotation scale. Although MedSAM2 zero-shot inference outperforms U-Net-like methods, it is still lower than the 88.24% of the method in this invention, which fully verifies the technical effectiveness of this invention in further releasing the potential of the basic model through efficient parameter fine-tuning.

[0067] This invention adapts the MedSAM2 basic model, which is designed for general medical image and video segmentation tasks, to the specific anatomical and pathological scenario of cervical cancer. It can output lesion region segmentation results end-to-end from multiple sequence MRI raw data acquired clinically, and is suitable for auxiliary diagnosis, staging assessment, treatment plan formulation, radiotherapy target delineation and efficacy follow-up of cervical cancer. Attached Figure Description

[0068] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0069] Figure 1 This is an overall flowchart of the method of the present invention;

[0070] Figure 2 A detailed flowchart for multi-sequence data acquisition and normalization preprocessing;

[0071] Figure 3 A schematic diagram of core sequence selection and pseudo-video frame serialization;

[0072] Figure 4 A schematic diagram of the MedSAM2-based cervical cancer lesion segmentation network adaptation;

[0073] Figure 5 Comparison of qualitative results for MRI segmentation of cervical cancer lesions;

[0074] Figure 6 This is a bar chart showing the quantitative indicators of the method of the present invention on the training and testing sets of a cervical cancer dataset. Detailed Implementation

[0075] The specific implementation method of this embodiment, which is an automatic extraction method for cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model, includes the following: its overall processing flow consists of the following five interconnected and functionally decoupled modules: Module 1 is a multi-sequence MRI data acquisition and annotation standardization module; Module 2 is a sequence-specific resolution standardization preprocessing module; Module 3 is a core sequence screening and pseudo-video frame serialization module; Module 4 is a MedSAM2-based cervical cancer lesion segmentation adaptation and training module; and Module 5 is a segmentation result post-processing and evaluation module. The overall process is as follows: Figure 1 As shown, this illustrates the complete processing flow from the 3D Slicer clinical annotation data (.nii images + .seg.nrrd segmentation) provided by the hospital, sequentially through Module 1 (multi-sequence data acquisition and annotation standardization), Module 2 (sequence-specific resolution standardization preprocessing), Module 3 (core sequence screening and pseudo-video frame serialization), Module 4 (cervical cancer lesion segmentation adaptation and training based on MedSAM2), and Module 5 (segmentation result postprocessing and evaluation) to outputting a three-dimensional lesion mask and quantitative indicators.

[0076] The specific processing steps for each module will be explained below.

[0077] 3.2.1 Module 1: Standardization of Multi-Sequence MRI Data Acquisition and Annotation

[0078] like Figure 2 The diagram shows a detailed flowchart of the multi-sequence data acquisition and annotation standardization process. It illustrates the process of starting from the .seg.nrrd segmented file generated by the 3D Slicer, using the original .nii image as the reference space, performing resampling using nearest neighbor interpolation, and uniformly exporting to the .nii.gz format. It also shows the bidirectional mapping mechanism of forward mapping and reverse restoration according to lexicographical order of "original patient folder name → research ID (in the form of img00001)," and the final organization of the two-level directory of "sequence / patient research ID."

[0079] This module takes as input MRI data of cervical cancer patients provided by the hospital (stored in NIfTI format) and lesion segmentation annotations drawn by radiologists in 3D Slicer software (stored in .seg.nrrd format). The output is a normalized dataset where the images and segments are aligned in the same geometric space, and patient identifiers have been anonymized and mapped. The specific processing procedure is as follows:

[0080] (1) Organization of raw data: The hospital provides data in two levels of "sequence-patient". Each patient subdirectory contains the raw image .nii file generated from the same examination and the corresponding Segmentation_*.seg.nrrd segmentation file. The sequence set is {ADC, DWI, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp, t1_tra_W, t2_tra, t2_cor, t2_sag}, a total of 10 sequences. Among them, ADC is the apparent diffusion coefficient map, DWI is magnetic resonance diffusion-weighted imaging (DWI), t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp and t1_tra_W are multivariate T1-weighted imaging, and t2_tra, t2_cor and t2_sag are multi-directional T2-weighted imaging.

[0081] (2) Alignment of segmentation label space: Since the .seg.nrrd segment generated by 3D Slicer may not be completely consistent with the original image in terms of size, spacing, and origin, this module uses the ResampleImageFilter provided by SimpleITK to resample the segmentation with the original image as the reference space; in order to avoid the label values ​​being destroyed by interpolation, the resampling interpolator strictly adopts nearest neighbor interpolation (sitkNearestNeighbor) and retains the identity transformation; the resampled image and segmentation are uniformly exported as .nii.gz compressed format to form an aligned "image-segmentation" pair;

[0082] (3) Patient ID desensitization mapping: For each sequence, all patient folders under that sequence are traversed independently, and the original patient IDs are mapped to research IDs in the form of img00001, img00002, ... in lexicographical order. The mapping results of each sequence are written separately into the patient_folder_mapping_{sequence name}.txt file to form a one-to-one relationship of "sequence-mapping table".

[0083] (4) Reversible bidirectional mapping mechanism: The above mapping table supports both forward (original ID → research ID) and reverse (research ID → original ID) queries, which allows modeling to be performed using the desensitized research ID during the research phase, and the research ID to be restored to the original folder name that can be recognized by the hospital side based on the reverse mapping table during the stage of sending the segmentation results back to the hospital, thus resolving the contradiction between desensitization on the research side and traceability of results on the hospital side.

[0084] (5) Data storage: The output is reorganized according to the two-level directory structure of "sequence name / patient study ID". Each patient directory saves a one-to-one corresponding .nii.gz image and .nii.gz segmentation file, forming a standardized dataset with naming conventions, aligned annotation space, and direct access to subsequent preprocessing.

[0085] The key focus of this module is to integrate the 3D Slicer clinical annotation workflow (.seg.nrrd segmentation files) and the deep learning research workflow (.nii.gz aligned format) into the same batch pipeline. The strategy of using the original image as the reference space and strictly employing nearest neighbor interpolation to resample the segmentation ensures the semantic integrity of the lesion boundary labels. The reversible bidirectional mapping mechanism ensures a balance between desensitization compliance and the reproducibility of research results.

[0086] 3.2.2 Module Two: Normalization Preprocessing at Sequence Resolution Specific

[0087] This module takes as input the aligned "image-segmentation" pairs (.nii.gz format) output from Module 1, and outputs slice-level images (JPG format) and slice-level masks (NPY format) that can be directly used by subsequent models. The core design idea of ​​this module is a "sequence-specific resolution strategy," meaning that different MRI sequences have significantly different native resolutions due to their different physical acquisition characteristics and imaging purposes. This invention assigns the most suitable target spatial size to each type of sequence, balancing information fidelity and computational cost. The specific processing procedure is as follows:

[0088] (1) NIfTI loading and Z-axis slicing: Load the .nii.gz image and the corresponding .nii.gz mask for each patient separately. After the shape consistency check is passed, extract the two-dimensional image and two-dimensional mask slice by slice along the Z-axis;

[0089] (2) Sequence-specific target resolution settings: Target spatial dimensions were set for each of the 10 sequences—224×224 for diffusion-type sequences ADC and DWI (matching their lower native scan resolution); 320×320 for T1-weighted subsequences t1_tra_F, t1_tra_W, t1_tra_in, and t1_tra_opp (matching their medium-resolution Dixon-type reconstruction characteristics); 640×640 for structural sequences t1_tra, t2_tra, and t2_sag (fully preserving high-resolution structural details); and 512×512 for t2_cor (balancing coronal resolution and computational overhead). The above resolution strategies were applied in batches to the corresponding sequences using a lookup table.

[0090] (3) Bicubic Interpolation Unified Resize: Bicubic interpolation is applied to both the image and the mask of each slice to resize to the target size corresponding to the sequence. This invention intentionally uses bicubic interpolation for the mask as well. The purpose is to preserve the sub-pixel level transition information at the lesion boundary during the resize stage, so that the floating-point interpolation result carries the soft transition intensity near the boundary. Then, the mask is rounded to the nearest integer and truncated to the effective range of uint8 [0, 255] to obtain an integer mask. This results in a boundary label that is smoother and closer to the subjective intention of manual drawing than the nearest neighbor result of hard discretization.

[0091] (4) NaN and Inf numerical cleaning: Considering that the original floating-point data of MRI may contain NaN or infinite values ​​(especially computational sequences such as ADC), np.nan_to_num cleaning is performed on the image data before normalization to uniformly replace NaN, +Inf, and −Inf with 0;

[0092] (5) min-max 0-1 normalization: In view of the fact that MRI signal intensity has no absolute physical meaning and the dynamic range of different devices / sequences / slices is significantly different, min-max linear normalization is performed independently for each slice to compress the value to the [0,1] interval; if the maximum value and the minimum value of the slice are equal (extreme cases such as all-zero slices), the value is directly set to zero.

[0093] (6) Slice-level disk saving: Multiply the normalized image by 255 to convert it to 8-bit grayscale, and save it in JPEG format (quality 95) as {slice index:04d}.jpg file; the mask is saved directly in uint8 type as {slice index:04d}.npy file; the output directory is organized into a three-level structure of "sequence name / image or mask / patient study ID / slice file" to ensure that the image and mask directories correspond completely one-to-one at the patient and slice levels;

[0094] (7) Slice validity statistics: For each slice, determine whether its mask contains non-zero foreground pixels, and count the "number of effective slices" for each patient. This provides a basis for sampling based on effective slices in the subsequent training stage, and avoids diluting the training signal with a large number of background slices.

[0095] The focus of this module is to propose and implement a "sequence-specific resolution strategy," which no longer applies a uniform resolution to all MRI sequences. Instead, it specifies the most suitable target spatial size (ADC / DWI=224, T1 variant ∈ {320, 640}, T2 direction ∈ {512, 640}) based on the physical acquisition characteristics and imaging purpose of each sequence. This effectively controls the redundant computational overhead of low-resolution functional sequences while ensuring the fidelity of information in high-resolution structural sequences.

[0096] 3.2.3 Module 3: Core Sequence Selection and Pseudo-Video Frame Serialization

[0097] like Figure 3 As shown, Figure 3 : A schematic diagram of core sequence selection and pseudo-video frame serialization. It shows the spatial representation of 10 sequences (ADC, DWI, five T1 variants, and three T2 directions) and their respective target resolutions (ADC / DWI=224, T1 variant ∈ {320, 640}, T2 direction ∈ {512, 640}), with t2_sag selected as the core sequence. Further, it illustrates the correspondence between continuous slice extraction centered on the lesion and MedSAM2 pseudo-video frame serialization, as well as the process of automatically generating a bounding box prompt based on the slice mask.

[0098] This module serves as a crucial bridge connecting clinical multi-sequence MRI data to the MedSAM2 pseudo-video input interface. The input is the slice-level image and mask output from module two, and the output is a pseudo-video frame sequence and corresponding bounding box prompt that MedSAM2 can directly consume. The specific processing procedure is as follows:

[0099] (1) Core sequence selection: Taking into account factors such as the clarity of anatomical structures, the feasibility of physician delineation, and consistency with the imaging evidence used for clinical staging of cervical cancer, and after joint evaluation with the clinical expert team, t2_sag (sagittal T2-weighted sequence) was determined as the core sequence for automatic extraction of cervical cancer lesions. t2_sag can completely present the cervix, uterine body, vagina and bladder / rectum interface, and expresses the anatomical boundaries of cervical cancer lesions most clearly. Moreover, this sequence is used most frequently in clinical staging (FIGO) work.

[0100] (2) Extraction of slices of interest: Based on the slice-level mask of each patient, the slice index interval containing the lesion is determined according to the statistical results of the "number of effective slices" output by module 2. The interval is extended upward and downward as needed as spatial context redundancy, and continuous slices "centered on the lesion" are extracted.

[0101] (3) Pseudo-video frame serialization: The extracted continuous slices are organized according to their physical position in the original volume data into pseudo-video frame inputs required by MedSAM2, with each slice corresponding to one frame in the pseudo-video. Compared with the scheme of feeding all slices as independent 2D images into the segmentation model, this design enables the memory attention module built into MedSAM2 to propagate contextual information between adjacent slices. By utilizing the prior spatial continuity of cervical cancer lesions between adjacent slices, the temporal consistency and overall integrity of lesion boundaries in the slice direction are significantly improved.

[0102] (4) Automatic generation of bbox prompt: Based on the binary mask corresponding to each slice, the bounding rectangle of its foreground pixels is automatically calculated as the bounding box prompt (i.e. bbox prompt) of the slice, replacing the prompt acquisition method that MedSAM2 originally requires interactive clicking, so that the entire inference process does not require manual intervention for each slice.

[0103] (5) Auxiliary sequence fusion interface: Reserve functional sequences such as ADC and DWI as extended interfaces for auxiliary input. Under the premise that the core sequence t2_sag is dominant, supplementary information can be introduced by multi-channel splicing or feature-level fusion, providing a unified data access protocol for the subsequent expansion of model capabilities for complex lesion scenarios.

[0104] The focus of this module is to establish a one-to-one mapping between clinical continuous slice data of cervical cancer MRI and MedSAM2's native pseudo-video frame interface, enabling MedSAM2's built-in memory attention mechanism to propagate contextual information between adjacent slices and fully utilize the prior spatial continuity of cervical cancer lesions in the slice direction; and through an automatic bbox prompt generation mechanism based on the slice-level mask bounding rectangle, the entire inference process does not require radiologists to manually click on each slice, realizing MedSAM2's zero-interaction end-to-end automatic segmentation capability in cervical cancer scenarios.

[0105] 3.2.4 Module Four: Cervical Cancer Lesion Segmentation Adaptation and Training Based on MedSAM2

[0106] like Figure 4 The diagram shows the adaptation of the cervical cancer lesion segmentation network based on MedSAM2 (single-frame data stream + cross-frame memory loop). It illustrates the structure of the MedSAM2 image encoder, memory attention module, memory encoder, mask decoder, and memory bank. The memory bank, as a cross-frame memory, is stored between adjacent pseudo-video frames, forming a propagation loop of "reading t−1 memory → generating t segmentation → writing t memory". It also shows the partitioning of freezing (Image Encoder, Memory Attention, Memory Encoder, Memory Bank) and efficient parameter fine-tuning (Prompt Encoder, Mask Decoder) in this invention, as well as the input path for automatically generating the bbox prompt based on the bounding rectangle of the slice mask.

[0107] This module starts with the official pre-trained weights of MedSAM2 and performs model fine-tuning on limited cervical cancer labeled data, outputting segmentation model weights specifically for cervical cancer lesions. MedSAM2 has been pre-trained on tens of thousands to hundreds of thousands of general medical images, resulting in pre-trained weights that carry general medical image segmentation priors. Based on these pre-trained weights, this module loads them and continues training on the cervical cancer MRI t2_sag sequence dataset with a small learning rate. This allows some parameters in the model weights (the specific range of which is specified by the subsequent fine-tuning strategy) to adapt to the specific texture and boundary patterns of cervical cancer lesions while retaining the general pre-training priors. This process is the fine-tuning described in this invention. The specific processing steps are as follows:

[0108] (1) Model initialization: Load the pre-trained weights released by MedSAM2 and retain the complete structure of its image encoder, memory attention module, memory encoder and mask decoder;

[0109] (2) Training data organization: The pseudo video frame sequence output by module 3 and the automatically generated prompt are used as training samples. The training / validation / test sets are divided by patient to ensure that the slices of the same patient do not cross sets and to avoid data leakage.

[0110] (3) Fine-tuning strategy configuration: adopt an efficient fine-tuning strategy of freezing most backbone parameters and only fine-tuning the parameters of key layers of prompt encoder and maskdecoder to effectively prevent overfitting under limited annotation scale;

[0111] (4) Loss function design: The weighted combination of Dice Loss and Binary Cross-Entropy Loss is used as the overall optimization objective to balance the region overlap index and pixel-level classification accuracy; the loss function used can be: Loss total = 0.5 * Dice Loss + 0.5 * Binary Cross-Entropy Loss;

[0112] (5) Data augmentation and regularization: During the training phase, random flipping, rotation, intensity perturbation, and slight bbox jitter are applied to the pseudo-video frame sequence to simulate the uncertainty of clinical collection and sketching, thereby improving the robustness of the model.

[0113] (6) Training and model selection: Based on the Dice metric of the validation set, an early stopping strategy is implemented, and the model that performs best on the validation set is selected as the final release model.

[0114] The focus of this module is to achieve effective domain adaptation of MedSAM2 on cervical cancer clinical data with strictly limited annotation scale using a combination strategy of "core sequence-driven + automatic prompt + efficient parameter fine-tuning", thus fully leveraging the pre-training prior of the basic model.

[0115] 3.2.5 Module Five: Post-processing and Evaluation of Segmentation Results

[0116] This module post-processes the slice-level segmentation mask output by the model and calculates clinically relevant quantitative indicators. The specific processing procedure is as follows:

[0117] (1) Pseudo-video frame → 3D mask restoration: Each frame mask output by MedSAM2 is reassembled into a 3D mask body according to the physical position order of the slices recorded in Module 3, and then mapped back to the original space before preprocessing in Module 2 through the recorded coordinates.

[0118] (2) Morphological post-processing: Perform small connected component removal, morphological opening and closing operations on the 3D mask to eliminate isolated scattered points and edge spikes;

[0119] (3) Quantitative evaluation: Calculate segmentation metrics such as Dice similarity coefficient (DSC), IoU, HD95 and ASD on the test set, with Dice being the primary evaluation metric;

[0120] (4) Output of results: The final mask will be output in NIfTI format, and a visual overlay of each slice will be provided for clinicians to review.

[0121] This implementation provides: (1) a label space alignment method that uses the original image as the reference space, strictly adopts nearest neighbor interpolation to resample the .seg.nrrd format segment generated by 3DSlicer software and uniformly converts it to .nii.gz format, which solves the format gap between clinical labeling workflow and deep learning research workflow, and ensures the semantic integrity of the label of lesion boundary;

[0122] (2) A "sequence-specific resolution preprocessing strategy" for cervical cancer MRI 10 sequences, that is, specifying the most matching target spatial size (ADC / DWI=224×224, T1 weighted subsequence ∈{320×320, 640×640}, T2 weighted direction ∈{512×512, 640×640}) according to the physical acquisition characteristics and imaging purpose of each sequence, and applying it in batches by looking up a table; and including a matching "image-mask synchronous bicubic interpolation + mask rounding" boundary fidelity resize method;

[0123] (3) A reversible bidirectional patient identifier mapping mechanism that independently maps the original patient folder name to the research ID in the form of img00001 for each sequence in lexicographical order, and simultaneously supports the query mode of reverting the original hospital folder name from the research ID, thus resolving the contradiction between the research side's desensitization compliance and the hospital side's research results being able to be transmitted back.

[0124] (4) Using t2_sag as the preferred strategy for automatically extracting the core sequence of cervical cancer lesions, and designing an extended interface that retains the other 9 sequences as auxiliary inputs under the guidance of the core sequence;

[0125] (5) A MedSAM2 pseudo video frame serialization method based on slice-level mask, including a continuous segment extraction strategy centered on lesions, a frame sorting rule that organizes pseudo video frames according to physical location order, and a zero-interaction reasoning scheme that automatically generates bounding box prompts based on the bounding rectangle of each frame mask, so that the memory attention mechanism built into MedSAM2 can propagate context information between adjacent slices.

[0126] (6) An efficient fine-tuning strategy for MedSAM2 parameters for cervical cancer lesions, including the definition of the pre-training weight freezing range, the loss function form of the weighted combination of Dice and BCE, the patient-level dataset partitioning method, and the overall architecture of the end-to-end automatic cervical cancer segmentation pipeline consisting of the above five core technologies: "3D Slicer annotation → sequence-specific preprocessing → bidirectional mapping desensitization → core sequence MedSAM2 pseudo-video frame adaptation".

[0127] Example:

[0128] The present invention will be further described below with reference to a specific embodiment. This embodiment is based on cervical cancer MRI clinical data provided by the Sixth Affiliated Hospital of China Medical University and is used to verify the technical feasibility and segmentation performance of the method of the present invention.

[0129] 6.1 Data Sources and Scale

[0130] The data used in this embodiment comes from cervical cancer MRI multi-sequence images collected by the Sixth Affiliated Hospital of China Medical University in collaboration with our research group from March to November 2025. Each patient's complete examination included 10 sequences: ADC, DWI, T1 (tra, tra_F, tra_in, tra_opp, tra_W), and T2 (tra, cor, sag). Lesions were delineated slice by slice in 3D Slicer software by senior radiologists, exported as Segmentation_*.seg.nrrd segmentation files, and jointly reviewed by a team of medical imaging experts to ensure annotation quality. All data underwent spatial alignment and patient identification desensitization mapping via module one of this invention before entering the research modeling process.

[0131] 6.2 Experimental Environment

[0132] Hardware environment: NVIDIA RTX 4090 GPU (24GB VRAM), Intel Xeon-level CPU, 64GB or more RAM. Software environment: Ubuntu 20.04 / Windows 11, Python 3.10, PyTorch 2.4.0, CUDA 12.8, MedSAM2 official code repository and pre-trained weights, SimpleITK for format unification and spatial resampling from .seg.nrrd to .nii.gz, nibabel for slicing and reading .nii.gz, Pillow (PIL) for bicubic interpolation resizing and JPEG encoding, NumPy for mask array storage.

[0133] 6.3 Specific Implementation Process

[0134] The specific implementation process of this embodiment strictly follows the five modules described in Section 3.2 of the invention, and the key parameter configurations are as follows:

[0135] (1) In Module 1, using the original .nii image as the reference space, SimpleITK's ResampleImageFilter, in conjunction with the nearest neighbor interpolator (sitkNearestNeighbor), is used to resample the Segmentation_*.seg.nrrd segmentation file for each patient, and the image and the resampled segment are exported in the same .nii.gz format; then, for each sequence {ADC, DWI, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp, t1_tra_W, t2_tra, t2_cor, t2_sag}, the original patient folder name is independently mapped to the research ID in the form img00001, img00002, ... in lexicographical order, and this mapping is written to the patient_folder_mapping_{sequence name}.txt file to support bidirectional restoration query between the research ID and the original ID in the future;

[0136] (2) In Module 2, the table is looked up according to the "sequence-specific resolution strategy". The target size of ADC / DWI is set to 224×224, t1_tra_F / t1_tra_W / t1_tra_in / t1_tra_opp is set to 320×320, t2_cor is set to 512×512, and t1_tra / t2_tra / t2_sag is set to 640×640. The .nii.gz image and .nii.gz mask of each patient are loaded with nibabel and two-dimensional slices are extracted slice by slice along the Z-axis. The images and masks are uniformly resized to the target size corresponding to each sequence using the bicubic interpolation (BICUBIC) of PIL. The interpolation result of the mask is rounded and clipped to the uint8 range of [0, 255]. The images are first cleaned with numpy.nan_to_num to remove NaN / Inf, and then min-max is performed on each slice. 0-1 normalization; finally, the normalized image is multiplied by 255 to convert it to 8-bit grayscale and saved as a JPEG (quality 95) as {slice index:04d}.jpg, and the mask is saved as a uint8 type as {slice index:04d}.npy; the output directory is organized as a three-level structure of "sequence name / image or mask / patient study ID / slice file";

[0137] (3) In Module 3, t2_sag is determined as the core sequence; based on the spatial envelope of the three-dimensional lesion mask, 5 slices are extended in the upward and downward directions to extract continuous segments; the extracted slice sequences are sorted and organized into MedSAM2 pseudo-video frame input according to the physical position of the sagittal sag; each frame automatically generates a bbox prompt according to the bounding rectangle of its slice mask.

[0138] (4) In Module 4, the official pre-trained weights of MedSAM2 are loaded, the backbone parameters of the Image Encoder are frozen, and the parameters of the key layers of the prompt encoder and mask decoder are finely tuned efficiently. The AdamW optimizer is used with an initial learning rate of 1e-4, which is then adjusted to 1e-6 by cosine annealing. The batch size is set to 4, and the training lasts for 200 epochs. The loss function is a weighted combination of DiceLoss and BCE Loss. Data augmentation includes random flipping, ±15° rotation, 0.8×–1.2× random scaling, and ±10% intensity perturbation. The training / validation / test sets are divided into patient-level sets in a ratio of 8:1:1, and a fixed random seed is used to ensure reproducibility.

[0139] (5) In Module 5, small connected component removal and morphological opening and closing operations are performed on the output mask to calculate indicators such as Dice, IoU, sensitivity, and specificity, and a visual overlay map is generated for all cases in the test set for clinical review.

[0140] 6.4 Experimental Results

[0141] Under the above experimental settings, the method of the present invention achieved a Dice coefficient of 88.24% on the independent test set, which is significantly better than the MedSAM2 zero-sample inference baseline. From the qualitative results, the lesion boundary output by the method of the present invention is smooth and continuous, which is highly consistent with the spatial morphology of the gold standard delineation of radiologists, and can also maintain reasonable segmentation results in difficult cases with blurred lesion boundaries.

[0142] Figure 5 The image shows a comparison of the qualitative results of MRI lesion segmentation for cervical cancer. A typical validation case was selected. From left to right, the original t2_sag image, the predicted segmentation result of the method of the present invention on this image (Dice=0.9653), and the gold standard drawn by the radiologist are shown. It can be seen that the lesion area output by the method of the present invention is highly consistent with the gold standard in terms of spatial morphology. Figure 6 The bar charts show the quantitative indicators of the method of the present invention on the training and test sets of the cervical cancer dataset. (a) shows the performance of the method of the present invention on the two regional overlap indicators, Dice and IoU; (b) shows the performance of the method of the present invention on the two boundary distance indicators, HD95 and ASD.

[0143] This embodiment verifies that the overall technical solution proposed in this invention, which combines "standardized preprocessing of multiple sequence annotations + t2_sag core sequence + pseudo-video frame serialization + efficient fine-tuning of MedSAM2 parameters," can achieve clinically usable automatic segmentation accuracy for cervical cancer lesions under limited clinical annotation scale. This provides high-quality lesion ROI input for subsequent downstream diagnostic tasks such as LNM and LVSI, laying the core technical foundation for the segmentation stage in the intelligent implementation of the entire process of cervical cancer precision diagnosis.

[0144] The technical problems that this invention can solve include:

[0145] (1) How to standardize and batch convert the cervical cancer MRI image data (.nii format) and 3DSlicer annotation (.seg.nrrd format) containing 10 sequences (ADC, DWI, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp, t1_tra_W, t2_tra, t2_cor, t2_sag) provided by the hospital into an input format that MedSAM2 can directly accept, and complete the annotation space alignment and patient identification desensitization in the process;

[0146] (2) How to determine the most suitable core sequence for automatic extraction of cervical cancer lesions from 10 candidate sequences, and establish an input organization strategy of "core sequence as the main component and other sequences as auxiliary components" to reduce the computational cost of the model while maintaining or improving the segmentation accuracy;

[0147] (3) How to convert the .seg.nrrd format clinical annotations generated by 3D Slicer into the slice-level mask and pseudo-video frame alignment format required by MedSAM2, so as to realize the automatic generation of bbox prompts and replace the interactive prompt method that relies on manual clicks;

[0148] (4) How to effectively adapt MedSAM2 to cervical cancer lesions under limited clinical annotation samples, so that its feature space is sensitive to the typical texture and boundary patterns of cervical cancer lesions, and finally achieve clinically acceptable segmentation accuracy on the cervical cancer test set.

Claims

1. A method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model, characterized in that, The method includes: Step 1: Collect MRI data and lesion segmentation annotations of cervical cancer patients, resample the images and mask into the same geometric space, and obtain a standardized dataset with the images and segmentation mask space aligned and the patient identifiers desensitized and mapped. Step 2: Perform sequence resolution standardization preprocessing on the normalized dataset obtained in Step 1. Specify the most matching target space size according to the physical acquisition characteristics and imaging purpose of each sequence to obtain slice-level images and slice-level masks for subsequent model training. Step 3: Based on the slice-level image and slice-level mask obtained in Step 2, extract continuous segments centered on the lesion. Organize the extracted continuous slices into pseudo-video frame inputs required by MedSAM2 according to their physical position in the original volume data. Automatically generate bounding box prompts based on the bounding rectangle of each frame mask. Obtain the pseudo-video frame sequence and corresponding bounding box prompts that MedSAM2 can directly consume. Step 4: Starting with the official pre-trained weights of MedSAM2, fine-tune the model on limited cervical cancer labeled data, and output the dedicated segmentation model weights for cervical cancer lesions. Step 5: Postprocess the slice-level segmentation mask output by the model and calculate the quantitative indicators of clinical concern.

2. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 1, characterized in that: Step 1 specifically includes: Step 1.1: Raw Data Organization: The hospital provides data in two levels: patient and sequence. Each patient subdirectory contains the raw image .nii file generated from the same examination and the corresponding Segmentation_*.seg.nrrd segmentation file. The sequence set consists of 10 sequences: {ADC, DWI, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp, t1_tra_W, t2_tra, t2_cor, t2_sag}. Among them, ADC is the apparent diffusion coefficient map, DWI is magnetic resonance diffusion-weighted imaging, t1_tra, t1_tra_F, t1_tra_in, t1_tra_opp and t1_tra_W are multivariate T1-weighted imaging, and t2_tra, t2_cor and t2_sag are multi-directional T2-weighted imaging. Step 1.2: Segmentation Label Space Alignment: The segmentation is resampled using the ResampleImageFilter provided by SimpleITK with the original image as the reference space. To avoid the label values ​​being corrupted by interpolation, the resampling interpolator uses nearest neighbor interpolation sitkNearestNeighbor and preserves the identity transformation. The resampled image and segmentation are exported in the same .nii.gz compressed format to form an aligned image-segmentation pair. Step 1.3: Patient ID desensitization mapping: For each sequence, independently traverse all patient folders under that sequence, map the original patient IDs to the research IDs in lexicographical order, and write the mapping results of each sequence to the patient_folder_mapping_{sequence name}.txt file to form a one-to-one relationship between patient name and research ID; Step 1.4: Reversible bidirectional mapping mechanism: The mapping table supports both forward and reverse queries from the original ID to the research ID, enabling modeling with anonymized research IDs during the research phase, and restoring the research IDs to the original folder names recognizable by the hospital side based on the reverse mapping table during the stage of sending the segmentation results back to the hospital. Step 1.5: Data Storage: The output is reorganized into a two-level directory structure with the sequence name folder containing the patient study ID folder. Each patient directory contains a corresponding .nii.gz image and a .nii.gz segmentation mask file, forming a standardized dataset with consistent naming, spatial alignment, and direct access to subsequent preprocessing.

3. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 1, characterized in that: Step 2 includes: Step 2.1: Loading NIfTI and slicing along the Z-axis: Load the .nii.gz image and corresponding .nii.gz mask for each patient separately. After passing the shape consistency check, extract the two-dimensional image and two-dimensional mask slice by slice along the Z-axis. Step 2.2: Sequence-Specific Target Resolution Setting: Target spatial dimensions are set for each of the 10 sequences: The dimensions used for diffusion-type sequences ADC and DWI are matched to their lower native scan resolution; the dimensions used for T1-weighted subsequences t1_tra_F, t1_tra_W, t1_tra_in, and t1_tra_opp are matched to their medium-resolution Dixon-type reconstruction characteristics; the dimensions used for structural sequences t1_tra, t2_tra, and t2_sag are designed to preserve high-resolution structural details; the dimensions used for t2_cor strike a balance between coronal resolution and computational overhead. These resolution settings are applied in batches to the corresponding sequences using a lookup table. Step 2.3: Bicubic Interpolation Unified Resize: For each slice of image and mask, apply bicubic interpolation to scale it to the target size corresponding to the sequence. During the resize stage, retain the sub-pixel level transition information at the lesion boundary, so that the floating-point interpolation result carries the soft transition intensity near the boundary. Then, round it to the nearest integer and truncate it to the effective range of uint8 [0, 255] to obtain the integer mask and obtain the boundary label. Step 2.4: NaN and Inf numerical cleaning: Before normalization, perform np.nan_to_num cleaning on the image data to uniformly replace NaN, +Inf, and −Inf with 0; Step 2.5: min-max 0-1 normalization: Perform min-max linear normalization independently on each slice to compress the values ​​to the [0,1] interval; if the maximum and minimum values ​​of a slice are equal, set them to zero directly; Step 2.6: Slice-level disk saving: Multiply the normalized image by 255 to convert it to 8-bit grayscale, and save it in JPEG format as {slice index:04d}.jpg file; save the mask directly as uint8 type as {slice index:04d}.npy file; organize the output directory as a three-level directory of sequence name / image or mask / patient study ID, where / is the path separator within the folder, ensuring that the image and mask directories correspond completely one-to-one at the patient and slice levels; Step 2.7: Slice Validity Statistics: For each slice, determine whether its mask contains non-zero foreground pixels. This will count the number of valid slices for each patient, providing a basis for sampling based on valid slices in the subsequent training phase and avoiding diluting the training signal with a large number of background slices.

4. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 1, characterized in that: Step 3 includes: Step 3.1: Core sequence screening: Determine the core sequence automatically extracted from cervical cancer lesions; Step 3.2: Extraction of slices of interest: Based on the slice-level mask for each patient, determine the slice index interval containing the lesion according to the number of effective slices, and extend this interval upwards and downwards as needed as spatial context redundancy, and extract continuous slice segments centered on the lesion. Step 3.3: Pseudo-video frame serialization: Organize the continuous slices centered on the lesion into pseudo-video frame inputs according to their physical location in the original volume data, with each slice corresponding to one frame in the pseudo-video. Step 3.4: Automatic generation of bounding box prompt: Based on the binary mask corresponding to each slice, calculate the bounding rectangle of its foreground pixels as the bounding box prompt of that slice; Step 3.5: Auxiliary Sequence Fusion Interface: Reserves an extension interface for other functional sequences as auxiliary inputs. Under the premise of the core sequence being dominant, it allows the introduction of supplementary information through multi-channel splicing or feature-level fusion, providing a unified data access protocol for subsequent model capability expansion for complex lesion scenarios.

5. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 4, characterized in that: The core sequence in step 3.1 is the sagittal T2-weighted sequence t2_sag.

6. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 1, characterized in that: Step 4 includes: Step 4.1: Model initialization: Load the pre-trained weights released by MedSAM2, retaining the complete structure of its ImageEncoder, Memory Attention module, Memory Encoder, and Mask Decoder; Step 4.2: Training data organization: Using the pseudo video frame sequence and corresponding bbox prompt obtained in Step 3 as training samples, the training, validation and test sets are divided by patient to ensure that the same patient's slice does not cross sets and to avoid data leakage; Step 4.3: Fine-tuning strategy configuration: Freeze some backbone parameters and only fine-tune the parameters of the prompt encoder and mask decoder to effectively prevent overfitting under limited annotation scale; Step 4.4: Loss function design: A weighted combination of Dice Loss and Binary Cross-Entropy Loss is used as the overall optimization objective to balance the region overlap index and pixel-level classification accuracy; Step 4.5: Data Augmentation and Regularization: During the training phase, data augmentation is performed on the pseudo-video frame sequence. The data augmentation includes random flipping, rotation, intensity perturbation, and slight bbox jitter to simulate the uncertainty of clinical collection and sketching. Step 4.6: Training and Model Selection: Based on the Dice metric on the validation set, implement an early stopping strategy and select the model that performs best on the validation set as the dedicated segmentation model for cervical cancer lesions.

7. The method for automatic extraction of cervical cancer lesions from multiple MRI sequences based on the MedSAM2 video segmentation model according to claim 1, characterized in that: Step 5 include: Step 5.1: Restoration of pseudo-video frames to 3D mask: Reassemble each frame mask output by MedSAM2 into a 3D mask volume according to the physical position order of the slices in Step 3, and map it back to the original space before preprocessing in Step 2 through the recorded coordinates. Step 5.2: Morphological post-processing: Perform small connected component culling and morphological opening and closing operations on the 3D mask to eliminate isolated scattered points and edge spikes; Step 5.3: Quantitative evaluation: Calculate the Dice similarity coefficients DSC, IoU, HD95, and ASD on the test set, with Dice being the primary evaluation metric; Step 5.4: Output Results: Output the final mask in NIfTI format, and provide a visual overlay of each slice for user review.

8. An automatic lesion extraction system for cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model, characterized in that: The system has a program module corresponding to the steps of any one of claims 1-7, and executes the steps in the method for automatic extraction of cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model when it is run.

9. A computer device, characterized in that: The device includes a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, it performs the steps of the automatic extraction method for cervical cancer MRI multi-sequence image lesions based on the MedSAM2 video segmentation basic model as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: The storage medium is used to store a computer program that executes the automatic extraction method for cervical cancer MRI multi-sequence images based on the MedSAM2 video segmentation model as described in any one of claims 1-7.