Abstract
Objective
Ultrasound imaging of the endometrium is often affected by speckle noise, low contrast, and physiological cycle variations, which lead to blurred boundaries and ambiguous structural representation. To address these challenges, this study proposes a segmentation method specifically designed for ambiguous ultrasound scenarios, which provides stronger attention guidance to indistinct boundaries, thereby improving the accuracy of structural contour segmentation.
Methods
The proposed TGMS-UNet is a dual-branch segmentation network that converts geometric contours into sequential representations by calculating the distance and angle variations from boundary points to the centroid. The sequence-image feature alignment module employs global attention and scanning mechanisms to achieve cross-modal fusion and integrate contour prior knowledge, while the feature correction and adaptive fusion module uses a gating mechanism to rectify multi-scale feature misalignment and suppress erroneous information. The network is trained end-to-end, enabling the fusion of multi-scale image features and sequence-guided boundary information within a unified framework.
Results
Experimental results show that TGMS-UNet achieves a Dice of 0.9226 and an IoU of 0.8822 on a private endometrial ultrasound dataset of 1,063 images, and a Dice of 0.8355 and an IoU of 0.8012 on the public BUSI breast ultrasound dataset, outperforming existing mainstream segmentation models on key metrics.
Conclusion
The proposed TGMS-UNet demonstrates strong ability to handle ambiguous, low-contrast ultrasound images, particularly in accurately delineating blurred boundaries. By leveraging contour-derived prior information and enhancing feature consistency across scales, it improves segmentation precision and reliability.
Keywords
1. Introduction
The endometrium is a vital component of the female reproductive system. Accurate evaluation via transvaginal ultrasound is crucial for diagnosing conditions such as infertility, endometrial hyperplasia, endometriosis, and endometrial cancer.
1
According to the World Health Organization, approximately one in six adults worldwide suffers from infertility, with endometrial factors accounting for nearly two thirds of cases.
2
Transvaginal ultrasound, through comprehensive scanning using a vaginal probe, provides critical information on endometrial length, thickness, morphology, and uterine position, aiding in the detection of abnormalities.
3
However, precise segmentation of the endometrium in B-mode ultrasound imaging faces several challenges. First, inherent speckle noise, which results from constructive and destructive interference of coherent echoes scattered at tissue interfaces, often leads to significant noise interference, low overall contrast, considerable boundary variability, and frequent boundary obscuration. Second, as shown in Figure 1, beyond these inherent imaging limitations, ultrasound images of the endometrium are further influenced by menstrual cycle variations. These physiological changes introduce additional speckle noise, acoustic shadowing, and reduced boundary contrast, particularly in scenarios where the demarcation between the endometrium and myometrium is ambiguous. Ultrasound endometrial image in a blurred scene. The red arrows indicate blurring in the ultrasound image.
Currently, manual delineation of endometrial contours in ultrasound images is highly subjective and prone to inconsistency, as it relies heavily on clinicians’ experience and may vary among individuals with different levels of seniority. 4 Therefore, precise and automated segmentation of the endometrial boundary in blurred ultrasound images is crucial for reducing diagnostic subjectivity. Accurate endometrial segmentation can enhance the objectivity and reliability of endometrial receptivity assessment in infertility diagnosis and treatment. 5 The accurate evaluation of endometrial receptivity depends on key parameters such as endometrial thickness and morphology, which in turn require clear and reliable boundary segmentation. Based on this, clinicians can more objectively determine the implantation window and select the optimal timing for assisted reproductive procedures.
Existing deep learning approaches for this task face significant limitations. Convolutional neural network (CNN)-based methods, while effective in feature extraction, often lose spatial details during down-sampling and struggle with the global context due to their local receptive fields. 6 Although multi-scale strategies and Transformer-based models have been introduced to capture broader context and improve accuracy, they can still produce jagged boundaries due to detail loss during up-sampling. 7 To overcome this, several studies have focused on enhancing boundary segmentation. For example, Park et al. proposed a key-point-based framework that incorporates prior key-point information to improve the accuracy and robustness of endometrial region segmentation. 3 Nevertheless, in cases of extremely low contrast, these models fail to fully emulate the nuanced reasoning and domain expertise clinicians employ when delineating ambiguous contours. To address these shortcomings, leveraging textual representations of expert knowledge has emerged as a promising direction. In natural image segmentation, sequence-guided methods have demonstrated efficacy by integrating precise linguistic descriptions.8,9 In medical imaging, Early studies, such as Bhalodia et al., explored the use of radiology report text for weakly supervised lesion localization by extracting keyword-level attributes and employing cross-attention to align visual and textual representations, demonstrating that textual information can effectively guide models toward clinically relevant regions. 10 however, the outputs were limited to coarse bounding boxes rather than pixel-level segmentation or fine boundary modeling. Building on this idea, Tomar et al. proposed TGANet, which introduced structured textual attributes (e.g., polyp size and number) into colorectal polyp segmentation via a label attention mechanism, showing that even simple textual cues can enhance segmentation performance, albeit with limited semantic richness and insufficient boundary guidance. 11 Subsequently, Li et al. presented LViT, leveraging richer textual descriptions and BERT embeddings within a dual-branch U-shaped CNN–Transformer architecture to enable deeper language–vision interaction under a semi-supervised framework, but at the cost of increased model complexity and without explicitly addressing high-frequency edge perception. 12 Further, Zhang W. et al. proposed DescriptorMedSAM, which systematically investigated the effect of prompt granularity and demonstrated that structured descriptors incorporating shape and spatial information significantly improve zero-shot and few-shot segmentation performance, while still being constrained by the performance of the underlying foundation model and lacking explicit boundary-aware optimization. 13
Inspired by these developments, we propose TGMS-UNet, a novel sequence-guided dual-branch segmentation network tailored for ambiguous ultrasound endometrial images. Our core innovation lies in encoding the geometric contour of the endometrium into contour sequence features based on variations in distance and angle from contour points to the centroid. Specifically, contour sequence features are defined as a centroid-based ordered representation of endometrial boundary points, where the manually annotated contour is arranged in a clockwise order starting from the leftmost boundary point and encoded by transforming its coordinates into normalized distance and angular sequences relative to the centroid. These features embed the clinical reasoning process of contour delineation. We design a sequence-image feature alignment module to fuse this prior knowledge with visual features dynamically. Furthermore, to tackle the feature misalignment issue inherent in multi-scale fusion, we introduce a feature correction and adaptive fusion module that incorporates a gating mechanism to selectively integrate and calibrate features. The main contributions of this work are summarized as follows: 1. We propose a novel sequence-guided segmentation framework that encodes endometrial contours into a distance-angle-based sequence, effectively incorporating clinical prior knowledge to resolve ambiguities in ultrasound images. 2. We design a feature correction and adaptive fusion module within the bottleneck to mitigate multi-scale feature misalignment, allowing the model to adaptively adjust fusion ratios and suppress erroneous guidance. 3. Extensive experiments on a private ultrasound endometrial dataset and a public breast ultrasound dataset demonstrate that our TGMS-UNet outperforms state-of-the-art segmentation methods across multiple metrics, offering a robust tool for clinical support.
2. Methodology
2.1. Image datasets
2.1.1. Self-built ultrasound endometrial dataset
This study is a retrospective model development and validation study conducted in Changsha, China. It collated videos of endometrial examinations from 400 patients undergoing TVUS at the Ultrasound Department of the Affiliated Changsha Central Hospital, University of South China from 2023 to 2024, using a LOGIQ E11 system. This retrospective study was approved by the Institutional Review Board of the Affiliated Changsha Central Hospital (approval number KY-2023-156-01) with a waiver of informed consent due to the retrospective nature. The collected videos were filtered according to the following exclusion criteria: (1) images containing severe artifacts or incomplete anatomical structures; (2) videos with poor signal-to-noise ratio or incomplete scanning sequences; (3) cases where the visualization duration of the standard endometrial section was less than 1 second; (4) examination videos with a total duration of less than 10 seconds. To enhance the generalizability of the model, the final included video data covered examination scenes from both the proliferative and secretory phases. Each retained video was approximately 10 seconds in duration, with the standard endometrial section lasting between 1-2 seconds. From these videos, an average of about 25 images were extracted per video, including 2-4 standard sections, resulting in a final dataset of 1063 standard section images.
All images were annotated by two professional physicians to produce real segmentation masks of the endometrial region. The annotation workflow followed a two-reader protocol: inter-rater agreement between the two physicians was first evaluated using the Dice similarity coefficient. The segmentation masks were jointly confirmed by both physicians to form a consensus annotation. For cases with disagreement or large Dice variation, particularly where the endometrial boundary was ambiguous or difficult to delineate in ultrasound images, both experts performed joint re-evaluation and refined the annotations through sufficient discussion, ultimately generating a unified binary consensus mask. Based on these masks, a sequence representation that simulates the doctor’s contour sketching process is generated by encoding the distance and angle variations from each contour point to the centroid. Importantly, to avoid potential data leakage caused by strong intra-patient correlation among frames extracted from the same video, dataset splitting was strictly performed at the patient level rather than the image level. All frames from the same patient were kept within the same subset. The dataset was finally divided into training, validation, and test sets in a ratio of 7:1:2 based on patients.
2.1.2. Breast ultrasound images dataset
To verify the general applicability of the model, additional evaluation was conducted on the public BUSI dataset, 14 collected from Baheya Women’s Hospital, which includes 780 ultrasound images (500 ×500 pixels) from 600 patients aged 25-75, covering 437 benign, 210 malignant, and 133 normal cases, acquired using LOGIQ E9 and E9 Agile systems.
2.2. Two-branch segmentation network based on sequence guidance and multi-scale feature correction (TGMS-UNet)
As illustrated in Figure 2, the proposed network framework, designated TGMS-UNet, accepts ultrasound endometrial standard cross-section images and their corresponding contour sequence data as input. The sequence data contain the “time series” change information of the distance and angle from the endometrial boundary contour points to the center of mass. The model generated segmentation masks in an end-to-end manner. Specifically, the backbone network uses U-Net with residual connections to extract the image features at all levels. The Transformer sequence encoding branch constitutes another backbone branch, which employs the Transformer with self-learning position encoding to extract sequence features. In addition, it designs a sequence feature and image feature alignment fusion module (TIFM). The alignment and fusion of sequence and image features are achieved through the global attention mechanism of the transformer, along with spatial and channel scanning fusion. To enhance the model’s understanding of multi-scale features and global context, the lateral connection was embedded in a multi-scale fusion module (GLFM). The purpose of this is to fuse the global features of the transformer visual branch with the local multi-scale features of the encoder at all levels. Concurrently, a feature correction and adaptive fusion module (FCAM) was integrated into the bottleneck structure to enhance the morphological features of the endometrium, rectify the offset features induced by multi-scale fusion, and regulate the fusion ratio through a gating mechanism to mitigate potential guidance bias. This approach enhances the model’s perception of fuzzy boundaries and improves the overall segmentation performance. The general framework of the proposed TGMS-Unet model. The model is based on an enhanced U-Net with residual connections, integrated with a sequence and image feature fusion module, a multi-scale fusion module, and a feature correction and adaptive fusion module.
2.3. Sequence feature extraction branch
As demonstrated in Figure 3, the extraction of features reflecting contour changes in the contour sequence data is achieved using two CNN components specifically designed for one-dimensional contour sequence data.15,16 In our work, the endometrial contour is transformed into a numerical sequence representation based on its geometric structure. Specifically, the contour is extracted from the binary mask obtained via manual annotation, and the annotated contour points are directly utilized to preserve boundary fidelity. To ensure sequence consistency, the leftmost point is selected as the starting point, and all contour points are arranged in a clockwise order. The centroid of the contour is computed using the region moment method, and each point is represented in polar form relative to the centroid by calculating its Euclidean distance and azimuth angle, with the angle normalized to the range [0,2π). Furthermore, the distance and angle values are normalized to reduce scale variations. Since the annotation process enforces contour closure, the resulting sequence forms a complete and continuous representation of the endometrial shape. This distance-angle pair provides a complete polar coordinate description of the contour, thereby enabling the theoretical reconstruction of the original shape. Each component comprises a 1D convolution layer, a batch normalization layer, and a GELU activation function. The component performs preliminary processing on the sequence data X to extract basic features L reflecting contour changes. Subsequently, these features are input into a multi-head self-attention (MHA) mechanism to learn correlations within the sequence. Each attention head can identify different patterns, thereby capturing the endometrial contour and its variation characteristics. The process can be calculated by the following formulas: Unit module structure of the proposed sequence encoding branch.
Since the positions of node elements in the set lack inherent meaning, a learnable positional encoding is introduced to represent these positions, thereby enhancing the model’s ability to understand contour sequence data. This approach allows the model to capture the changing characteristics of the endometrial contour more accurately and provide precise contour change information for the sequence and image fusion module, which guides the image segmentation process and model attention, ultimately achieving more accurate endometrial contour segmentation.
2.4. Sequence feature and image feature alignment fusion module (TIFM)
Accurate segmentation of the endometrial boundary remains challenging due to artifacts, noise, and physiological variations in ultrasound images. Existing CNN-based models often treat the image uniformly, leading to overly smooth and inaccurate boundaries. 17 To tackle this, we introduce a sequence-image feature fusion module that integrates boundary-related sequence features to enhance boundary precision and attention focus. A key challenge in sequence-guided segmentation lies in aligning cross-modal visual and sequence features. Early methods used RNN/LSTM to encode text and CNN to extract image features, combining them via multimodal LSTM,18–21 attention mechanisms,22,23 or cycle consistency. 24 More recent approaches employ transformers for deeper fusion, such as MDETR and VLT with transformer decoders,25,26 LAVT with a Swin Transformer backbone, 27 and dual-encoder architectures like ReSTR and CRIS.28,29
Despite these advances, most existing methods perform modality alignment only after feature encoding, which limits the exploitation of multi-level visual details and may result in information loss. To address this limitation, we adopt a dual-branch encoder architecture and embed TIFM into each encoder layer to enable progressive cross-modal fusion. Specifically, TIFM employs a cross-attention mechanism in which visual features act as queries, while sequence features serve as keys and values, allowing boundary-aware sequence cues to selectively guide visual feature enhancement. Modal alignment is conducted using a single-head cross-attention module at each encoder layer, thereby achieving fusion at a single scale per layer while preserving hierarchical representations. In addition, residual connections and a gating mechanism are introduced to balance gradient propagation between the visual and sequence branches, adaptively regulate the fusion ratio, and alleviate potential bias introduced by noisy or ambiguous sequence priors.
As demonstrated in Figure 4, given the input image features Sequence and image feature fusion module.
Among them, The implementation of the projection functions
Among them,
In the second step, the sequence feature
In order to promote interaction both within and across different modalities, a warping mechanism was designed for the hybrid feature cube. Specifically, this mechanism consists of channel and spatial scanning in sequence, where both scanning operations are implemented via multi-head attention MHA to explicitly model global dependencies rather than local aggregation. Channel scanning regards channels as ordered sequences and learns cross-channel communication to promote modal fusion. In this process, each channel is treated as a token, and self-attention is performed across the channel dimension to dynamically model inter-channel dependencies, allowing information exchange among different modality-related feature groups embedded in the channel space. Then, spatial scanning operates on the spatial dimension and learns to transfer information within a separate spatial dimension slice. In this step, each spatial position is treated as a token, and multi-head attention is applied across all spatial locations to capture long-range spatial relationships and enable contextual propagation across different regions of the feature map, while preserving the channel-refined representations. Formally, this process can be written as:
Among them,
2.5. Feature correction and adaptive fusion module (FCAM)
In ultrasound imaging, the morphology and size of the endometrium vary with the physiological cycle, and down-sampling further aggravates the loss of spatial information. Traditional multi-scale cross-level fusion methods integrate high-resolution spatial features with low-resolution semantic features; however, repeated down-sampling often leads to spatial misalignment and representation discrepancies, ultimately degrading model performance.
31
To address this, we propose a feature fusion and correction method with two key strategies. As demonstrated in Figure 5, The first is multi-scale fusion, which aligns feature map sizes via down-sampling. Early stages integrate global-local features from the Transformer branch, while later stages fuse multi-scale features across stages, enhancing detail perception and semantic understanding. Proposed multi-scale fusion module.
The second strategy involves the incorporation of a feature correction and adaptive fusion module within the bottleneck structure, as shown in Figure 6. This module utilizes a grouping strategy to calculate the offset between multi-scale and multi-modal features, employs sequence-guided boundary morphological attention to correct multi-scale features, enhances boundary attention, and mitigates the issue of spatial feature misalignment. This method optimizes spatial consistency and preserves semantic information. To circumvent the performance degradation that arises from direct concatenation and fusion of features,32,33 a gating mechanism is introduced to achieve adaptive fusion of the corrected multi-scale features and multi-modal features.
34
This mechanism enables dynamic adjustment of the fusion ratio, mitigates the impact of erroneous sequence information, and enhances the robustness of the model. Finally, the corrected features are input into the channel attention module to further focus on key features and improve segmentation accuracy.
35
Feature correction and adaptive fusion module.
Specifically, for the multi-scale feature
3. Statistical analysis
3.1. Evaluation metrics
The study used six common metrics to quantitatively compare the performance of different methods for segmentation of standard sections of ultrasound endometrium: Dice, IoU, Acc, Sen, Spe and Hausdorff distance (HD). Dice and IoU evaluate the overlap between the true segmentation mask G and the model predicted segmentation result P. Acc, Pre and Spe are key indicators to measure the performance of the model for pixel classification. TP, FP, TN, and FN stand for true positive, false positive, true negative, and false negative, respectively. They are defined as:
HD measures the maximum distance between the two boundaries of the true segmentation mask and the model predicted segmentation mask.
3.2. Statistical evaluation methods and experimental parameters
All models in this study were implemented using the PyTorch deep learning framework and trained on a workstation equipped with an NVIDIA GeForce RTX 4090 GPU. The models were trained for 100 epochs with the Adam optimizer, using an initial learning rate of 0.0001, a weight decay of
4. Results
4.1. Comparative experimental results
Comparison of our method with state-of-the-art segmentation methods on the ultrasound endometrial standard section dataset. The unit of HD is pixels (px) and the best results are marked in bold text.
In order to further compare the segmentation performance of these methods, Figure 7 presents a visual comparison of TGMS-UNet and other approaches on the endometrial ultrasound image dataset. Each row in the figure corresponds to the same input image, while each column represents the segmentation results of different methods. The test images consist of cases of ambiguous ultrasound, where the endometrial boundary is mixed with myometrial echoes and exhibits indistinct boundaries. The findings demonstrate that, through the synergistic effect of the sequence-enhanced guidance and boundary refinement modules, our method is more effective than alternative approaches in handling regions with blurred boundaries or low contrast, and can accurately delineate endometrial boundaries of various shapes. These findings further demonstrate that TGMS-UNet achieves superior segmentation performance compared with other mainstream methods. Segmentation visualization results of different models on a dataset of endometrial ultrasound images.
Quantitative comparison of the performance of different methods on the public BUSI dataset, with the best results shown in bold.
To provide a more intuitive evaluation of the actual segmentation performance of different models on the BUSI breast ultrasound dataset, Figure 8 presents a visual comparison of the results produced by various methods. From the visualization, it can be observed that under the challenging conditions of breast ultrasound images, where boundaries are more ambiguous and structural information is insufficient, TGMS-UNet is able to more robustly extract lesion contours and preserve structural integrity through the joint effect of the boundary guidance module and the feature refinement module. Compared with other methods, it demonstrates more pronounced advantages in capturing fine details and maintaining regional coherence. Segmentation visualization results on the BUSI ultrasound image dataset with different models.
4.2. Ablation experiment results of the sequence-guided branch
In order to evaluate the effectiveness of the sequence-guided branch in enabling the model to learn the outline process of professional physicians, this study designed the following ablation experiments: 1) using only the sequence data of the distance change from the endometrial contour point to the center; 2) using only the sequence data of the angle change from the contour point to the center; 3) using a combination of distance and angle change sequence data. Additionally, to compare with the sequence-guided strategies, two non-sequence geometric encoding methods were introduced: 4) SMU-Net-based saliency guidance, 45 which generates a saliency map by fusing multi-level structural information of the foreground and background, representing a contour-map encoding strategy for segmentation enhancement and 5) Keypoint-guided segmentation, which uses four anatomical keypoints of the endometrium (the tip of the endometrial cavity, the cervical os, and the two thickest points between the anterior and posterior basal layers) to guide the segmentation. 3 The baseline model removes the sequence-guided segmentation branch and the sequence-image feature fusion module.
Results of ablation experiments on different sequence-guided segmentation strategies of the model using the ultrasound endometrial standard section dataset.
4.3. Ablation experiment results of the model module
In order to evaluate the role of each component in the segmentation framework, an ablation study was conducted on the ultrasound endometrial dataset. This study involved three main modules: the text–image feature integration module (TIFM), the feature correction and adaptive fusion module (FCAM), and the global–local multi-scale feature fusion module (GLFM). The baseline model is constructed based on U-Net, where the above modules are removed and only residual connections are retained to enhance feature propagation.
Results of ablation experiments on different modules in the model using the ultrasound endometrial standard section dataset.
As demonstrated in Figure 9, the qualitative outcomes provide additional support for the conclusions derived from the quantitative analysis. In this study, endometrial ultrasound images with pronounced boundary ambiguity and noise interference were selected for analysis. A qualitative visual comparison was conducted among the segmentation results of the baseline model, the baseline model with the FCAM module, the baseline model with the GLFM module, and the baseline model incorporating the TIFM module. The results were then overlaid with the corresponding ground truth annotations for comprehensive evaluation. The findings suggest that, in comparison with the baseline model, the incorporation of the FCAM and GLFM modules enhances the completeness of the segmented regions to a certain extent. Nevertheless, limitations persist with regard to boundary continuity and closure. In contrast, the model incorporating the TIFM module demonstrates superior contour consistency and structural integrity when handling blurred boundaries and noisy regions, achieving a higher degree of overlap with the ground truth annotations. These visualization results indicate that all modules contribute to performance improvement. Among them, the TIFM module effectively leverages the sequential prior information of boundary contours to constrain and refine ambiguous regions, thereby guiding the model to achieve more precise boundary segmentation and significantly improving boundary localization accuracy under complex ultrasound imaging conditions. Qualitative visualization of segmentation results in blurred regions across different modules.
4.4. Parameter experiment results
Computational cost comparison of segmentation models.
As shown in Table 5, TGMS-UNet has a moderate parameter count (62.2 M), FLOPs (83.6 G), and inference latency (45.2 ms) among the compared models. This may be due to the dual-branch design introducing additional model redundancy. Future work will focus on exploring lightweight strategies to reduce the computational cost while maintaining segmentation performance.
4.5. Clinical validation trial of automated endometrial thickness measurement
In this experiment, the outputs of different segmentation models were combined with an automatic thickness measurement method to evaluate their applicability in quantitative endometrial thickness analysis. For each model’s segmentation result, the largest connected component was first extracted to remove noise and small spurious regions, thereby ensuring the stability and robustness of subsequent measurements. Within this region, an Euclidean distance transform was applied to compute the minimum distance from each pixel to the nearest boundary, resulting in a distance map. The location of the maximum value in the distance map was then identified as the center of the maximum inscribed circle, with the corresponding distance value representing its radius. The endometrial thickness was finally defined as the diameter of this maximum inscribed circle. To ensure consistency across different models and images, all thickness measurements were reported in pixel units.
Figure 10 illustrates the relative errors between the automatically measured thickness and the thickness derived from expert manual contour delineations for representative test samples. The results show that the proposed model maintains a consistently low measurement error across all examples and achieves the smallest error in most cases. Furthermore, Figure 11 presents the mean absolute error between the automatically measured thickness based on segmentation results and the reference thickness obtained from ground-truth contours over the entire test set. The proposed method again demonstrates superior performance compared with the other models. Comparison of relative errors between the thickness of the model segmentation results and the thickness annotated by the physician. Comparison of mean absolute error of model segmentation thickness.

The results demonstrate that the endometrial ultrasound image segmentation model constructed in this study not only exhibits excellent segmentation performance but also supports highly consistent automatic thickness measurement. This significantly reduces subjective bias introduced by differences in physician operation, improving the repeatability and efficiency of endometrial thickness measurement. This provides a reliable method for the objective and standardized assessment of endometrial thickness, and has practical significance for optimizing clinical examination procedures and assisting in the diagnosis of related diseases.
4.6. GradCAM heatmap experiment results
To enhance the interpretability of TGMS-Net’s boundary segmentation decisions, this study employed the Grad-CAM technique to visualize the regions of interest in the segmentation model and to verify the precision of boundary segmentation with the addition of boundary guidance.
46
As shown in Figure 12, the experimental results indicate that in ultrasound images with blurred boundaries, models without boundary guidance, such as Swin-Unet and CASFNet, tend to prioritize noise regions rather than true boundary features. Although TGANet and LViT incorporate sequence-guided segmentation, they do not perform effective filtering and correction of the guidance information, which may result in attention being misallocated to non-target regions. Consequently, their segmentation outputs may either exceed the actual contours or entirely overlook the blurred areas where boundaries are discernible, leading to significant segmentation errors. In contrast, the TGMS-UNet model, equipped with boundary guidance branches, can accurately focus on the true endometrial contours within blurred regions by fusing image features with boundary sequence features, achieving precise segmentation. This demonstrates that the sequence-guided attention mechanism effectively corrects the model’s attention allocation in blurred regions, thereby mitigating segmentation errors caused by noise interference and generating more refined and accurate segmentation boundaries. Attention heatmap. Red arrows indicate blurred areas in the image.
The experiment comprised four models: two comparison models that achieved the best results on the endometrial ultrasound dataset, the TGMS-UNet model without the sequence boundary guidance branch, and the complete TGMS-UNet model. The test images comprised images in which the endometrial boundary and myometrial echo were mixed and the boundary was unclear, as indicated by the red arrow marking the location of the blurred area. The experimental results demonstrate that the complete TGMS-UNet model, when guided by the sequence boundary, can significantly enhance the focus on areas with blurred boundaries or low contrast, and achieve accurate segmentation of the entire endometrial contour.
4.7. Failure case analysis
As demonstrated in Figure 13, three typical failure or suboptimal segmentation cases of the TGMS-UNet model are presented, with each row corresponding to one specific case. In the first instance, the endometrial region demonstrates notable echogenic similarity with the adjacent myometrial background over a substantial area, leading to indistinct boundaries and consequently impaired segmentation performance. In the second case, the endometrial region appears relatively elongated, and this narrow structure shares similar echogenic characteristics with the myometrium, making it challenging for the model to accurately delineate the complete anatomical boundaries. In the third case, fluid accumulation caused by either device-related factors or endometrial pathology results in the presence of an anechoic dark region within the image, which partially obscures the endometrial contour and reduces segmentation accuracy. In future work, for the aforementioned challenging segmentation cases, we consider incorporating prior information from complete contour sequences together with global structural information to impose consistency constraints, and further refine the segmentation results. It is anticipated that this approach will enhance the structural integrity and segmentation accuracy of the model in complex conditions, such as blurred boundaries, elongated morphologies, and partial occlusions. Analysis of three types of failure cases.
5. Discussion
5.1. Comparison and discussion of related ultrasound segmentation methods
In order to further discuss and compare the performance differences between TGMS-UNet and similar models, as well as to validate its cross-organ generalization capability, this study conducts a comparative analysis of related approaches adopting boundary enhancement strategies and CNN–Transformer hybrid architectures. This study places particular emphasis on the architectural designs and the segmentation performance of the subjects on ultrasound datasets, with particular attention being paid to the BUSI dataset.
In the field of boundary enhancement and guidance strategies, Liu et al. proposed Asym-UNet, a multi-branch residual encoder and an external attention module, combined with a deeply supervised boundary detection branch, to strengthen boundary localization. The model attained a Dice score of 79.94% on the BUSI ultrasound dataset, encompassing both benign and malignant cases. 47 Xue et al. developed GG-Net, which designs a global guidance module along both spatial and channel dimensions, and incorporates a shallow boundary detection branch to impose boundary-aware deep supervision on multi-scale features. This results in a Dice score of 82.1% on the BUSI benign and malignant ultrasound dataset. 48 Hu et al. proposed BGRA-GSA, which leverages a global-scale adaptive module to capture multi-scale contextual information, and employs a boundary-guided module together with a region-aware module to progressively refine feature representations, reaching a Dice score of 81.43% on the BUSI dataset. 49 Huang et al. have devised a Boundary-Rendering Network that incorporates a boundary selection module and a graph convolution-based boundary rendering module. Utilizing a graph structure enables the global refinement of contour vertices, thereby achieving a Dice score of 85.4% on the BUS ultrasound dataset. 8 Boundary enhancement-based methods generally improve segmentation accuracy by introducing boundary supervision branches, edge detection operators, or boundary post-processing modules, which can partially alleviate the issue of blurred boundaries in ultrasound images. However, these approaches fundamentally still rely on image-derived features or treat boundary extraction as an auxiliary learning task, and their performance is limited when lesions exhibit gray-level similarity with surrounding tissues. In contrast, TGMS-UNet does not directly detect boundaries from images; instead, it transforms expert-annotated contours into distance- and angle-based sequential representations and aligns these sequences with image features, thereby embedding structured geometric priors into feature learning and enabling more robust segmentation in low-contrast regions.
In the field of CNN–Transformer hybrid architecture strategies, Feng et al. designed HTBE-Net, which constructs a dual-branch encoder consisting of a CNN and a Swin Transformer. It achieves feature-level deep fusion through a boundary-guided module, a selective feature enhancement module, and a long–short-range attention interaction fusion module, reporting a Dice score of 81.17%. 50 He et al. developed HCTNet, which interleaves CNN and Transformer encoding blocks within the encoder and introduces a spatial cross-attention module to reduce semantic gaps between the encoder and decoder, achieving a Dice score of 82.00% on the BUSI benign and malignant ultrasound dataset. 51 Zhang et al. proposed HAU-Net, which embeds a Local-Global Transformer module into the skip connections of U-Net. It leverages local window self-attention and global token attention for efficient long-range dependency modeling, and further introduces a cross-attention module in the decoder to fuse multi-scale features, achieving a Dice score of 83.11% on the BUSI dataset. 52 Yang et al. proposed CSwin-PNet, which constructs a feature pyramid based on Residual Swin Transformer Blocks. It further integrates an interactive channel attention module and a complementary feature fusion module to achieve encoder–decoder feature complementation, obtaining a Dice score of 83.68% on the BUSI dataset. 53 These hybrid architectures leverage the self-attention mechanism of Transformers to compensate for the limited receptive field of CNNs, thereby enhancing global contextual modeling and demonstrating advantages in irregular lesion segmentation. However, their global modeling remains confined to semantic relationships within the image space and lacks explicit understanding of holistic geometric structures. Moreover, fusion strategies are mostly based on concatenation or simple attention mechanisms, which do not fundamentally improve boundary awareness. In contrast, although TGMS-UNet also adopts a dual-branch design with cross-modal fusion, its Transformer branch takes contour-derived distance–angle sequences as input, encoding shape priors rather than image semantics. Therefore, its fusion with the CNN branch is essentially prior-guided rather than simple feature complementarity, enabling stronger robustness in boundary-ambiguous regions.
Despite not being specifically designed for breast ultrasound, TGMS-UNet achieves a Dice score of 83.55% on the BUSI benign and malignant segmentation task, reaching or even surpassing most task-specific models. This enhanced performance can be attributed primarily to the contour-sequence guidance strategy, which involves the encoding of geometric information concerning clinician-annotated boundaries into explicit priors. Furthermore, this strategy leverages cross-modal alignment to guide feature learning, thereby enabling the model to maintain robust boundary inference capability even in circumstances where visual information is limited. Concurrently, the feature correction and adaptive fusion modules mitigate spatial misalignment issues in multi-scale feature integration, thereby ensuring stable performance across lesions of varying scales and morphologies. The results obtained demonstrate that cross-modal methods based on contour sequence priors constitute an effective segmentation paradigm with strong generalization ability.
5.2. Limitations of sequence guidance and computational overhead
This study systematically compares TGMS-UNet with representative text and sequence guided segmentation methods including TGANet, 11 LViT, 12 LAVT, 27 and TVE-Net.54.All of these methods leverage auxiliary information beyond the image, such as textual descriptions, attribute labels, or contour sequences, to compensate for the insufficient information caused by noise, low contrast, or unclear boundaries in medical images, and align features through cross-modal attention. However, they differ in the form of guidance and fusion strategies. LViT and LAVT use natural language text and rely on pre-trained language models, which introduces high computational cost and a semantic gap that is difficult to fully bridge. TGANet simplifies text into discrete attributes, making the method lightweight but losing boundary shape information. TVE-Net converts textual location descriptions into probabilistic text views, effectively leveraging positional priors but not explicitly modeling continuous contour geometry. In contrast, TGMS-UNet directly converts manually annotated contours into distance and angle sequences, preserving complete geometric information without requiring additional text or pre-trained models. The polar coordinate sequences simulate the cognitive process of clinicians tracing contours, providing strong clinical interpretability and low computational complexity. Our quantitative comparisons, as shown in Tables 1 and 2, demonstrate the model’s superior performance in Dice, IoU, and HD metrics, confirming the effectiveness of sequence guidance for precise boundary segmentation. This feature correction and adaptive fusion strategy is the key reason why TGMS-UNet achieves significantly better HD performance on ultrasound images compared with LViT and TGANet.
Regarding fusion strategies, LViT and LAVT merge features through different forms of cross-modal attention, while TVE-Net employs multi-stage knowledge transfer to propagate textual view information. None of these methods explicitly address spatial misalignment of multi-scale features. TGMS-UNet introduces a sequence-image feature alignment module that fully explores cross-modal interactions through cross-attention and channel and spatial scanning mechanisms. At the bottleneck, a feature correction and adaptive fusion module calculates offsets in groups to correct spatial misalignment across different scales and modalities and applies a gating mechanism to suppress erroneous guidance. This allows the model to perform robustly in ultrasound images with blurred boundaries and severe noise. Nevertheless, the method still relies on high-quality manual contour annotations, which are labor- and time-intensive, and the dual-branch architecture increases computational burden. Future work may explore self-supervised contour learning and lightweight fusion architectures, as well as extending the method to 3D ultrasound or other modalities such as MRI and CT to improve generalizability.
5.3. Limitations in dataset scale, bias, and generalization capability
Although the private endometrial ultrasound dataset constructed in this study consists of 1063 images collected from transvaginal ultrasound videos of 400 patients, the dataset originates from a single institution, a single geographic region in Changsha, China, and a single ultrasound system. This results in significant regional and device-specific biases. In addition, the demographic characteristics of the patients, such as age distribution, body mass index, and ethnic diversity, are relatively limited, making it difficult to fully represent a broader clinical population. The main risks associated with these constraints include domain generalization risk, scanner variability, operator variability, and cycle-phase variability. Specifically, a model trained on a single data distribution may struggle to adapt to new clinical environments. Differences in probe frequency, gain settings, and post-processing algorithms across ultrasound devices can alter speckle noise patterns and boundary clarity. Variations in scanning techniques and standard section selection habits among different operators may also introduce inconsistencies in image quality. Furthermore, although the dataset includes images from both the proliferative and secretory phases, the sample distribution across these phases may still be imbalanced, making it difficult to fully capture the morphological and echogenic variations related to the physiological cycle.
In the field of medical image segmentation, the acquisition of high-quality annotated medical images is inherently constrained by clinical resources, imaging availability, and the limited number of experienced physicians. In this study, we did not explicitly compute a direct quantitative relationship between sample size and model performance. Instead, we adopted multiple indirect validation strategies to ensure that the sample size was sufficient for model development and to verify the reliability and robustness of the proposed method. First, compared with recent studies employing transformer-based models for ultrasound medical image segmentation,55,56 where sample sizes typically range from approximately 500 to 800 images, the 1063 images in this dataset represent a relatively large scale. Second, extensive data augmentation strategies were applied during training, and additional validation was performed on the public BUSI breast ultrasound dataset. These steps confirmed that the proposed model maintains stable performance and satisfactory generalization across different data sources. Although the dataset in this study may be considered relatively small compared to segmentation projects in natural scenes, this work is part of an ongoing research initiative. We are continuously collecting additional ultrasound and contrast-enhanced ultrasound images from multiple devices and clinical centers, with the goal of further expanding dataset diversity and enhancing the model’s generalizability.
6. Conclusion
This study proposes an innovative visual-language ultrasound medical image segmentation model termed TGMS-UNet. The model uses sequence data derived from changes in distance and angle between the target boundary and centroid to create a multimodal dataset comprising images and sequence The sequence-image feature alignment module addresses boundary blurring caused by noise and artefacts, enabling the model to focus on target regions in unclear conditions. Morphological correction and attention enhancement modules further refine the contour features, and multi-scale fusion effectively integrates global and local context. Extensive experiments on private and public ultrasound datasets demonstrated that the proposed distance-angle-based sequence guidance strategy significantly outperformed existing methods. TGMS-UNet can accurately segment the endometrium in blurred ultrasound images, providing a robust and practical tool for the preliminary evaluation of endometrial function and receptivity, as well as for related clinical applications.
Footnotes
Acknowledgements
The authors express their gratitude to all the institutions and individuals that have provided support for this work.
Ethical considerations
This retrospective study was approved by the Institutional Review Board of the Affiliated Changsha Central Hospital (approval number KY-2023-156-01) with a waiver of informed consent due to the retrospective nature.
Author contributions
Qiao Wei: Writing – original draft, Visualization, Validation, Formal analysis, Data curation; Xiaowen Liang: Resources, Investigation, Conceptualization, Data curation; Yanfen Zhang: Resources, Project administration, Supervision; Zhili Guo and Qing Zhang: Resources, Project administration, Data curation; Zhang Xiao: Methodology, Investigation; Yaocheng Xiao: Supervision, Resources, Project administration; Hong Yu: Investigation, Project administration; Xiaoyan Kui: Writing – review & editing, Supervision, Methodology; Zhiyi Chen: Writing – review & editing, Supervision, Methodology, Investigation, Funding acquisition.
Funding
The authors disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the National Natural Science Foundation of China (82102054), Clinical Research 4310 Program of the Affiliated Changsha Central Hospital of the University of South China (20214310NHYCG06), and Health Research Project of Hunan Provincial Health Commission (W20241010).
Declaration of conflicting interests
The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Data Availability Statement
Guarantor
ZC.
