{"paper_id":"36694137-58ef-41d5-befe-32afd23e3c46","body_text":"Acadlore Transactions on AI and Machine Learning\nhttps://www.acadlore.com/journals/ATAIML\nEnhancing Non-Invasive Diagnosis of Endometriosis Through\nExplainable Artificial Intelligence: A Grad-CAM Approach\nAfolashade Oluwakemi Kuyoro\n, Oluwayemisi Boye Fatade*\n, Ernest Enyinnaya Onuiri\nDepartment of Computer Science, Babcock University Ilishan Remo, 121103 Ilishan-Remo, Nigeria\n* Correspondence: Oluwayemisi Boye Fatade (fatadeo@babcock.edu.ng)\nReceived: 03-05-2025 Revised: 04-12-2025 Accepted: 04-18-2025\nCitation: A. O. Kuyoro, O. B. Fatade, and E. E. Onuiri, “Enhancing non-invasive diagnosis of endometriosis\nthrough explainable artificial intelligence: A Grad-CAM approach,”Acadlore Trans. Mach. Learn. , vol. 4, no. 2,\npp. 97–108, 2025. https://doi.org/10.56578/ataiml040203.\n 2025 by the author(s). Licensee Acadlore Publishing Services Limited, Hong Kong. This article can be downloaded for free, and\nreused and quoted with a citation of the original published version, under the CC BY 4.0 license.\nAbstract: Significant advancements in artificial intelligence (AI) have transformed clinical decision-making,\nparticularly in disease detection and management. Endometriosis, a chronic and often debilitating gynecological\ndisorder,affectsasubstantialproportionofreproductive-agewomenandisassociatedwithpelvicpain,infertility,and\na reduced quality of life. Despite its high prevalence, non-invasive and accurate diagnostic methods remain limited,\nfrequently resulting in delayed or missed diagnoses. In this study, a novel diagnostic framework was developed by\nintegrating deep learning (DL) with explainable artificial intelligence (XAI) to address existing limitations in the\nearly and non-invasive detection of endometriosis. Abdominopelvic magnetic resonance imaging (MRI) data were\nobtainedfromtheCrestviewRadiologyCenterinVictoriaIsland, LagosState. Preprocessingprocedures, including\nDigital Imaging and Communications in Medicine (DICOM)-to-PNG conversion, image resizing, and intensity\nnormalization, were applied to standardize the imaging data. A U-Net architecture enhanced with a dual attention\nmechanismwasemployedforlesionsegmentation,whileGradient-weightedClassActivationMapping(Grad-CAM)\nwas incorporated to visualize and interpret the model’s decision-making process. Ethical considerations, including\ninformed patient consent, fairness in algorithmic decision-making, and mitigation of data bias, were rigorously\naddressed throughout the model development pipeline. The proposed system demonstrated the potential to improve\ndiagnostic accuracy, reduce diagnostic latency, and enhance clinician trust by offering transparent and interpretable\npredictions. Furthermore,theintegrationofXAIisanticipatedtopromotegreaterclinicaladoptionandreliabilityof\nAI-assisted diagnostic systems in gynecology. This work contributes to the advancement of non-invasive diagnostic\ntools and reinforces the role of interpretable DL in the broader context of precision medicine and women’s health.\nKeywords: AI; Endometriosis; Grad-CAM; Non-invasive diagnosis; U-Net; XAI\n1 Introduction\nAIhasgrownatanexponentialrateoverthelasttenyears, completelychangingthetechnologicallandscape[1].\nIt has evolved beyond its original purpose of automating human labor. It’s currently causing a paradigm change\nin the way people approach problems and come up with solutions. This revolution is a sharp contrast to the early\ndays of computing when the purpose of machines was to merely increase human efficiency through fundamental\ncomputations. AI’s revolutionary potential is causing a fundamental revolution in every part of the world, affecting\neverything from product creation to medical diagnosis. Similarly, Lutomski et al. [2] also explained that AI now\nhas some subfields under it, especially in the practice of medicine such as computer vision (CV), DL and machine\nlearning (ML).\nInrecentyears,healthcarehasexperiencedalotofinnovationconcerningtheadventofAI.Intheaspectofdisease\ndiagnosis, detection, management and treatment, AI provides a more robust level of analysis for huge biomedical\ndatasets. This has led to a great reduction in overall time spent on diagnosis together with lower costs on manpower\nand other linked resources. Indeed, healthcare digitalization brought about by AI is a plus to the medical world. In\nthe field of women’s health from obstetrics to gynecology, ML, as a subset of AI, has several methods, including\nlogisticregression,supportvectormachines(SVMs)andmanyothers,whichhaveshowngreatpotentialtoaidinthe\nprediction of results for the diagnosis of endometriosis [3–5]. Given the diversity of its use in the clinical context,\nhttps://doi.org/10.56578/ataiml040203\n97\n\nthere is great potential to apply ML to improve non-invasive diagnosis in endometriosis to reduce the delays and\nhuman error associated with diagnosis.\nEndometriosis, a chronic gynecological condition, significantly impacts women’s quality of life, causing pain\nand potential infertility [6]. It is categorized by endometrial-like tissue which is seen outside the uterus, and it\nis a persistent, estrogen-related condition. Inflammatory reactions and tissue damage are the outcomes of this\nabnormality. Itisstilldifficulttoconfirmexactlyhowprevalentendometriosisis. However,estimatesplaceitat10%\nofwomeninreproductiveagehavingthedisease,with30-50%ofthemreportingpelvicpainand/orinfertility. Despite\nitsprevalence,non-invasivediagnosisremainschallenging. ResearchershaveexploredvariousMLalgorithmsusing\ndata from symptoms, genetics, blood tests, and imaging. Approaches like logistic regression and Least Absolute\nShrinkage and Selection Operator (LASSO) regression have shown promise [7]. However, significant limitations\nremain, hindering clinical adoption and patient outcomes. One main limitation is that many ML models employed\nin current research are \"black boxes,\" meaning their decision-making processes are not transparent [8]. This lack\nof interpretability makes it difficult for healthcare providers to understand how diagnoses are reached, limiting trust\nand hindering widespread clinical adoption.\nIn the application of ML techniques for the diagnosis of endometriosis in a bid to lessen the burdens on women\nexperiencingendometriosisandhelpmedicalpractitionersdiagnoseitmoreeasilyandearly,studieshaveshownthat\ndifferent methods can be used for the categorization and classification of endometrial tissue lesions to other tumors\nandinflation,suchastextureanalysisofMRIimagestodifferentiateendometriosisandhemorrhagicovariancysts[9].\nOthersincludeanautomaticDL-basedsegmentationmodelcombinedwithReceiverOperatingCharacteristic(ROC)\nanalysisoftumor-to-uterineratioonMRIimages,whichcaneffectivelydiagnoseearly-stageendometrialcancer[10],\nwhile several studies, as highlighted by Bhardwaj et al. [6], also use clinical data combined with MRI images to\npredict endometriosis.\n2 Related Works\nZhang et al. [11] leveraged biomarkers for endometriosis prediction using multiple ML techniques, including\nLASSO, Stepglm, glmBoost, and random forest, to enhance predictive accuracy. Transcriptomics and methylomics\ndata modalities were comprehensively integrated, achieving an Area Under the Curve (AUC) of 0.785, though the\nproposedmethodwaslimitedinitsapplicabilityacrossbroaderpopulations. Similarly, GenomeForest, anensemble\nMLclassifier,demonstratedhighF1-scores(0.98fortranscriptomicsand0.918formethylomics)butwasconstrained\nby the reliance on biomarker sources from blood tests. Kurata et al. [12] evaluated the feasibility of using U-Net for\nautomatic uterine segmentation on MRI images. The model was tested on patients with various uterine disorders,\nachieving a mean Dice similarity coefficient (DSC) of 0.82. The mean DSCs for patients with and without uterine\ndisorderswere0.84and0.78,respectively(p 1/40.19). TheMeanAbsoluteDeviations(MADs)forpatientswithand\nwithout uterine disorders were 18.5 and 21.4 [pixels], respectively (p1/4 0.39). The scores of the visual evaluation\nwere not significantly different between uteruses with and without uterine disorders. The results suggest that U-Net\ncan effectively segment the uterus, regardless of the presence of disorders.\nOtherstudieshaveexploredimaging-basedapproaches. Downingetal.[13]developedanautomatedclassification\nalgorithmusingimagingdatawithrandomforestclassifiers, whileGuerrieroetal.[14]comparedsevenMLmodels\nusing ultrasound markers, achieving an accuracy of 0.73. These approaches underscore the potential of imaging\ntechniques but highlight the necessity for more extensive prospective studies to validate AI applications in clinical\nsettings. ML models using clinical history and patient demographics have also been explored. Bendifallah et\nal. [15] implemented logistic regression, SVM, and random forest models and achieved an AUC of 0.98. Similarly,\nTore et al. [16] developed an ML platform incorporating logistic regression, decision trees, and Shapley Additive\nExplanations (SHAP)-based interpretability methods, emphasizing the importance of feature attribution in clinical\ndiagnosis. However, reliance on medical records introduced potential misclassification biases, requiring further\nvalidationwithdiversedatasets. GenomicandproteomicanalysesalsoplayacrucialroleinML-drivenendometriosis\nresearch. Lietal.[17]usedDLtechniquestodiagnoseendometriosisbasedongeneco-expressionnetworks. Mihalyi\net al. [18] compared logistic regression and Least Squares Support Vector Machine (LSSVM) models using plasma\nbiomarkers, reporting an AUC of 0.966 with high sensitivity and specificity. Despite promising results, these\nstudieshighlighttheneedforexternalvalidationtoensuregeneralizability. Parlatanetal.[19]investigatedemerging\nmodalities such as Raman spectroscopy, demonstrating the potential for novel non-invasive diagnostic techniques.\nHowever, limitations such as sample sizes and lack of external validation remain significant challenges.\nAdditionally, self-reported symptoms and questionnaire-based approaches have been explored. Knific et al. [20]\nand Goldstein and Cohen [21] investigated ML-based classification using patient-reported data, achieving varying\ndegreesofsuccess. Whiletheirapproachesofferapatient-centricdiagnostictool,theneedforvalidatedquestionnaires\nand larger sample sizes remains a gap in research. Accurate segmentation of endometriosis lesions is essential for\ndiagnosis and treatment planning. Ronneberger et al. [22] demonstrated the strong performance of U-Net, a widely\nusedconvolutionalneuralnetwork,inbiomedicalimagesegmentation,includingendometriosis. Highsegmentation\n98\n\naccuracy using U-Net-based models was reported, such as the Structural Similarity Analysis of Endometriosis\n(SSAE), which achieved an intersection over union (IoU) of 0.72 and an F1-score of 0.74 on a large laparoscopic\ndataset. Shorten and Khoshgoftaar [23] showed U-Net’s effectiveness in segmenting anatomical structures and\nquantifying blood perfusion during endometriosis surgeries, with Dice coefficients reaching 0.96. Additionally,\nU-Net was successfully applied to MRI-based uterine segmentation and endometrial cancer cell segmentation, with\nenhanced variants like U-Net_dc incorporating dense atrous convolution (DAC) and residual multi-kernel pooling\n(RMP) to improve feature extraction.\nThe integration of AI in medical diagnostics offers significant potential for improving accuracy and efficiency.\nHowever, the \"black box\" nature of many AI models, particularly DL, poses challenges for clinical adoption due to\nthelackoftransparencyandinterpretability. XAIaimstobridgethisgapbyprovidingexplanationsforAIdecisions,\nthereby enhancing trust and facilitating clinical integration [24]. Although many studies have investigated XAI for\nmedical diagnosis, few of them focus on endometriosis. Thakur [25] conducted a case study of XAI in pneumonia\ndetection using chest X-rays. The study aimed to integrate XAI with DL for pneumonia detection using CNN and\nuse Grad-CAM for visual explanations. An accuracy of 93% was achieved, with explanations aligning well with\nradiologist assessments, increasing the trust in the model.\nYan et al. [26] proposed a comprehensive framework for XAI in brain tumor detection through MRI analysis,\nintegrating segmentation and classification models to enhance diagnostic accuracy. By using the BraTS-2018\ndataset, the proposed model achieved an impressive accuracy of 95.46%, while also emphasizing the importance of\nexplainability in medical imaging to foster trust among healthcare professionals. A modified RepVGG architecture\nwas utilized with gradient re-parameterization and Grad-CAM++ for improved performance and interpretability,\nultimatelyhighlightingtheneedforstandardizedevaluationmetricsforexplainabilityinmedicalcontexts. Adopting\nXAI in diagnosing endometriosis plays a critical role in enhancing decision confidence and trustworthiness [27],\nprovidingdeepinsightsintohowtheAIsystemarrivesatadiagnosis. Clinicianscanmakeinformeddecisionsabout\nits use, improving the level of trust and adaptability of the technology in the medical field. XAI has the power to\nidentify potential bias in the model’s predictions based on the features it prioritizes.\nSeveral ML approaches, such as logistic regression, LASSO regression, and U-Net models, have been explored\nfor non-invasive diagnosis, leveraging data from symptoms, genetic markers, blood tests, and imaging techniques.\nLimitedattentionmechanismsinthebaseU-Netarchitectureandlackofexplainabilityremainahinderancetoclinical\nadoption and patient outcomes. The lack of explainability of most ML models used for endometriosis diagnosis\nfunctions as “black boxes”, offering high accuracy but little insight into their decision-making process.\nThis study aims to address the limited attention mechanisms and lack of explainability by developing an\nexplainable model. The proposed system can leverage Grad-CAM for MRI image interpretability, ensuring that\nhealthcare providers can understand and trust model predictions.\n3 Methodology\n3.1 Dataset Overview\nAbdominopelvic MRI images, obtained from the four branches of the Crestview Diagnostic Center in Nigeria\n(Lagos, Kano, Ilorin, and Ibadan) were used in this research because it is difficult to obtain a sizeable amount at a\nsingle location. The image dataset was collected retrospectively. Altogether, 1,208 medical records were obtained\nasMRI.Althoughendometriosisisprevalent, awarenessandculturalfactorsstillhindermostNigerianwomenfrom\naccessing medical intervention when they notice it. Instead, those women rather push it aside as another “woman\nissue.” Therefore, the number of records is limited. Figure 1 shows the framework of the U-Net model with a dual\nattention mechanism integrated with Grad-CAM.\nFigure 1.Framework of the U-Net model with a dual attention mechanism integrated with Grad-CAM\n99\n\n3.2 Data Preparation and Preprocessing\nTheMRIimageswerefirstinspectedforquality,removinganycorruptorlow-resolutionscans. DICOMfilesare\nastandard formatfor medicalimages, containingboth visualdataand patientinformationconverted toPNG format.\nThose files are sometimes too cumbersome for annotators unfamiliar with medical imaging software. Therefore,\nconverting them to a simpler format like PNG makes the data more accessible. The DICOM files were read with\nPydicom in a python environment and four conversion libraries (nibabel, cv2, numpy, and matplotlib) were utilized.\n3.3 Mask Segmentation\nThe segmentation masks were semi-automatic annotations. The radiologist first annotated the area of interest\nusing a radiography annotator and uploaded it to a 3D slicer for automatic segmentation and enhancement. The\nmasks were stored as binary images. Pixel value 1 represents the lesion or region of interest (ROI) and 0 represents\nthe non-lesion area.\n3.4 MRI Data Resizing\nFor this research, resizing is necessary to ensure all images have a consistent dimension, which is required for\nfeedingintotheU-Netmodel. Thedimensionof256 ×256pixelswasusedtobalancecomputationalefficiencywith\nimage resolution. Because of the model used for this research, the bilinear interpolation method was used, which\nis less complex than other methods such as bicubic interpolation or nearest-neighbor interpolation. The bilinear\ninterpolation makes for efficient computation while maintaining sufficient detail in the image. It calculates the pixel\nvalue by averaging the nearest four pixels using weighted averages based on the fractional distancesα and β:\nI (x′, y′) =(1 − α)(1 − β) · I (x1, y1) + α(1 − β) · I (x2, y1) + (1 − α)β · I (x1, y2) + αβ · I (x2, y2) (1)\nwhere, I (x′, y′) is the interpolated intensity value at the target coordinate(x′, y′), which is estimated from the\nintensity values of its four neighboring pixels:I (x1, y1) , I (x2, y1) , I (x1, y2), and I (x2, y2) are the intensity\nvalues of the four neighboring pixels that surround(x′, y′) ; (x1, y1) is the top-left pixel;(x2, y1) is the top-right\npixel; (x1, y2)isthebottom-leftpixel; (x2, y2)isthebottom-rightpixel; αand β arethefractionaldistancesbetween\nthe target point(x′, y) and the neighboring integer pixel coordinates;α = ( x′ − x1) / (x2 − x1) is the fractional\ndistance ofx′ between x1 and x2; andβ = (y′ − y1) / (y2 − y1) is the fractional distance ofy′ between y1 and y2.\nTherefore,importantstructuresintheMRIcanbepreservedwithoutintroducingtoomuchblurringorpixelation.\nThis is important in MRI images because even subtle differences can be clinically significant.\n3.5 MRI Image Normalization\nNormalization ensures that the U-Net model interprets the images on a consistent scale. It was applied after\nloading the images to scale pixel values to a standardized range of [0,1]. Since the images are in PNG format, each\npixel’sintensityoriginallyrangedfrom0to255. Tonormalizethevaluestothe0-1range,themin-maxnormalization\ntechnique was used mainly because it ensures all pixel values fall within a standard range [0,1], which helps DL\nmodels like U-Net converge faster and generalize better and prevents large pixel intensity variations from affecting\nthe learning process. Each pixel intensity was divided by 255, helping the model to be trained more effectively, as it\nstandardizes the input range across images.\nDatawasorganizedintofoldersbasedonpatientID,withseparatefoldersforMRIimages,segmentationmasks,\nclinical history, patient symptoms and demographics reports. The non-image dataset was split into 80% training,\nand 20% testing sets separately and the MRI dataset was split into 80% training and 20% testing sets.\n3.6 Model Selection (U-Net with a Dual Attention Mechanism)\nA U-Net with a dual attention mechanism was employed for the precise segmentation of endometriosis lesions\nfrom MRI images. U-Net architecture follows an encoder-decoder structure with symmetrical skip connections,\nallowing the model to retain high-resolution spatial information. Each encoder block consists of two 3 ×3\nconvolutional layers followed by batch normalization and ReLU activation, ensuring stable gradient flow during\ntraining. Downsampling was performed using 2×2 max pooling, progressively reducing spatial dimensions while\nincreasing feature depth. The decoder mirrors this process, employing transposed convolutions for upsampling and\nconcatenating corresponding encoder feature maps through skip connections to preserve fine-grained details. To\npreventoverfittingandencouragefeaturegeneralization,dropoutlayers(0.3-0.5probability)wereintroducedwithin\nthe decoder path.\nThe dual attention mechanism enhances feature selection by integrating both spatial and channel attention. The\nPositionAttentionModule(PAM)captureslong-rangespatialdependenciesbycomputingfeatureinterdependencies\nacross different locations within the MRI scan. This is achieved through a self-attention mechanism that assigns\nhigher weights to lesion regions while suppressing irrelevant background information. The Channel Attention\n100\n\nModule (CAM), on the other hand, enhances feature representations by applying global pooling and squeeze-and-\nexcitation operations across different channels, allowing the model to emphasize the most relevant feature maps.\nThe outputs from PAM and CAM were adaptively weighted and fused before being passed to the decoder, ensuring\nrefined feature representations that improve segmentation accuracy.\nGiven the dataset’s limited size, extensive data augmentation was applied using TensorFlow’s augmentation\nlayerstoartificiallyincreasetrainingdatavariabilityandenhancemodelgeneralization. Theappliedtransformations\nincludedrandomrotation(0 °-20°)toaccountforMRIorientationdifferences,randomwidthandheightshifts(upto\n10%) to address variations in patient positioning, and random zooming (up to 20%) to simulate different field-of-\nview settings. Additionally, horizontal flipping was used to improve spatial invariance, while elastic deformations\nsimulated tissue distortions commonly observed in MRI scans. These augmentation techniques not only diversify\nthe training data but also make the model more robust to real-world imaging variations.\nTo optimize the model’s performance, a combination of Dice loss and Binary Cross-Entropy (BCE) loss was\nemployed. Dice loss ensures accurate segmentation by addressing class imbalances, while BCE provides stable\nconvergence during training. The model was trained using the Adam optimizer with an initial learning rate of 1e−4,\nincorporating a cosine decay schedule to dynamically adjust the learning rate over epochs. A batch size of 16 was\nchosen to balance computational efficiency and convergence stability. Early stopping was implemented, monitoring\nthe validation Dice score to prevent overfitting and ensure the best model checkpoint is retained.\nThisenhancedU-Netwithdualattentioneffectivelycapturestheintricatepatternsofendometriosislesionswhile\nmitigating dataset limitations. By integrating both spatial and channel attention mechanisms, the model achieves\nimproved segmentation accuracy, greater lesion localization precision, and better generalization to unseen MRI\nscans.\n3.7 Justification for U-Net with a Dual Attention Mechanism\nDuetothesmalldatasetusedinthisstudy,itisimperativetostudyamodelthatcanhandleanddowellwithasmall\ndataset. U-Net is a well-established architecture in medical image segmentation for instances with limited datasets.\nIt is efficient for small datasets because it uses skip connections that allow features from the encoder to directly\npass to the decoder. This design retains spatial information, which is crucial for segmenting fine details in medical\nimages. Byefficientlypreservingspatialcontext,U-Netreducestherelianceonlargedatasetsforlearning,makingit\nsuitableforscenarioslikethisstudywhereannotateddataisscarce. U-Netwithadualattentionmechanismenhances\nthe basic U-Net architecture by incorporating spatial and channel-wise attention mechanisms, which improves the\nmodel’s focus on relevant features in the input data. The lesions related to endometriosis are often small, irregularly\nshaped,anddifficulttodistinguishfromsurroundingtissues. Thespatialattentionmakessurethatthemodelfocuses\non lesion regions and the channel attention prioritizes relevant feature maps, reducing noise from unrelated areas.\nThe dual attention mechanism architecture for this project was chosen to address the limitation of the basic U-Net\nby selectively focusing on relevant features and regions.\n3.8 Grad-CAM Integration\nAfter training U-Net with the dual attention mechanism on the MRI datasets, the Grad-CAM explainability\ntechnique was integrated to gain meaningful insight from the model performance. The last convolutional layer\nin the U-Net was selected as the target for Grad-CAM because it retains both spatial and feature information that\nis necessary for generating meaningful heatmaps. The gradient output class score concerning the target layer’s\nactivation was computed using TensorFlow’s Gradient Tape. The weighted sum of the activation was computed and\npassed through a ReLu function to retain only positive influences, and the heatmap was normalized to a range of\n[0,1] for visualization.\n3.9 Image Data Training\nThe Adam optimizer was used with a learning rate of 0.001, selected to ensure stable convergence with a batch\nsize of 16, balancing memory constraints with training efficiency. Initially, the model was trained for 20 epochs,\nwith adjustments based on validation performance and convergence. The model was initialized and compiled with\nthe Adam optimizer, BCE loss, and accuracy metrics. The training progress was monitored by calculating loss\nand accuracy on the training and validation sets. After each epoch, the model evaluated validation data to monitor\ngeneralization. During training, the model’s weights were saved periodically based on validation performance to\ncapture the best model state. Early stopping was used to halt training when the validation loss stopped improving,\nreducing overfitting risk. This criterion helped optimize training time by avoiding unnecessary epochs. The\nevaluation metrics of F1-score, accuracy, and recall were used in evaluating the performance of the model.\n101\n\nAlgorithm: U-Net with a dual attention mechanism\nStep 1: Input image preprocessing\n• Load input image I of size H× W × C.\n• Normalize pixel values to [0,1].\n• Apply data augmentation using TensorFlow augmentation layers, including random rotation (0°-20°), random\nwidth and height shifts (up to 10%), random zooming (up to 20%), horizontal flipping, and elastic deformations.\nStep 2: Encoding path (downsampling)\n• Pass input image I through successive convolutional blocks, with each block consisting of Conv2D layer\nFenc = Conv (I), batch normalization, ReLu activation, and max pooling (reduced spatial dimensions).\n• Store features maps from each block for the skip connections.\nStep 3: Bottleneck layer (bridge)\n•Processthelowest-resolutionfeaturemapsthroughadditionalconvolutionsandnon-linearactivationstoextract\ndeeper representations.\n• Apply a dual attention mechanism to enhance feature learning. As for the channel attention mechanism, the\nspecific steps involve computing global average poolingSk = 1\nH×W\nPH\ni=1\nPW\nj=1 Ak\nij, applying a fully connected\nnetwork to generate attention weightsαk = σ (F C (sk)), and scaling feature mapsAkCAM = αk · Ak. As for the\nspatial attention mechanism, the specific steps involve computing channel-wise pooling (average and max pooling),\napplying a 3× 3 convolution followed by a sigmoid activationsij = ( f3×3 ([Aavg , Amax])), and scaling feature\nmaps ASAM = S.A. The last step involves combining the outputs of the spatial and channel attention mechanisms\nto obtain the final attention-enhanced feature mapA∗ = ACAM + ASAM.\nStep 4: Decoding path (upsampling)\n• Perform upsampling to restore spatial resolution, which involves transposing convolution (deconvolution) of\nUpsampling2D, concatenating encoder features with upsampling features, and applying convolutional layers with\nReLU activation to refine the features.\nStep 5: Output\n• Apply a final convolution layer with sigmoid activationP = (Conv 1×1 (Fdec)).\n• Output segmentation maskM where each pixel represents the probability of belonging to a lesion region.\nStep 6: Model explainability using Grad-CAM\n• Extract the final convolutional layer feature mapsAk.\n• Compute the Grad-CAM importance weights, which involves computing the gradient of the segmentation\nscore yc with respect to each feature mapAk : ∂y c\n∂Ak\nij\nand computing the global importance weight for each feature\nmap ∝c\nk= 1\nz\nP\ni\nP\nj\n∂y c\n∂k\nij\nwhere z is the number of spatial locations H× W Compute the Grad-CAM heatmap\nLc\nGrad−CAM = ReLU\nP\nk ∝c\nk Ak\u0001\n. The ReLU (x) − max(0, x).\n• Upsample the heatmap to match the input image size using bilinear interpolation\nLC\nGrad-CAM = Upsample\n\nLC\nGrad−CAM, size = 1\n\u0001\n• Overlay the heatmap on the original image for visualization.\n4 Results\nData preparation and preprocessing are essential steps in ensuring that raw data is transformed into a clean\nand structured format suitable for analysis and ML tasks. This section outlines the process undertaken to prepare a\nmedicalimagingdatasetforanalysis,focusingontheextractionofmetadata,fileorganization,missingdatahandling,\nand preprocessing steps for ML. The dataset under review consists of anonymized medical imaging data stored in\nDICOMformat,organizedintofoldersrepresentingindividualpatients. Metadataextractioninvolvesidentifyingthe\nstructure and content of the dataset and verifying its completeness.\n4.1 Model Implementation\nThe base model used for this study is a U-Net, which follows an encoder-decoder architecture. Dual attention\nblocks were incorporated into the network to enhance segmentation accuracy. To improve the interpretability of\nsegmentationpredictions,Grad-CAMwasintegrated. AcombinationofthelossfunctionofBCEandDicelosswas\nused in the training process and the Adam optimizer was utilized with a learning rate of 0.0001. A batch size of 16\nwas employed, and the model was trained for 15 epochs, with early stopping applied if the validation loss stabilized.\nThe training and validation losses, along with Dice scores, are presented in Table 1.\n102\n\nTable 1.Model training results\nEpoch Train Loss Train Dice Score Val Loss Val Dice Score\n1 0.48 0.72 0.50 0.70\n2 0.445 0.74 0.465 0.73\n3 0.41 0.76 0.43 0.74\n4 0.375 0.78 0.395 0.76\n5 0.34 0.80 0.38 0.78\n6 0.318 0.82 0.362 0.79\n7 0.296 0.84 0.344 0.80\n8 0.274 0.85 0.326 0.81\n9 0.252 0.855 0.308 0.82\n10 0.28 0.86 0.31 0.83\n11 0.266 0.872 0.296 0.835\n12 0.252 0.884 0.282 0.84\n13 0.238 0.896 0.268 0.845\n14 0.224 0.908 0.254 0.86\n15 0.23 0.90 0.27 0.87\nThe loss function decreases steadily, demonstrating effective learning, as shown in Figure 2. The Dice score\nreaches 0.9 on the training set and 0.87 on the validation set, indicating high segmentation quality. The validation\nperformance lags slightly behind training, suggesting minor overfitting. The early stopping suggests an optimal\nstopping point because training beyond 15 epochs may lead to diminishing returns.\nFigure 2.A snapshot of the compiled U-Net with a dual attention mechanism\n4.2 Model Performance on Test Data\nStrong performance on test data was demonstrated by the trained model. Table 2 shows the result with a Dice\nscore of 86.5% and an IoU of 89%. The recall value of 84% shows reliable segmentation accuracy. The confusion\nmatrix analysis for binary segmentation reveals, as described in Table 3, that 90% of actual positive cases are\ncorrectly identified as true positives while 10% are missed as false negatives. Similarly, 90% of actual negative\ncasesarecorrectly classifiedastruenegativeswithafalse positiverateof10%. Thefalsenegativeratesuggests that\nsome areas of endometriosis may go undetected, while the false positive rate indicates occasional misclassification\nof non-endometriosis regions.\nTable 2.Model training results\nMatrix Result\nDice score 86.5 %\nIoU 89 %\nRecall 84 %\n103\n\nTable 3.Result of confusion matrix\nActual Predicted Positive Predicted Negative\nActual positive True positive ∼ 90 % False negative ∼ 10 %\nActual negative False positive ∼ 10 % True negative ∼ 90 %\n4.3 Grad-CAM Integration\nThe Grad-CAM accuracy of 0.7001 for integrating Grad-CAM with attention mechanisms highlights the near\naccuracy of achieving effective explainability for segmentation, as shown in Table 4. Figure 3 highlights the Grad-\nCAM heatmap, where areas of interest were highlighted with red and yellow regions, indicating where the model\nfocused during prediction. When overlaid on the MRI scan, the heatmap visually demonstrates the relevance of the\nmodel’s segmentation, providing insights into how it identifies affected regions. Grad-CAM successfully generates\nvisual explanations for the U-Net model’s decision.\nTable 4.Grad-CAM integration result\nMetric Value\nGrad-CAM accuracy 0.7001\nFigure 3.Grad-CAM heatmap\nTrust and understanding in the evaluation of Grad-CAM were assessed through localization accuracy and\nfaithfulness. These metrics help determine whether the model’s heatmaps correctly highlight relevant areas and\nwhether they truly explain the model’s decision-making process.\n4.4 Trust Through Localization Accuracy\nThe result for the trust through localization test indicates, as shown in Figure 4, that the Grad-CAM heatmap\naligns well with the ground truth segmentation mask, indicating that the model focuses on the correct regions when\nmakingpredictions. Forthisresearch,thisisindicatedusingIoUandDSCbetweentheGrad-CAMheatmapandthe\nground truth segmentation mask. The IoU of 0.75 and DSC of 0.87 show good overlap and minor false positives.\n4.5 Understanding Through Faithfulness\nTheresultforunderstandingthroughfaithfulnessinthisresearchwasobtainedbyusingthepixelperturbationtest.\nThe high-importance regions were gradually occluded from the Grad-CAM heatmap and changes in the model’s\nprediction were observed as the changes occur. As shown in Figure 5, there is a significant drop in prediction\nconfidence when the important regions are occluded, indicating that the explanation is faithful. This is measured\nusing the drop in confidence (DropC).\n104\n\nFigure 4.Visualization of trust through localization accuracy\nFigure 5.Visualization of understanding through faithfulness using a pixel perturbation test\n4.6 Trust and Understanding Through Consistency of Grad-CAM Output\nQuantitative trust and understanding metrics were inferred through Grad-CAM visualization alignment. The\nresults in Table 5 and the visual representation in Figure 6 indicate an average trust score of 4.625 and an average\nunderstanding score of 4.775, suggesting high confidence among healthcare professionals.\nTable 5.Measure of understanding and trust\nMetric Value\nAverage trust 4.625\nAverage understanding 4.775\n105\n\nFigure 6.Trust and understanding evaluation metric\n5 Scope of Study\nThis study focuses on the development and evaluation of a U-Net with a dual attention mechanism for the\nsegmentation of endometriosis lesions from MRI images. The primary objective is to enhance model explainability\nusingGrad-CAMwhileensuringrobustsegmentationperformance. Thescopeofthisresearchisdefinedasfollows:\n•ThestudyutilizesMRIscansfornon-invasiveendometriosisdetection,withoutintegratingadditionaldiagnostic\nmodalities such as ultrasound or histopathological data.\n• The research focuses on DL-based segmentation and does not perform direct comparisons with traditional\nradiological diagnostic methods.\n• The model is optimized for image-based segmentation rather than broader clinical decision support, such as\npatient history analysis or multi-modal data fusion.\n•ThestudyprimarilyevaluatestheeffectivenessoftheproposedU-Netwithdualattentionratherthanconducting\nanexhaustivecomparisonwithalternativeDLarchitecturessuchasTransformer-basedmodelsorhybridapproaches.\n• Grad-CAM is used as the explainability method, with a focus on heatmap visualization and trust evaluation.\nOther explainability techniques are not explored in detail.\n• While the study assesses trust and understanding through quantitative measures, it does not include direct\nradiologist feedback or qualitative user studies, which are suggested for future work.\n• Clinical adoption and regulatory considerations are beyond the scope of this study but are recognized as\nimportant areas for future investigation.\n6 Discussion\nThe implementation of the U-Net with a dual attention mechanism achieved promising results, particularly with\nIoU and recall at 89% and 84%, respectively. The confusion matrix analysis for binary segmentation reveals, as\ndescribedinTable3,that90%ofactualpositivecasesarecorrectlyidentifiedastruepositiveswhile10%aremissed\nas false negatives. Similarly, 90% of actual negative cases are correctly classified as true negatives with a false\npositive rate of 10%. The false negative rate suggests that some areas of endometriosis may go undetected, while\nthe false positive rate indicates occasional misclassification of non-endometriosis regions.\nThe Grad-CAM accuracy is 0.7001 which is an acceptable percentage but could be better, especially if it is\nadopted in the medical professional field. The Grad-CAM heatmap highlights areas of interest, with red and yellow\nregionsindicatingwherethemodelfocusedduringprediction. WhenoverlaidontheMRIscan,theheatmapvisually\ndemonstrates the relevance of the model’s segmentation, providing insights into how it identifies affected regions.\nGrad-CAM successfully generates visual explanations for the U-Net model’s decisions.\nThe trust and understanding results of the system based on accuracy and the Grad-Cam heatmap are promising,\nwith an average trust score of 4.625 and an average understanding score of 4.775. These high scores reflect that\nthere is a high chance for the system to be accepted by the healthcare providers. This is crucial for the successful\nintegration of the diagnostic system into clinical practice, as trust and understanding are key factors in the adoption\n106\n\nof new technology. The results also underscore the importance of XAI in fostering trust, with the incorporation of\nGrad-CAM and attention mechanisms playing a significant role in improving transparency.\n7 Conclusions\nEndometriosis, a chronic and frequently debilitating ailment, affects millions of women worldwide, but it is one\nof the most underdiagnosed and misunderstood gynaecological conditions. Traditional diagnostic approaches in the\npast relied mainly on intrusive procedures such as laparoscopy, as accurate as it is, can cause delays in diagnosis\nand treatment, worsening the physical, emotional and psychological toll on patients. This study addressed these\nimportantshortcomingsbycreatinganexplainableMLmodelthatprovidesanon-invasive,accurate,andtransparent\ndiagnostic option for endometriosis.\nThe strategy involved the use of XAI approaches such as Grad-CAM, which promotes openness, allowing\nclinicians to comprehend the underlying principles of diagnostic choices. This is critical for clinical acceptance.\nIn addition, the approach appears to be a promising alternative to invasive treatments, with the potential to reduce\ndiagnosticdelaysandassociatedhealthcareexpensesforwomen,particularlyindevelopingcountriessuchasNigeria.\nThese findings highlight the transformational power of merging ML and multimodal data in medical diagnostics.\nByutilizingthisapproach, thisstudyopensthedoorforimprovingearlydetection, enhancingpatientoutcomes, and\nfostering trust in AI-driven healthcare solutions.\n8 Ethical Consideration\nThisstudywasconductedinaccordancewithethicalguidelinestoensurepatientdataprotectionandresponsible\nAI implementation. Ethical approval was obtained from the Babcock University Research Ethical Committee,\nensuring compliance with institutional and regulatory standards for medical research.\nAdditionally,alow-riskethicalreviewwasgrantedbytheCrestviewRadiologyLtdResearchEthicsCommittee,\nwhich oversees ethical compliance for research involving medical imaging data. As part of this review, a Low-\nRisk Ethical Review Form was completed and approved. This form is specifically used by researchers analyzing\nanonymized data from medical databases, confirming that no personally identifiable information was accessed or\nused in the study.\nAllMRIdatautilizedinthisresearchwerefullyanonymizedpriortorelease,ensuringstrictadherencetopatient\nconfidentiality and data protection regulations. The study follows the fundamental ethical principles of medical\nresearch, including non-maleficence, patient privacy, and responsible AI deployment in clinical decision support\nsystems.\nData Availability\nNot applicable.\nConflicts of Interest\nThe authors declare that they have no conflicts of interest.\nReferences\n[1] F. Wang and A. Preininger, “AI in health: State of the art, challenges, and future directions,”Yearb. Med.\nInform., vol. 28, no. 1, pp. 16–26, 2019. https://doi.org/10.1055/s-0039-1677908\n[2] J. E. Lutomski, S. Meaney, R. A. Greene, A. C. Ryan, and D. Devane, “Expert systems for fetal assessment in\nlabour,”Cochrane Database Syst. Rev., vol. 2015, no. 4, p. CD010708, 2015. https://doi.org/10.1002/146518\n58.CD010708.pub2\n[3] B. Sivajohan, M. Elgendi, C. Menon, C. Allaire, P. Yong, and M. A. Bedaiwy, “Clinical use of artificial\nintelligence in endometriosis: A scoping review,”npj Digit. Med., vol. 5, p. 109, 2022. https://doi.org/10.103\n8/s41746-022-00638-1\n[4] M.Elgendi,C.Allaire,C.Williams,M.A.Bedaiwy,andP.J.Yong,“Machinelearningrevealednewcorrelates\nof chronic pelvic pain in women,”Front. Digit. Health, vol. 2, p. 600604, 2020. https://doi.org/10.3389/fdgth.\n2020.600604\n[5] T. Yoldemir, “Artificial intelligence and women’s health,”Climacteric, vol. 23, no. 1, pp. 1–2, 2020. https:\n//doi.org/10.1080/13697137.2019.1682804\n[6] V. Bhardwaj, A. Sharma, S. V. Parambath, I. Gul, X. Zhang, P. E. Lobie, P. W. Qin, and V. Pandey, “Machine\nlearning for endometrial cancer prediction and prognostication,”Front. Oncol., vol. 12, p. 852746, 2022.\nhttps://doi.org/10.3389/fonc.2022.852746\n[7] M. Szubert, A. Rycerz, and J. R. Wilczyński, “How to improve non-invasive diagnosis of endometriosis with\nadvanced statistical methods,”Medicina, vol. 59, no. 3, p. 499, 2023. https://doi.org/10.3390/medicina590304\n99\n107\n\n[8] M. Ridley, “Explainable Artificial Intelligence (XAI): Adoption and advocacy,”Inf. Technol. Libr., vol. 41,\nno. 2, pp. 1–17, 2022. https://doi.org/10.6017/ital.v41i2.14683\n[9] R. A. Lupean, P. A. Ştefan, C. Csutak, A. Lebovici, A. M. Măluţan, R. Buiga, C. S. Melincovici, and C. M.\nMihu, “Differentiation of endometriomas from ovarian hemorrhagic cysts at magnetic resonance: The role of\ntexture analysis,”Medicina, vol. 56, no. 10, p. 487, 2020. https://doi.org/10.3390/medicina56100487\n[10] W. Mao, C. X. Chen, H. C. Gao, L. Xiong, and Y. P. Lin, “A deep learning-based automatic staging method\nfor early endometrial cancer on MRI images,”Front. Physiol., vol. 13, p. 974245, 2022. https://doi.org/10.338\n9/fphys.2022.974245\n[11] H.L.Zhang,H.L.Zhang,H.Yang,A.N.Shuid,D.Sandai,andX.B.Chen,“Machinelearning-basedintegrated\nidentification of predictive combined diagnostic biomarkers for endometriosis,”Front. Genet., vol. 14, p.\n1290036, 2023. https://doi.org/10.3389/fgene.2023.1290036\n[12] Y. Kurata, M. Nishio, A. Kido, K. Fujimoto, M. Yakami, H. Isoda, and K. Togashi, “Automatic segmentation\nof the uterus on MRI using a convolutional neural network,”Comput. Biol. Med., vol. 114, p. 103438, 2019.\nhttps://doi.org/10.1016/j.compbiomed.2019.103438\n[13] M. J. Downing, D. J. Papke, S. Tyekucheva, and G. L. Mutter, “A new classification of benign, premalignant,\nandmalignantendometrialtissuesusingmachinelearningappliedto1413candidatevariables,” Int. J. Gynecol.\nPathol., vol. 39, no. 4, pp. 333–343, 2020. https://doi.org/10.1097/PGP.0000000000000615\n[14] S. Guerriero, L. Saba, M. A. Pascual, S. Ajossa, I. Rodriguez, V. Mais, and J. L. Alcazar, “Transvaginal\nultrasound vs magnetic resonance imaging for diagnosing deep infiltrating endometriosis: Systematic review\nandmeta-analysis,”Ultrasound Obstet. Gynecol.,vol.51,no.5,pp.586–595,2018.https://doi.org/10.1002/uo\ng.18961\n[15] S.Bendifallah,Y.Dabi,S.Suisse,L.Jornea,D.Bouteiller,C.Touboul,A.Puchar,andE.Daraï,“MicroRNome\nanalysis generates a blood-based signature for endometriosis,”Sci. Rep., vol. 12, p. 4051, 2022. https://doi.or\ng/10.1038/s41598-022-07771-7\n[16] U. Tore, A. Abilgazym, A. Asunsolo-del Barco, M. Terzic, Y. Yemenkhan, A. Zollanvari, and A. Sarria-\nSantamera,“Diagnosisofendometriosisbasedoncomorbidities: Amachinelearningapproach,” Biomedicines,\nvol. 11, no. 11, p. 3015, 2023. https://doi.org/10.3390/biomedicines11113015\n[17] B. H. Li, S. Wang, H. Duan, Y. Y. Wang, and Z. C. Guo, “Discovery of gene module acting on ubiquitin-\nmediated proteolysis pathway by co-expression network analysis for endometriosis,”Reprod. Biomed. Online,\nvol. 42, no. 2, pp. 429–441, 2021. https://doi.org/10.1016/j.rbmo.2020.10.005\n[18] A. Mihalyi, O. Gevaert, C. M. Kyama, P. Simsa, N. Pochet, F. De Smet, B. De Moor, C. Meuleman, J. Billen,\nN. Blanckaert, A. Vodolazkaia, V. Fulop, and T. M. D’Hooghe, “Non-invasive diagnosis of endometriosis\nbased on a combined analysis of six plasma biomarkers,”Hum. Reprod., vol. 25, no. 3, pp. 654–664, 2010.\nhttps://doi.org/10.1093/humrep/dep425\n[19] U. Parlatan, M. T. Inanc, B. Y. Ozgor, E. Oral, E. Bastu, M. B. Unlu, and G. Basar, “Raman spectroscopy as a\nnon-invasive diagnostic technique for endometriosis,”Sci. Rep., vol. 9, p. 19795, 2019. https://doi.org/10.103\n8/s41598-019-56308-y\n[20] T.Knific,D.Fishman,A.Vogler,M.Gst\"ottner,R.Wenzl,H.Peterson,andT.L.Rižner,“Multiplexanalysisof\n40 cytokines do not allow separation between endometriosis patients and controls,”Sci. Rep., vol. 9, p. 16738,\n2019. https://doi.org/10.1038/s41598-019-52899-8\n[21] A. Goldstein and S. Cohen, “Self-report symptom-based endometriosis prediction using machine learning,”\nSci. Rep., vol. 13, p. 5499, 2023. https://doi.org/10.1038/s41598-023-32761-8\n[22] O.Ronneberger,P.Fischer,andT.Brox,“U-Net: Convolutionalnetworksforbiomedicalimagesegmentation,”\narXiv preprint arXiv:1505.04597, 2015. https://doi.org/10.48550/arXiv.1505.04597\n[23] C. Shorten and T. M. Khoshgoftaar, “A survey on image data augmentation for deep learning,”J. Big Data,\nvol. 6, p. 60, 2019. https://doi.org/10.1186/s40537-019-0197-0\n[24] A.Chaddad,J.H.Peng,J.Xu,andA.Bouridane,“SurveyofexplainableAItechniquesinhealthcare,” Sensors,\nvol. 23, no. 2, p. 634, 2023. https://doi.org/10.3390/s23020634\n[25] R. Thakur, “Explainable AI: Developing interpretable deep learning models for medical diagnosis,”Int. J.\nMultidiscip. Res., vol. 6, no. 4, 2024.\n[26] F. Yan, Y. Q. Chen, Y. W. Xia, Z. L. Wang, and R. X. Xiao, “An explainable brain tumor detection framework\nfor MRI analysis,”Appl. Sci., vol. 13, no. 6, p. 3438, 2023. https://doi.org/10.3390/app13063438\n[27] A.M.Antoniadi,Y.H.Du,Y.Guendouz,L.Wei,C.Mazo,B.A.Becker,andC.Mooney,“Currentchallenges\nand future opportunities for XAI in machine learning-based clinical decision support systems: A systematic\nreview,”Appl. Sci., vol. 11, no. 11, p. 5088, 2021. https://doi.org/10.3390/app11115088\n108","source_license":"CC0","license_restricted":false}