A semantic guidance and geometric constraint combined driving thyroid nodule segmentation method

By combining the improved U-Net network model with the level set energy function, employing an attention gating module and a composite loss function, and incorporating a deep learning probability guide term, high-precision and robust segmentation of thyroid nodule ultrasound images was achieved. This solved the problems of blurred boundaries and noise sensitivity in existing technologies, and improved the segmentation effect.

CN121962176BActive Publication Date: 2026-07-21TONGJI HOSPITAL ATTACHED TO TONGJI MEDICAL COLLEGE HUAZHONG SCI TECH
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TONGJI HOSPITAL ATTACHED TO TONGJI MEDICAL COLLEGE HUAZHONG SCI TECH
Filing Date
2026-04-01
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing technologies for segmenting thyroid nodules using ultrasound images suffer from problems such as blurred boundaries, artifact interference, high false positive rates, and poor robustness. In particular, traditional methods cannot effectively combine semantic understanding and geometric constraints, resulting in insufficient segmentation accuracy.

Method used

By combining an improved U-Net network model with a level set energy function, and by embedding an attention gating module and a composite loss function, adaptively weighted features, and combining deep learning probabilistic guidance terms, subpixel-level accurate segmentation of nodules is achieved.

Benefits of technology

It significantly improves the accuracy and robustness of boundary localization in thyroid nodule segmentation, solves the segmentation ambiguity and noise sensitivity problems existing in the prior art, and provides higher recall and boundary accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121962176B_ABST
    Figure CN121962176B_ABST
Patent Text Reader

Abstract

The application discloses a kind of semantic guidance and geometric constraint combined driving's thyroid nodule segmentation method, belong to medical image analysis technical field, including: constructing thyroid nodule segmentation dataset, division training set, verification set and test set;Attention gate module is embedded in the skip connection of U-Net encoder and decoder, and the loss value is calculated using the composite loss function of Dice loss, Focal loss and boundary loss weighting, to construct improved U-Net network model;Deep learning probability guide item is introduced to construct level set energy function;Improved U-Net network model and level set energy function are fused;Training set, verification set and test set are used to train the fusion model;After training is completed, input to be measured image, and output to obtain thyroid nodule detection segmentation result.The application provides high-quality initial segmentation contour by improved U-Net, and the smoothness and accuracy of nodule boundary recognition are improved by further optimizing boundary of customized level set energy function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image analysis technology, and in particular to a thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints. Background Technology

[0002] Thyroid nodules are one of the most common thyroid diseases in clinical practice, and early identification and accurate diagnosis of benign or malignant nodules are crucial for clinical treatment decisions. Ultrasound imaging, due to its non-invasive, real-time, and low-cost advantages, has become the preferred imaging method for thyroid nodule screening and evaluation. However, ultrasound image interpretation heavily relies on the experience and subjective judgment of radiologists, resulting in problems such as high workload and low diagnostic consistency. Therefore, developing deep learning-based computer-aided diagnosis (CAD) technology to achieve automatic and accurate segmentation of thyroid nodules has significant clinical value in improving diagnostic efficiency and standardizing evaluation procedures.

[0003] Currently, the technical approach to achieving the above goals mainly relies on deep learning models, but existing methods still have significant limitations. Specifically, these limitations are reflected in the following two aspects: At the first level, while semantic segmentation models based on encoder-decoder architectures (such as U-Net) have become mainstream, their inherent limitations restrict their application in precise clinical measurements. Firstly, their segmentation boundaries exhibit blurring and jagged edges. This stems from the fact that standard segmentation loss functions (such as Dice loss) primarily optimize the overall overlap of regions, lacking direct constraints on the geometric accuracy of boundary pixels, making it difficult for the model to generate smooth boundaries that meet clinical requirements. Secondly, the model is insufficient in suppressing complex background interference in ultrasound images. The indiscriminate feature fusion mechanism of skip connections transmits background noise and artifacts (such as acoustic shadowing and posterior enhancement effects) from the encoder to the decoder, leading to an increased false positive rate. Finally, the extreme imbalance between foreground (nodule) and background pixels makes model training prone to bias towards the background class, resulting in insufficient recall for difficult samples such as small nodules or ground-glass nodules.

[0004] Secondly, while traditional level sets and other geometry-driven models can generate geometrically accurate boundaries, they cannot independently solve the aforementioned problems and even introduce new challenges. These methods heavily rely on the placement of the initial contour; even small deviations in the initial position can easily cause the evolution process to get stuck in local optima and fail. Simultaneously, their evolutionary dynamics depend on the local gradients of the image, making them extremely sensitive to the inherent speckle noise of ultrasound images, and the contour is prone to leakage or distortion under noise interference. More fundamentally, traditional level sets completely lack semantic understanding of the image, failing to distinguish between similar structures such as nodules and blood vessels, resulting in poor robustness in complex applications.

[0005] In summary, the core bottleneck of existing technologies lies in the disconnect between semantic understanding and geometric localization: deep learning models excel at semantic extraction but are weak in precise boundary localization; while level set models are adept at geometric contour evolution but lack high-level semantic guidance. This fundamental contradiction severely restricts the breakthrough and application of automated thyroid nodule segmentation technology in clinical practice. Therefore, there is an urgent need in this field for an innovative solution that can deeply integrate semantic understanding and geometric constraints, aiming to simultaneously improve recall, boundary accuracy, and robustness. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a method for segmenting thyroid ultrasound images for nodules with high segmentation accuracy and precise boundary localization. Specifically, this invention aims to solve the problems of insufficient accuracy and poor robustness of traditional segmentation methods caused by low contrast, blurred boundaries, and artifact interference in ultrasound images, and particularly provides a technical solution that can achieve sub-pixel-level precise segmentation of nodules.

[0007] According to one aspect of the present invention, a thyroid nodule segmentation method jointly driven by semantic guidance and geometric constraints is provided, comprising: acquiring thyroid images to construct a thyroid nodule segmentation dataset, dividing the dataset into a training set, a validation set, and a test set; constructing an improved U-Net network model, wherein the improved U-Net network model uses U-Net as a baseline model, embedding an attention gating module at each skip connection between the U-Net encoder and decoder, and calculating the loss value using a composite loss function of weighted summation of Dice loss, Focal loss, and boundary loss, wherein the attention gating module uses the high-level semantic features of the decoder as a gating signal to adaptively weight the shallow features transmitted by the encoder; introducing a deep learning probabilistic guidance term to construct a level set energy function, wherein the deep learning probabilistic guidance term... The term represents the negative value of the predicted probability of all pixels within the probability map output by the improved U-Net network model. By minimizing the level set energy function, the sum of probabilities of pixels within the contour is maximized. The improved U-Net network model is combined with the level set energy function to obtain a fusion model. The improved U-Net network model is used to initially locate the main region of the nodule and generate the initial contour of the nodule and the probability map of the confidence that each pixel belongs to the nodule. The level set energy function is used to perform sub-pixel-level boundary evolution on the initial contour and probability map of the nodule, and further output the segmentation result. The fusion model is trained and evaluated using a training set, a validation set, and a test set. After training, the image to be tested is input into the trained fusion model, and the thyroid nodule detection and segmentation result is output.

[0008] Optionally, in the improved U-Net network model, the encoder consists of four downsampling stages, each containing two 3×3 convolutional layers and a 2×2 max pooling layer, with each convolutional layer followed by a ReLU activation function; the decoder is symmetrical to the encoder and consists of four upsampling stages, each upsampling stage performing upsampling through transposed convolution or bilinear interpolation, then concatenating the feature maps passed from the corresponding stage of the encoder through skip connections, and finally passing through two 3×3 convolutional layers.

[0009] Optionally, the attention gating module simultaneously receives shallow feature maps from the encoder and deep feature maps from the decoder. The deep feature maps from the decoder are processed through a 1×1 convolution and a Sigmoid activation function to generate a gating signal. The gating signal feature map is then element-wise added to the shallow feature map from the encoder to achieve information fusion. The fused feature map is then activated by a ReLU function to introduce non-linearity. The result of the ReLU activation is then convolved again with a 1×1 function to generate a single-channel preliminary attention map. This preliminary attention map is input into a Sigmoid activation function for normalization, generating a spatial dimension attention weight map.

[0010] Optionally, the formula for the composite loss function is: In the formula, Total loss; For Dice's loss; Focal loss; For boundary loss; , Here, are the weighting coefficients; , To predict the sum of all elements in the probability graph, It is the sum of all elements in the actual tag. This represents the sum of the element-wise products of the prediction and the true label. It is a smoothing constant; , It is the model's predicted probability of the true class. For focusing parameters; , The signed distance graph represents the true segmentation mask G, where the absolute value represents the distance to the boundary. It is the nodule probability predicted by the improved U-Net network model.

[0011] Optionally, a level set energy function constructed using deep learning probability guidance terms can be introduced. for: In the formula, It is a level set function; It is a length constraint term used to constrain the length of the profile; It is an area constraint that drives the contour to move inward or outward; For deep learning probability guidance terms; These are the weighting coefficients of the length constraint term; These are the weighting coefficients for the area constraint term; These are the weight coefficients of the deep learning probability guidance term; the deep learning probability guidance term It is inversely proportional to the predicted probability in the probability graph, as expressed by the formula: In the formula, It is a two-dimensional coordinate vector used to locate each pixel in the image. It is the spatial domain of the entire two-dimensional ultrasound image. It is the probability graph output by the improved U-Net network model. It's the Heaviside function. It is defined in the image domain The level set function on the surface is also represented as the segmentation contour in the evolution.

[0012] Optionally, the calculation formulas for the length constraint and the area constraint are as follows: ; In the formula, This is the gradient operator.

[0013] Optionally, the workflow of the fusion model includes: locating the main nodule region from the input image using an improved U-Net network model, generating the initial contour of the nodule and a probability map of the confidence score of each pixel in the image belonging to the nodule; and using the boundary of the binarized initial segmentation result output by the improved U-Net network model as the level set function. The initial zero level set; the level set function is iteratively updated using gradient descent. Minimize energy When the energy function converges or reaches the maximum number of iterations, the iteration stops, and the zero level set at this point is the final partition boundary of the nodule.

[0014] Optionally, during the training of the fusion model, the input size of the image is set to 512*512, the Adam optimizer is used, the initial learning rate is set to 1e-4, the training cycle is 100, and the batch size is 32. Every 10 training cycles, the performance is evaluated on the validation set. If the loss value of the validation set decreases less than a preset threshold for 5 consecutive cycles, the learning rate is halved.

[0015] According to one aspect of the present invention, an electronic device is provided, the electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the semantically guided and geometrically constrained jointly driven thyroid nodule segmentation method as described above.

[0016] According to one aspect of the present invention, a storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the semantically guided and geometrically constrained thyroid nodule segmentation method as described above.

[0017] The beneficial effects of this invention are: (1) Innovation of the system strategy: The present invention adopts a two-stage strategy of "coarse segmentation + fine optimization". This strategy is not a simple superposition of existing technologies, but a deeply coupled system solution. Among them, the improved U-Net is responsible for providing high-quality initial segmentation contours, solving the problem of the dependence of the level set method on initialization; while the customized level set model is specifically used to optimize the boundary, solving the inherent boundary segmentation ambiguity problem of deep learning models. The two work together to produce excellent technical effects that cannot be achieved by a single method.

[0018] (2) Improvement of model structure: The attention gating mechanism embedded in the improved U-Net network model can adaptively focus on the nodule region, effectively suppress the interference of ultrasound artifacts and complex backgrounds, and significantly improve the accuracy of initial segmentation.

[0019] (3) Robustness of the optimization algorithm: The level set optimization algorithm introduces a deep learning probabilistic graph as a guiding term, making its evolution process insensitive to the initial contour position and less likely to fall into local optima due to image noise. This effectively overcomes the defects of traditional methods, and the final boundary obtained is significantly improved in terms of smoothness and accuracy, making it highly suitable for precise clinical measurement and follow-up. Attached Figure Description

[0020] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is a flowchart of a thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints, provided in an embodiment of the present invention. Figure 2 This is a schematic diagram of the improved U-Net network model structure; Figure 3 This is a structural diagram of the attention gating mechanism; Figure 4This is the energy function structure diagram of the level set; Figure 5 These are the original ultrasound image and the actual segmentation image of the thyroid gland. Detailed Implementation

[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.

[0022] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0023] The terms “comprising” and “having”, and any variations thereof, in the specification and claims of this application are intended to cover non-exclusive inclusion, for example, a process, method, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.

[0024] This invention provides a thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints (wherein, semantic guidance corresponds to an improved U-Net, and geometric constraints correspond to level set energy function boundary optimization). The method provided in this embodiment can be executed on a server, computer, mobile phone, or similar computing device.

[0025] Reference Figure 1 The method includes the following steps: Step 1: Construct a thyroid nodule segmentation dataset and divide it into training, validation, and test sets; The training set is used to train the model, the validation set is used to tune the model's hyperparameters and evaluate its capabilities, and the test set is used to test the model's accuracy and feasibility. Specifically, S1 includes: Step 1.1: Collect thyroid ultrasound images; Images can be sourced from the internet, hospitals, schools, or relevant research institutions, and the collected images should cover as many different types of thyroid nodules as possible. After removing invalid images, the collected dataset is integrated with the open-source dataset (TN3K).

[0026] Among them, the TN3K dataset is a typical open-source thyroid ultrasound dataset in academia.

[0027] Step 1.2: Label the images in the dataset and divide the dataset into training, validation and test sets; The LabelMe software was used to annotate the images (including nodules and background). Pixel-level semantic segmentation annotation was performed on the integrated dataset to generate the gold standard required for model training. The annotation specifications clearly define the criteria for distinguishing nodules from the background, especially for complex cases such as blurred boundaries and adhesion to surrounding tissues. After annotation, the dataset was divided into training, validation, and test sets in a ratio (e.g., 7:1.5:1.5).

[0028] Step 1.3: Perform data augmentation on the dataset; To improve the model's generalization ability and robustness and prevent overfitting, online data augmentation is performed on the input images during training. Random horizontal flipping, random rotation, random scaling, and elastic deformation are employed to increase the spatial diversity of the data.

[0029] Step 2: Construct an improved U-Net network model; By comprehensively considering and comparing various current semantic segmentation model architectures, this invention selects U-Net as the baseline model for improvement. Its symmetrical encoder-decoder structure and skip connection design have been widely verified to be suitable for medical image segmentation tasks, and it is particularly good at processing thyroid ultrasound images with variable target scales and blurred boundaries.

[0030] The improvements to the U-Net network core in this invention are in two aspects: First, an attention gating module is embedded at each jump connection. This module uses the high-level semantic features of the decoder as gating signals to generate a spatial attention weight map, which adaptively weights the shallow features transmitted by the encoder, thereby enhancing the feature response of the nodule target region and suppressing irrelevant background interference. Second, a composite loss function is used to replace the traditional binary cross-entropy loss. This composite loss function is composed of Dice loss, Focal loss and boundary loss weighted together. It can simultaneously optimize the region overlap, focus on hard-to-separate samples and improve the geometric accuracy of the boundary, ultimately driving the model to obtain more accurate and robust segmentation performance.

[0031] In this invention, the encoder consists of four downsampling stages, each containing two 3×3 convolutional layers (each convolution followed by a ReLU activation function) and a 2×2 max pooling layer. Its function is to progressively extract multi-scale features from the input image and compress the spatial dimensions.

[0032] The decoder, symmetrical to the encoder, also consists of four upsampling stages. Each stage first performs upsampling through transposed convolution or bilinear interpolation, then concatenates the feature maps passed from the corresponding stage in the encoder via skip connections, and finally passes through two 3×3 convolutional layers. Its function is to progressively restore the spatial resolution of the feature maps and accurately locate the target position.

[0033] Skip connections concatenate high-resolution, detailed shallow features from each stage of the encoder with deep, semantically rich features from the corresponding stage of the decoder to assist the decoder in reconstructing the precise localization information of the target.

[0034] The attention gating module simultaneously receives shallow feature maps (rich in detail) from the encoder and deep feature maps (rich in global context) from the decoder. It uses the high-level semantic features of the decoder path as a gating signal (the decoder features are processed by a 1×1 convolution and a sigmoid activation function to generate a gating signal that encodes which regions in the image are important semantic information) to adaptively weight the shallow features passed from the encoder.

[0035] Reference Figure 2 and Figure 3 , Figure 2 This diagram illustrates the improved U-Net network model framework in an embodiment of the present invention. Figure 3 This represents the structural diagram of the attention gating mechanism. Furthermore, the above improvements are described in more detail below: 1. At each skip connection between the encoder and decoder, an attention gating module is embedded. This module uses high-level features from the decoder path as the gating signal to generate a spatial attention weight map and adaptively weights the shallow features transmitted by the encoder. The aim is to achieve selective information enhancement during the feature fusion stage, i.e., enhancing feature responses relevant to the nodule target while suppressing interference from irrelevant background features, thereby improving the model's feature discrimination ability in complex ultrasound images. The specific technical steps of this module are as follows: (1) Feature input and alignment: ① Simultaneously receive feature maps from two paths as input: Encoder features ( ): This is a shallow feature map from the current stage of the encoder. It has a high spatial resolution and is rich in detailed information (edges), but weak semantic information.

[0036] Gated signal (G): from the deep feature map of the previous stage of the decoder, which has low spatial resolution but is rich in high-level semantic information (i.e., a global understanding of "where the target may be").

[0037] ② Perform a 1×1 convolution operation on the two feature maps mentioned above to adjust their channel numbers to be consistent for subsequent calculations.

[0038] (2) Gating signal generation and attention weight calculation: ① Add the aligned gate signal feature map to the encoder feature map element by element to achieve information fusion.

[0039] ② The fused feature map is activated by a rectified linear unit (ReLU) activation function to introduce nonlinearity.

[0040] ③ Perform a 1×1 convolution on the result after ReLU activation to compress its channel number to 1, generating a single-channel preliminary attention map.

[0041] ④ Input the initial attention map into the Sigmoid activation function for normalization, and finally generate a spatial attention weight map (Δ). The value range of each pixel in this weight map is [0, 1]. The closer the value is to 1, the greater the probability that the spatial location belongs to the target nodule region, and the higher the importance.

[0042] (3) Feature weighting and output: ① Combine the generated attention weight map (Δ) with the encoder feature map (Δ). Perform element-wise multiplication.

[0043] This operation is equivalent to a spatial filter: features of regions with high weight (suspected nodules) are enhanced; features of regions with low weight (background) are suppressed.

[0044] ② Output the weighted feature map ( =Δ⊙ The corresponding stage of the decoder is then spliced ​​with the upsampled deep features to provide the decoder with cleaned and enhanced detailed information.

[0045] 2. A composite loss function is used for model training to replace the traditional binary cross-entropy loss.

[0046] The composite loss function is composed of Dice loss, Focal loss, and boundary loss weighted according to predetermined weights. Its design aims to synergistically optimize several key performance indicators: Dice loss ensures the overall overlap of segmented regions; Focal loss uses a modulation factor to focus training on difficult-to-distinguish boundary pixels and easily confused samples, alleviating class imbalance; and boundary loss directly constrains the geometric fit between the predicted contour and the true contour. These three factors work together to drive the model to achieve better overall performance. The specific technical steps of this composite loss function are as follows: (1) Define the loss function: The composite loss function is composed of a weighted sum of three independent loss terms, and its mathematical expression is defined as follows: ; in, The Dice loss term primarily optimizes the overlap area (Dice coefficient) between the predicted segmented region and the real region, thus optimizing the overall overlap of the region and serving as a fundamental metric for image segmentation tasks. The Focal loss term introduces a modulation factor on top of the standard cross-entropy loss to dynamically reduce the loss weight of easily classified samples (uniform background). This is used to solve the class imbalance problem between foreground (nodules) and background pixels, making the model pay more attention to difficult-to-classify samples (nodule boundary pixels). The boundary loss term is calculated based on the signed distance map of the true boundary. It specifically penalizes the distance error between the predicted boundary and the true boundary, and is used to drive the model to optimize the segmentation accuracy of boundary pixels and improve the geometric accuracy of the segmentation boundary. and This is a hyperparameter used to balance the contribution weights (i.e., weighting coefficients) of each loss term. In a preferred embodiment of the invention, it has been experimentally verified to be set as follows: =1.0, =0.5.

[0047] (2) Calculate the loss of each item: ① Calculate Dice loss ( ): Input: the probability map P predicted by the model (P can also be understood as the nodal probability predicted by the improved U-Net network model, with a value range of [0, 1]), and the binary mask G of the true label (i.e. the true segmentation mask, with a value range of {0, 1}).

[0048] Calculation formula: ; in, This represents the sum of the element-wise products of the prediction and the true label. and Let represent the sum of all elements in the predicted probability map and the true label, respectively. It is a very small smoothing constant used to prevent division by zero errors.

[0049] ② Calculate Focal loss ( ): Core mechanism: Based on the standard binary cross-entropy (BCE) loss, a dynamic modulation factor is introduced. This factor automatically reduces the loss contribution of easily classified samples (high-confidence background pixels), thus allowing the training process to focus more on difficult-to-classify samples (such as low-confidence nodule boundary pixels).

[0050] Calculation formula: ; in, It is the model's predicted probability of the true class (for positive samples, For negative samples, ). Focusing parameters (usually) ≥0), used to adjust the intensity of the modulation factor.

[0051] ③ Calculate boundary loss ( ): Prerequisite: Pre-compute the signed distance map of the binary mask G of the true labels. The value of each pixel in this image represents the shortest distance from that point to the actual boundary, with positive values ​​inside the boundary and negative values ​​outside.

[0052] Core mechanism: Penalty prediction probability graph P and distance graph The degree of mismatch. Prediction errors (such as a high probability of occurring outside the true boundary) will increase this value.

[0053] Calculation formula: ; This calculation is usually performed by summing or averaging over the entire image space Ω (i.e., the spatial domain of the entire two-dimensional ultrasound image).

[0054] (3) Weighted summation and backpropagation: According to predefined weights and The three loss items are then weighted and summed to obtain the final total loss. ,use Calculate the gradient and update all parameters of the improved U-Net network model using the backpropagation algorithm.

[0055] Step 3: Construct the level set energy function; This invention constructs an innovative level set energy function for accurately optimizing the initial segmentation contours of the improved U-Net output. The innovation of this function lies in its key introduction of a "deep learning probabilistic guide term" on top of the traditional level set framework, thereby combining the advantages of data-driven deep learning semantic information with model-driven geometric active contour models. Figure 4 This is the structure diagram of the energy function of the level set. The definition of is: ; in, Let be a level set function, and let its zero level set be... This represents the outline in the evolution. The function consists of a weighted sum of the following three terms: (1) Length constraint item ; Mathematical definition: ;in For the Heaviside function, This is the gradient operator.

[0056] Physical meaning: This item calculates the current contour. =0 to the total length.

[0057] Function: As a regularization term, its role is to maintain the smoothness of the contour during evolution, preventing excessive jaggedness or breaks in the contour. Minimizing this term drives the contour length to shorten, tending towards smoothness. Coefficient Weights that control the smoothness of the contour.

[0058] (2) Area constraint terms ; Mathematical definition: ; Physical meaning: This item calculates the current contour. =0 is the area inside the zero.

[0059] Function: As a driving force, it provides the intrinsic power for contour contraction or expansion. The direction of contour evolution can be controlled by setting the sign of its coefficient. Coefficient Control the intensity of the driving force.

[0060] (3) Probabilistic guidance term for deep learning ; Mathematical definition: ; Input source: The probability map output by the improved U-Net network model, where each pixel value This indicates the confidence level that the point belongs to a nodule (range [0,1]).

[0061] Physical significance and innovation mechanism: The probability map output by the improved U-Net network model determines the evolution of the level set contour, ensuring that it is driven not only by local image gradients but also by global semantic information (high-probability regions) provided by the deep learning model. (Integral interior) This represents summing the predicted probabilities of all pixels within the current contour. The negative sign before the integral indicates minimizing the energy. This is equivalent to maximizing the sum of probabilities of pixels inside the contour. When the points inside the contour... Corresponding probability When the value is high, the value of this deep learning probability-guided term decreases, thus reducing the total energy. The system tends to include high-probability points within the contour. Therefore, the physical meaning of this term is as a "semantic gravity field": driving the evolving contour to contract inward to enclose the high-confidence (high-probability) nodule regions that U-Net considers high-confidence, while excluding low-probability regions (background) from the contour. (Coefficient) Control the strength of U-Net semantic information in guiding contour evolution.

[0062] The process for solving the above level set evolution is as follows: Minimize the energy function using gradient descent. The corresponding level set evolution partial differential equation is obtained; the finite difference method is used for numerical solution, the time step Δt is set to 0.1, the spatial step is set to Δx=Δy=1, the number of iterations is set to 100, and the process automatically stops when the contour change is less than a certain threshold (0.1 pixels) or when the number of iterations is reached.

[0063] Workflow summary: ① Initialization: The boundary of the binarized initial segmentation result output by the improved U-Net is used as the level set function. The initial zero level set.

[0064] ②Evolution: Iterative updates via gradient descent. , making the total energy It continues to decline.

[0065] ③ Convergence: When the energy function converges (the decrease is less than the preset threshold) or reaches the maximum number of iterations, the zero level set at this time is the optimized precise segmentation boundary.

[0066] Step 4: Deeply couple the improved U-Net network model with the innovative level set energy function to construct an end-to-end fusion model for accurate thyroid nodule segmentation; This integration is not a simple connection, but a collaborative and organic whole.

[0067] ① Improved U-Net network model: This model acts as both a primary segmenter and a semantic perceptron. Its core task is to quickly and accurately locate the main region of a nodule in the input image and generate a high-quality probability map. This probability map encodes the model's confidence that each pixel in the image belongs to a nodule, providing crucial global semantic prior knowledge for subsequent optimization.

[0068] ② Level set energy function: Acts as a boundary optimizer. Its core task is to receive the initial contour and probability map provided by the improved U-Net, perform sub-pixel level fine boundary evolution, and output smooth and accurate segmentation results.

[0069] Step 5: Determine the model training parameters, input the training set, validation set, and test set images into the fused network model for training (and validation and testing), and obtain the trained fused model; In some embodiments of this invention, the input image size is set to 512*512, the Adam optimizer is used, and the initial learning rate is set to 1e-4. Training is performed for 100 epochs, with the batch size set to 32 due to GPU memory limitations. Performance is evaluated on the validation set every 10 epochs. If the validation set loss no longer decreases or decreases less than a preset threshold for 5 consecutive epochs, the learning rate is halved. After multiple iterations, the loss value tends to stabilize, and the network parameter model at this point is saved.

[0070] Step 6: Use the trained fusion model to segment and detect thyroid nodules.

[0071] In the actual segmentation process, the detected thyroid ultrasound image is input into the trained fusion model to obtain the initial contour and probability map of the thyroid nodule segmentation. These two are then optimized using level sets to obtain the final segmentation contour of the nodule. (Refer to...) Figure 5 , Figure 5 This indicates the segmentation effect of this method; thyroid nodules were identified in the image.

[0072] This invention uses the standard U-Net (encoder-decoder architecture) as the baseline model, embedding an attention gating module at each skip connection. Simultaneously, to collaboratively optimize the overlap of segmented regions, address class imbalance, and improve boundary localization accuracy, a composite loss function is employed for end-to-end optimization during model training. This composite loss function is composed of a weighted average of Dice loss, Focal loss, and boundary loss, driving model learning from three dimensions: overall region, difficult and easy samples, and edge pixels, respectively. Furthermore, an innovative level set energy function is constructed. In addition to traditional length constraints and image gradient terms, a crucial "deep learning probability guidance term" is introduced, driving the evolving contour to shrink inward to encompass the high-confidence (high-probability) nodule regions identified by U-Net. The improved U-Net network model provides fast and accurate nodule body contours, while also providing global semantic prior knowledge for subsequent level set energy function optimization. The level set energy function further refines the boundary contours; together, these two aspects enhance the smoothness and accuracy of boundary segmentation.

[0073] Furthermore, this embodiment also provides an electronic device, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps as described in any of the method embodiments above.

[0074] The electronic device can be a terminal, comprising a processor, memory, communication interface, display screen, and input device connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input device can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the device's casing, or an external keyboard, touchpad, or mouse.

[0075] Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0076] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0077] The sequence numbers of the above embodiments are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The descriptions of each embodiment in the above embodiments have different emphases; for parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0078] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints, characterized in that, include: Thyroid images were acquired to construct a thyroid nodule segmentation dataset, which was then divided into training, validation, and test sets. An improved U-Net network model is constructed. The improved U-Net network model uses U-Net as the baseline model and embeds an attention gating module at each hop connection between the U-Net encoder and decoder. The loss value is calculated using a composite loss function that is a weighted sum of Dice loss, Focal loss and boundary loss. The attention gating module uses the high-level semantic features of the decoder as the gating signal and adaptively weights the shallow features transmitted by the encoder. Multiple key performance indicators are optimized collaboratively through a composite loss function. Specifically, Dice loss is used to ensure the overall overlap of segmented regions, Focal loss is employed to focus training on difficult-to-distinguish boundary pixels and easily confused samples through a modulation factor, and boundary loss directly constrains the geometric fit between the predicted contour and the true contour. The formula for the composite loss function is as follows: ; In the formula, Total loss; For Dice's loss; Focal loss; For boundary loss; , These are the weighting coefficients; in, , To predict the sum of all elements in the probability graph, It is the sum of all elements in the actual tag. This represents the sum of the element-wise products of the prediction and the true label. It is a smoothing constant; , It is the model's predicted probability of the true class. For focusing parameters; , The signed distance graph represents the true segmentation mask G, where the absolute value represents the distance to the boundary. It is the nodule probability predicted by the improved U-Net network model; A deep learning probability guide term is introduced to construct a level set energy function. The deep learning probability guide term is the negative value of the predicted probability of all pixels in the probability map output by the improved U-Net network model. By minimizing the level set energy function, the sum of the probabilities of pixels inside the contour is maximized. The introduction of deep learning probability guidance terms to construct the level set energy function The specific steps are as follows: ; In the formula, It is a level set function; It is a length constraint term used to constrain the length of the profile; It is an area constraint that drives the contour to move inward or outward; For deep learning probability guidance terms; These are the weighting coefficients of the length constraint term; These are the weighting coefficients for the area constraint term; These are the weighting coefficients of the probability-guided term in deep learning; The deep learning probability guidance term It is inversely proportional to the predicted probability in the probability graph, as expressed by the formula: ; In the formula, It is a two-dimensional coordinate vector used to locate each pixel in the image. It is the spatial domain of the entire two-dimensional ultrasound image. It is the probability graph output by the improved U-Net network model. It's the Heaviside function. It is defined in the image domain The level set function on the surface is also represented as the segmentation contour in the evolution; The improved U-Net network model is combined with the level set energy function to obtain a fusion model. The improved U-Net network model is used to initially locate the main region of the nodule and generate the initial contour of the nodule and the probability map of the confidence of each pixel belonging to the nodule. The level set energy function is used to perform sub-pixel-level boundary evolution on the initial contour of the nodule and the probability map, and further output the segmentation result. The fusion model is trained and evaluated using a training set, a validation set, and a test set. After training, the image to be tested is input into the trained fusion model, and the output is the thyroid nodule detection and segmentation result.

2. The thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints according to claim 1, characterized in that, In the improved U-Net network model, the encoder consists of four downsampling stages, each of which contains two 3×3 convolutional layers and a 2×2 max pooling layer, with each convolutional layer followed by a ReLU activation function. The decoder is symmetrical to the encoder and consists of four upsampling stages. Each upsampling stage upsamples through transposed convolution or bilinear interpolation, and then concatenates the feature maps passed from the corresponding stage of the encoder through skip connections. Finally, it goes through two 3×3 convolutional layers.

3. The thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints according to claim 1, characterized in that, The attention gating module simultaneously receives shallow feature maps from the encoder and deep feature maps from the decoder. It generates a gating signal by passing the deep feature map from the decoder through a 1×1 convolution and a sigmoid activation function. Then, it adds the gating signal feature map element-wise with the shallow feature map from the encoder to achieve information fusion. The fused feature map is then activated by the ReLU function to introduce nonlinearity. The result after ReLU activation is convolved again with 1×1 to generate a single-channel preliminary attention map. The preliminary attention map is then input into the Sigmoid activation function for normalization to generate a spatial attention weight map.

4. The thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints according to claim 1, characterized in that, The calculation formulas for the length constraint and the area constraint are as follows: ; In the formula, This is the gradient operator.

5. The thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints according to claim 1, characterized in that, The workflow of the fusion model includes: An improved U-Net network model is used to locate the main region of nodules from the input image, and to generate the initial contour of the nodules and the probability map of the confidence that each pixel in the image belongs to a nodule. The boundary of the binarized initial segmentation result output by the improved U-Net network model is used as the level set function. The initial zero level set; The level set function is updated iteratively using gradient descent. Minimize energy ; When the energy function converges or reaches the maximum number of iterations, the iteration stops, and the zero level set at this point is the final partition boundary of the nodule.

6. The thyroid nodule segmentation method driven by a combination of semantic guidance and geometric constraints according to claim 1, characterized in that, During the training of the fusion model, the input image size is set to 512*512, the Adam optimizer is used, the initial learning rate is set to 1e-4, the training epochs are 100, and the batch size is 32. Every 10 training epochs, the performance is evaluated on the validation set. If the loss value on the validation set decreases less than a preset threshold for 5 consecutive epochs, the learning rate is halved.

7. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the semantically guided and geometrically constrained thyroid nodule segmentation method as described in any one of claims 1 to 6.

8. A storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the steps of the semantically guided and geometrically constrained thyroid nodule segmentation method as described in any one of claims 1 to 6.