Background and objectivesThe lens is one of the important refractive media in the eyeball. Abnormality of the nucleus or cortex in the lens can lead to ocular disorders such as cataracts and presbyopia. To achieve an accurate diagnosis, segmentation of these ocular structures from anterior segment optical coherence tomography (AS-OCT) is essential. However, weak-contrast boundaries of the object in the images present a challenge for accurate segmentation. The state-of-the-art (SOTA) methods, such as U-Net, treat segmentation as a binary classification of pixels, which cannot handle pixels on weak-contrast boundaries well. MethodsIn this paper, we propose to incorporate shape prior into a deep learning framework for accurate nucleus and cortex segmentation. Specifically, we propose to learn a level set function, whose zero-level set represents the object boundary, through a convolutional neural network. Moreover, we design a novel shape-based loss function, where the shape prior knowledge can be naturally embedded into the learning procedure, leading to improvement in performance. We collect a high-quality AS-OCT image dataset with precise annotations to train our model. ResultsAbundant experiments are conducted to verify the effectiveness of the proposed framework and the novel shape-based loss. The mean Intersection over Unions (MIoUs) of the proposed method for lens nucleus and cortex segmentation are 0.946 and 0.957, and the mean Euclidean Distance (MED) measure, which can reflect the accuracy of the segmentation boundary, are 6.746 and 2.045 pixels. In addition, the proposed shape-based loss improves the SOTA models on the nucleus and cortex segmentation tasks by an average of 0.0156 and 0.0078 in the MIoU metric and 1.394 and 0.134 pixels in the MED metric. ConclusionWe transform the segmentation from a classification task to a regression task by making the model learn the level set function, and embed shape information in deep learning by designing loss functions. This allows the proposed method to be more efficient in the segmentation of the object with weak-contrast boundaries. Concise abstractWe propose to incorporate shape priors into a deep learning framework for accurate nucleus and cortex segmentation from AS-OCT images. Specifically, we propose to learn a level set function, where the zero-level set represents the boundary of the target. Meanwhile, we design a novel shape-based loss function in which additional convex shape prior can be embedded in the learning process, leading to an improvement in performance. The IOUs for nucleus and cortex segmentation are 0.946 and 0.957, while the MED that reflects the accuracy of the boundary are 6.746 and 2.045 pixels. The proposed shape-based loss improves the SOTA model for nucleus and cortex segmentation by an average of 0.0156 and 0.0078 in IOU, and 1.394 and 0.134 pixels in MED. We transform segmentation from classification to regression by making the model learn a level set function, resulting in improved performance at the boundary with weak contrast.