\documentclass[fleqn,10pt]{wlscirep}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{subfigure}
\usepackage{bm}
\usepackage{algorithm}
\usepackage{algorithmic} 
\usepackage{longtable}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{tabularx}




\title{Interpretable and Robust Deep Learning for Automated HER2 Assessment in Breast Cancer}

\author[1,+]{Md Serajun Nabi}
\author[2,+]{Thinley Yeshey Choden}
\author[2,+]{S M Asiful Islam Saky}
\author[2,+]{Dema Yuden}
\author[1,4,+]{Mohammad Faizal Ahmad Fauzi}
\author[1,3,*,+]{Hezerul Bin Abdul Karim}
\affil[1]{Faculty of AI and Engineering, Multimedia University, Persiaran Multimedia, 63100 Cyberjaya, Malaysia.}
\affil[2]{School of Computing and Informatics, Albukhary International University, Alor Setar 05200, Kedah, Malaysia.}
\affil[3]{Centre for Image and Vision Computing, COE for Artificial Intelligence, Multimedia University, 63100 Cyberjaya, Malaysia}
\affil[4]{School of Digital Health, KPJ Healthcare University, 71800 Nilai, Negeri Sembilan, Malaysia}

\affil[*]{Corresponding Author: Hezerul Bin Abdul Karim}
\affil[*]{hezerul@mmu.edu.my}

% \affil[+]{these authors contributed equally to this work}

\keywords{HER2 IHC scoring, deep learning, explainable AI (XAI), digital pathology, breast cancer diagnosis}

\begin{abstract}
Accurate determination of human epidermal growth factor receptor 2 (HER2) status is essential for guiding targeted therapy in breast cancer. Yet, manual immunohistochemistry (IHC) scoring remains susceptible to inter-observer variability, particularly in borderline cases. Although deep learning–based methods have shown promise for automated HER2 assessment, their clinical adoption is hindered by limited interpretability, poor robustness across imaging magnifications, and insufficient alignment with pathological reasoning. In this study, we propose an interpretable and computationally efficient deep learning framework for automated HER2 scoring that operates consistently across tissue-level (10×) and cellular-level (40×) histopathological images. The framework employs a hybrid layer unfreezing strategy to balance feature adaptation and computational cost, enabling robust multi-magnification learning without reliance on extensive fine-tuning. To address the limitations of qualitative explainability, we integrate Score-CAM with quantitatively validated, membrane-focused metrics Membrane Activation Precision (MAP) and Explanation Consistency (EC) to objectively assess the clinical relevance and stability of model explanations against pathologist annotations. The proposed approach is evaluated on three public HER2 IHC datasets, including BCI, HER2-IHC-40x-Patch, and HER2-IHC-40x-WSI. Experimental results demonstrate strong and consistent performance across magnifications, achieving up to 96\% accuracy on high-resolution patches and maintaining robust performance at 10× magnification, with near-perfect discrimination of HER2 3+ cases (AUC > 0.99). Furthermore, the framework reduces computational overhead compared to full fine-tuning while improving cross-magnification generalizability relative to existing methods. By combining robust multi-scale performance with clinically grounded explainability, this work advances trustworthy AI-assisted HER2 scoring and addresses key barriers to the deployment of automated decision-support systems in digital pathology.
\end{abstract}
\begin{document}


% \begin{keywords}
% HER2 IHC scoring, deep learning, explainable AI (XAI), digital pathology, breast cancer diagnosis
% \end{keywords}

\flushbottom
\maketitle
% * <john.hammersley@gmail.com> 2015-02-09T12:07:31.197Z:
%
%  Click the title above to edit the author information and abstract
%
\thispagestyle{empty}


% \titlepgskip=-21pt

\maketitle


%\begin{document}


\section{Introduction}
%\subsection{Background and Motivation}
Breast cancer diagnosis and treatment stratification increasingly rely on precise biomarker assessment, with human epidermal growth factor receptor 2 (HER2) status being a critical determinant for targeted therapies. Approximately 15 to 20\% \cite{sung2021global} of breast cancers exhibit overexpression or gene amplification of the HER2 protein, conferring aggressive tumor behavior. Immunohistochemistry (IHC) remains the initial test for HER2 assessment, where pathologists measure membrane intensity of staining, completeness, and cell distribution to score as 0 (negative), 1+ (weak), 2+ (equivocal), or 3+ (strong positive) \cite{wolff2018human}. Despite standardized guidelines (ASCO/CAP), manual HER2 scoring suffers from substantial interobserver variability (quoted concordance rates of 60–75\% for 2+ cases) due to subjective reading of the staining pattern and tissue heterogeneity \cite{davey2021ki}. This variability directly impacts patient outcomes, as misclassification leads to under- or overtreatment. Athough digital pathology and AI have demonstrated the potential to improve scoring consistency, most solutions today are focused primarily on accuracy in classification without addressing two fundamental clinical needs: interpretability of AI decisions to build pathologist trust and the insensitivity to diverse imaging protocols and magnification levels \cite{holzinger2021explainable}.

%\subsection{Problem Statement}
Current AI-driven HER2 scoring systems face three interconnected challenges that our study directly addresses. First, while deep learning architectures like CNNs achieve high accuracy ($>$90\%) on single-center datasets \cite{wu2024challenges}, their "black-box" nature denies insight into the morphological characteristic driving predictions, which is a key barrier to clinical adoption. Second, existing explanation techniques (e.g., Grad-CAM) often generate heat maps misaligned with the diagnostic reasoning of pathologists, particularly for subtle membrane staining patterns in 1+ and 2+ cases \cite{rguibi2022cxai}. Third, models trained at one magnification level (e.g., 40×) frequently underperform when applied to other magnifications (e.g., 10×), although both are used clinically \cite{kuklyte2021evaluation}. Our study mitigates these limitations by employing a multi-magnification ResNet50 model where We quantitatively evaluate explainability using membrane-focused metrics rather than subjective pathologist scoring, ensuring reproducible validation, and rigorously testing on three publicly available datasets (BCI at 10×, HER2-IHC-40x-WSI/Patch at 40×) to ensure generalizability across imaging protocols.

\subsection{Study Aim}
The study aims to develop a robust and computationally efficient deep learning framework for automated HER2 scoring that achieves consistent performance across tissue-level (10×) and cellular-level (40×) histopathological images, addressing variability introduced by magnification differences in digital pathology. To establish quantitatively validated explainability for HER2 scoring by integrating Score-CAM with membrane-focused metrics that objectively assess the clinical relevance and stability of model attention, moving beyond qualitative visual interpretation, and to evaluate cross-dataset generalizability and practical deployability of the proposed framework through comprehensive performance analysis, ablation studies, and efficiency benchmarking on publicly available HER2 IHC datasets.



\section{Literature Review}
\subsection{Clinical Significance and Challenges of HER2 Scoring}
HER2 status is a key breast cancer treatment stratification determinant, with overexpression in 15-20\% cases correlating with aggressive tumor behavior as well as sensitivity to targeted therapies like trastuzumab \cite{sung2021global}. IHC remains the primary method for HER2 assessment, with pathologists evaluating membrane staining intensity, completeness, and distribution to assign scores of 0 to 3+ \cite{wolff2018human}. However, manual scoring is marred by high variability between observers, particularly for borderline (2+) cases, with concordance rates as low as 60–75\% \cite{davey2021ki} \cite{palm2023determining}. This variability stems from subjective interpretation of staining patterns and tissue heterogeneity, leading to potential misclassification and suboptimal treatment decisions \cite{tewary2021autoihc}. Although the ASCO / CAP guidelines offer standardization for scoring, subjectivity underscores the need for automated, reproducible solutions \cite{wolff2018human} \cite{wang2020score}.


\subsection{Evolution of AI in HER2 IHC Analysis}
Recent advances in deep learning have demonstrated the potential of convolutional neural networks (CNN) to improve the consistency of the HER2 scoring \cite{pisula2023predicting} \cite{farahmand2022deep} \cite{wang2024automated}. Early studies achieved exceeding 90\% accuracies in single-center data sets using architectures like ResNet and InceptionV3 \cite{wu2024challenges} \cite{cruz2014automatic}. However, these models often function as "black boxes," giving limited insight into the morphological features underlying predictions, a significant barrier to clinical adoption \cite{rguibi2022cxai}. Furthermore, their performance degrades when applied on data from other institutions or staining protocols, demonstrating a failure in generalizability \cite{kuklyte2021evaluation} \cite{ming2022predicting}. For example, models learned on 40× images often perform poorly on 10× images, even though both resolutions are clinically significant \cite{kuklyte2021evaluation}. These limitations call for methods that balance accuracy with interpretability and insensitivity to variations in imaging conditions.

\subsection{Explainability in Medical AI: Gaps and needs}
The demand for explainable AI (XAI) in digital pathology has increased with regulatory requirements for transparent decision-making in healthcare \cite{holzinger2021explainable} \cite{tang2024reviewing}. Post hoc approaches such as Grad-CAM generate heat maps showing model attention but often fail to align with pathologists' diagnostic reasoning, particularly in weak membrane staining patterns of 1+ and 2+ cases \cite{rguibi2022cxai} \cite{wang2024gradient}. For example, heatmaps may highlight cytoplasmic or stromal regions irrelevant to HER2 scoring, undermining clinician trust \cite{ribeiro2016should}. A recent study by \cite{wang2020score} proposed Score-CAM to address this by using activation scores rather than gradients to improve localization accuracy. Based on this, our study employs quantitative metrics, membrane activation precision (MAP) and explanation consistency (EC), which use pathologist-annotated membrane masks as a reference to objectively assess the alignment and stability of Score-CAM heat maps (Section \ref{evaluation}).


\subsection{Multi-Magnification Robustness in Computational Pathology}
A common challenge in computational pathology is the variability introduced by various magnification levels (e.g., 10× for tissue-level assessment vs. 40× for cellular resolution) \cite{qu2024advancing} \cite{modi2024multi}. Studies by \cite{kuklyte2021evaluation} revealed that single-magnification models exhibit extreme performance degradations when applied to other resolutions, making them less practical clinically. Multi-scale models like HRNet \cite{wang2024ms} and Swin Transformers (SwinT) \cite{liu2021swin} have been proposed to address this but are usually at a high computational expense. Our joint unfreezing method to ResNet50 (section \ref{unfreeziing}) mitigates this by preserving general features in early layers (Blocks 1–2) and fine-tuning upper blocks for magnification-related patterns, with cross-resolution robustness without loss of efficiency.



\section{Materials and Method}


\subsection{Data Acquisition and Preprocessing} 


The HER2-IHC-40x dataset was sourced from the University of Malaya Medical Center, consisting of 107 whole-slide images (WSI). After preprocessing and validation by expert pathologists, the authors made the dataset publicly available \cite{nabi2025her22}. These datasets were pre-split into training and test sets and underwent consistent preprocessing procedures to ensure compatibility for training with the ResNet50 model.

\begin{figure} [htbp]
    \centering
    \includegraphics[width=1\linewidth, keepaspectratio]{Scientific_Report_her2-Paper2/Images/ResNet50_diagram.png}
    \caption{The architecture presents the structure of the ResNet50 model in which the pretrained layers are utilized for feature extraction while fine-tuning the last layers to predict HER2 classification. Key components include the dropout layer for regularization, cosine annealing scheduler, early stopping, and L2 regularization, all contributing to the model's performance in predicting HER2 expression levels across four classes (0, 1+, 2+, 3+).}
    \label{resnet50-diagram}
\end{figure}


The images were resized to $224 \times 224$ pixels to match the input dimensions required by the ResNet50 model, which expects a fixed input size for consistent feature extraction and training efficiency. They were then normalized using the ImageNet mean and standard deviation values $\text{Mean} = [0.485, 0.456, 0.406]$, $\text{Standard Deviation} = [0.229, 0.224, 0.225]$ to align the pixel intensity distributions with the pre-trained ResNet50 model, facilitating better convergence and performance. For data augmentation, training sets were subjected to random horizontal flips, rotations $\pm 20^\circ$, and color jitter to artificially increase data variability, helping to reduce overfitting and improving the generalization of the model to unseen images. Furthermore, all datasets were pre-split into 80\% training and 20\% testing sets to allow robust evaluation, as summarized in Table~\ref{data_overview}.



\begin{table*} [htbp]
\centering
\caption{Dataset overview and splits for BCI, HER2-IHC-40x-WSI, and HER2-IHC-40x-Patch}
\small
\begin{tabular}{lccc}
\hline
Class & BCI Dataset & HER2-IHC-40x-WSI & HER2-IHC-40x-Patch \\
\hline
0  & 240 (202 train, 38 test)  & 3789 (3131 train, 658 test)  & 3789 (3031 train, 758 test) \\
1+ & 1154 (919 train, 235 test) & 2153 (1837 train, 316 test) & 2689 (2151 train, 538 test) \\
2+ & 2143 (1697 train, 446 test) & 634 (523 train, 111 test)  & 1131 (905 train, 226 test) \\
3+ & 1336 (1078 train, 258 test) & 3364 (2602 train, 762 test) & 3388 (2710 train, 678 test) \\
\hline
Total & 4873 (3896 train, 977 test) & 9940 (8093 train, 1847 test) & 10997 (8797 train, 2200 test) \\
\hline
\end{tabular}
\label{data_overview}
\end{table*}

\subsection{Base Model Selection}
The model utilized in this study is based on ResNet50, a well-known convolutional neural network (CNN) architecture pre-trained on ImageNet. ResNet50 incorporates residual connections that allow deep networks to be trained by alleviating the problem of vanishing gradients. The residual blocks allow the model to learn more abstract and detailed features from the input images \cite{koonce2021resnet}. ResNet50 has proven to be effective in a variety of image classification tasks and thus is an appropriate choice for the HER2 expression classification task in histopathological images. Using pre-trained weights from ImageNet \cite{he2019rethinking}, the model gets to take advantage of the learned features, especially in the early layers, which capture general image attributes such as edges, textures, and simple patterns. The visual architectural design of the proposed ResNet50 model is shown in Figure \ref{resnet50-diagram}.

\subsection{Hybrid Layer Unfreezing Strategy}
\label{unfreeziing}
The theoretical foundation for our hybrid layer unfreezing approach is derived from the hierarchical learning characteristics of deep convolutional networks applied to images \cite{yan2015hd} of human epidermal growth factor receptor 2 (HER2) immunohistochemistry (IHC). In the ResNet50 architecture, the initial layers (Blocks 1-2) create generic feature detectors for histological structures like cell membranes, nuclei, and tissue architecture, features that are invariant to variations in various IHC staining protocols. These layers are therefore left pre-trained to maintain their generic image processing capabilities.

The intermediate blocks (Block 3) extract more specialized patterns, particularly relevant to HER2 scoring, e.g., completeness and intensity distribution of membrane staining. These layers are partially fine-tuned with a reduced learning rate (0.5×base rate) to allow gradual adaptation to staining variation without overfitting. The deepest layers (Block 4) are fully fine-tuned to produce HER2-specific feature detectors, particularly for the characteristic strong circumferential membrane staining patterns of HER2-positive (3+) cases. The final fully connected layer is completely retrained to map these learned features to the four HER2 score categories (0, 1+, 2+, 3+). This strategy is implemented using a differential learning rate across network depths, defined as:

\begin{equation}
\eta_l =
\begin{cases}
0, & \text{for } l \in \text{Blocks 1--2} \\
0.5\eta_{\text{base}}, & \text{for } l \in \text{Block 3} \\
\eta_{\text{base}}, & \text{for } l \in \text{Block 4 and FC layers}
\end{cases}
\label{eq:differential_lr}
\end{equation}

where \(\eta_{\text{base}}\) follows a cosine annealing schedule from 0.001 to \(1 \times 10^{-6}\) over the training epochs. This approach reduces the effective parameter space by 72.7\% compared to full network fine-tuning while preserving the essential adaptation capacity for learning HER2-specific features.


\subsection{HER2-Specific Classification Head}

\begin{figure} [!b]
    \centering
    \includegraphics[width=0.55\linewidth, keepaspectratio]{Scientific_Report_her2-Paper2/Images/dual-path_classification head.jpg}
    \caption{Dual-path classification head architecture
Parallel membrane (red) and context (green) pathways process features before fusion, with dropout rates and regularization components visualized. The design optimizes performance for borderline cases while maintaining clinical interpretability.}
    \label{dual}
\end{figure}


To address the unique challenges of HER2 scoring, we redesigned ResNet50's classification head with three clinically motivated modifications Figure \ref{dual}. The standard fully connected layer was replaced by a dual-path architecture that processes features in parallel through specialized pathways: (1) a membrane-focused route employing aggressive dropout ($p=0.4$) to amplify staining pattern features, and (2) a contextual route with lighter dropout ($p=0.2$) to preserve tissue morphology information. This asymmetric design, validated through systematic testing, proved optimal for discriminating challenging equivocal (2+) cases by forcing the model to maintain robust membrane feature detection while retaining broader histological context. The architecture reduces parameter counts by 63\% compared to standard ResNet50 heads while improving performance on borderline cases. For confidence calibration critical to clinical use, we incorporated label smoothing ($\alpha=0.1$) and L2 weight decay ($\lambda=1 \times 10^{-4}$), combining them in the composite loss function $\mathcal{L} = \mathcal{L}_{CE} + \lambda \lVert \theta \rVert^2$ where $\mathcal{L}_{CE}$ represents smoothed cross-entropy loss. This integrated approach yields well-calibrated predictions that align with pathologists' confidence levels, particularly for subtle staining patterns that dominate 1+ and 2+ classifications.


\subsection{Adaptive Cosine Annealing Learning Rate Scheduling}
The learning rate scheduling employs a cosine annealing strategy that non-linearly adjusts the learning rate during training. The learning rate \(\eta_t\) at epoch \(t\) is computed as:

\begin{equation}
\eta_t = \eta_{\text{min}} + \frac{1}{2} (\eta_{\text{max}} - \eta_{\text{min}}) \left(1 + \cos\left(\frac{t\pi}{T_{\text{max}}}\right)\right)
\label{eq:cosine_annealing}
\end{equation}

where \(\eta_{\text{max}} = 0.001\) serves as the initial learning rate, \(\eta_{\text{min}} = 10^{-6}\) defines the minimum learning rate, and \(T_{\text{max}} = 100\) corresponds to the total number of training epochs.  This approach allows for a gradient descent-like, smooth, oscillation-free decreasing of the learning rate, which can be particularly valuable in the optimization of HER2 classifier models where subtle staining patterns require careful fine-tuning. Unlike traditional step-based decay, which abruptly reduces the learning rate at fixed intervals, cosine annealing allows for continuous adjustment that avoids suboptimal convergence.

\subsection{Early Stopping with Dynamic Patience}
To prevent overfitting while maximizing model performance, we implement an early stopping mechanism with dynamic patience. The patience window \(P_t\) at epoch \(t\) is adjusted adaptively based on the training progress:

\begin{equation}
P_t = P_{\text{base}} \left(1 + 0.5 \cos\left(\frac{t\pi}{T_{\text{max}}}\right)\right)
\label{eq:patience_schedule}
\end{equation}

Here, \(P_{\text{base}} = 5\) defines the baseline patience in epochs. This dynamic adjustment accommodates various convergence behaviors during different phases of training. Early stopping is triggered if the validation loss does not improve for \(P_t\) consecutive epochs, ensuring efficient resource utilization without premature termination. The best-performing model weights are retained throughout training, so that maximum performance is achieved at early stopping. This optimization framework balances computational efficiency with model accuracy, making it particularly suitable for medical image analysis applications where training stability and generalization are critical. Table \ref{hyperparameters} summarizes the overall hyperparameters used in the model. 

\begin{table}
\centering
\caption{Hyperparameters used for training the model.}
\small
\begin{tabular}{lcl}
\hline
Parameter & Value & Description \\
\hline
Number of Epochs & 100 & Total number of training epochs \\
Batch Size & 32 & Batch size used for training and evaluation \\
Learning Rate & 0.001 & Initial learning rate for the Adam optimizer \\
Optimizer & Adam & Optimizer used for model training \\
Weight Decay & $1 \times 10^{-4}$ & Weight decay for regularization during optimization \\
LR Scheduler & Cosine Annealing & Scheduler used to decay learning rate during training \\
Early Stopping Patience & 5 & Number of epochs without improvement before early stopping \\
\hline
\end{tabular}
\label{hyperparameters}
\end{table}




\subsection{Explainable AI (Scor-CAM) Integration}
The explainability framework incorporates Score-CAM (Score-weighted Class Activation Mapping) to visualize the model's decision-making process for HER2 scoring. The target layer of activation mapping is set as the final convolutional layer of Block 4 in ResNet50 (layer4[-1]), as this layer optimally captures both high-level histological patterns and spatial information relevant to membrane staining assessment. The default PyTorch-GradCAM package was utilized \cite{gierse2023novel} without architectural modifications to maintain reproducibility along with clinical interpretability. Figure \ref{xai-integration} illustrates the complete process flow for Score-CAM, highlighting how activation heatmaps are generated and overlaid on the baseline images to explain the model's focus on discriminative regions for classification.

\begin{figure} 
    \centering
    \includegraphics[width=0.9\linewidth, keepaspectratio]{Scientific_Report_her2-Paper2/Images/xai-integration.png}
    \caption{The figure demonstrates the complete Process flow for explainability integration using Score-CAM. It includes steps from image preprocessing and feature extraction to the generation of heatmaps through Score-CAM, and the final explanation overlay for model interpretability, emphasizing regions that most significantly affect the model's predictions for HER2 expression levels.}
    \label{xai-integration}
\end{figure}

The visualization process applies min-max normalization to activation maps before overlaying them over original images with the JET colormap. A fixed threshold of 0.5 is employed to highlight regions most influential to the model's predictions. This approach generates heatmaps consistent with pathologist review patterns and emphasizes membrane staining features critical for HER2 scoring. The overall process of Score-CAM is presented in Table \ref{heatmap_steps}.

\begin{table}
\centering
\caption{Process Overview of Score-CAM for Model Interpretation.}
\small
\begin{tabular}{ll}
\hline
Step & Description \\
\hline
Activation Map Generation & Extract feature maps from ResNet50’s Layer 4 for high-level image features. \\
Perturbation Mapping & Apply perturbations and compute activation scores for each image region. \\
Heatmap Generation & Generate heatmap using activation scores, applying a Jet colormap to visualize influential regions. \\
Post-Processing & Overlay heatmap on the original image, highlighting the regions most influential in the prediction. \\
\hline
\end{tabular}
\label{heatmap_steps}
\end{table}



\subsection{Quantitative Explainability Assessment}
We evaluated explanation quality using three core metrics, as shown in Table \ref{xai_metrics}. These metrics objectively quantify the reliability and clinical relevance of model explanations without interfering with routine pathological workflows. The framework requires no additional annotations, and it leverages only the model's own outputs and activation maps.

\begin{table}
\centering
\caption{Evaluation metrics for explanation quality and clinical interpretation.}
\small
\begin{tabular}{lll}
\hline
Metric Name & Formulation & Clinical Interpretation \\
\hline
Mean activation intensity & $\mathbb{E}[H(x,y) \mid H(x,y) > 0.5]$ & Measures focus on clinically relevant regions \\
Mean confidence spread & $\sigma(\{p(y \mid x)_i\}^{n})$ & Quantifies prediction stability across analyses \\
Mean explainability score & $-\sum p(y \mid x)\log p(y \mid x)$ & Assesses uncertainty in model explanations \\
\hline
\end{tabular}
\label{xai_metrics}
\end{table}



\subsection{Comprehensive Evaluation Framework}
\label{evaluation}
The evaluation incorporates clinically relevant measures alongside conventional accuracy, with a special focus on the problems of HER2 scoring. The precision-recall tradeoff is quantified in class-specific F1-scores, given by:

\begin{equation}
F1_c = \frac{2 \cdot \text{Precision}_c \cdot \text{Recall}_c}{\text{Precision}_c + \text{Recall}_c}
\label{eq:f1}
\end{equation}

where \( c \) denotes each HER2 category (\( 0, 1+, 2+, 3+ \)). To handle class imbalance, we offer macroaveraged ROC-AUC across all classes and report per-class AUCs equally weighted to reduce bias against the majority classes. Model calibration is assessed via the Expected Calibration Error (ECE):

\begin{equation}
ECE = \sum_{m=1}^{M} \frac{|B_m|}{n} \left| \text{acc}(B_m) - \text{conf}(B_m) \right|
\label{eq:ece}
\end{equation}

where predictions are partitioned into \( M = 10 \) confidence bins \( B_m \), \( n \) is the total number of samples, \( \text{acc}(B_m) \) is the accuracy in bin \( B_m \), and \( \text{conf}(B_m) \) is the average predicted confidence in bin \( B_m \).


\subsubsection{Explainability Assessment Metrics}
For quantitative validation of Score-CAM explanations in HER2 scoring, we implemented three rigorously defined metrics: Membrane Activation Precision (MAP), Explanation Consistency (EC), and Relevance Coverage (RC). These metrics utilize existing pathologist-annotated membrane masks as a reference to objectively evaluate how well the model's explanations align with biologically meaningful regions and their consistency across multiple runs.


\begin{equation}
\text{MAP} = \frac{\sum_{x,y} H(x,y)}{\sum_{x,y} H(x,y) \cdot M(x,y)}
\label{eq:MAP}
\end{equation}

\begin{equation}
\text{EC} = 1 - \frac{1}{N} \sum_{i=1}^{N} \sigma \left( \{ p_i(k) \}_{k=1}^{10} \right)
\label{eq:EC}
\end{equation}

\begin{equation}
\text{RC} = \frac{\sum_{x,y} M(x,y)}{\sum_{x,y} I(H(x,y) > 0.7) \cdot M(x,y)}
\label{eq:RC}
\end{equation}



In equation \ref{eq:MAP}, we applied the MAP following the formulation of \cite{wang2020score}, modified for HER2 scoring. Where \( H(x,y) \in [0,1] \) is the normalized Score-CAM heatmap value at pixel \((x,y)\), and \( M(x,y) \in \{0,1\} \) is the binary membrane mask. MAP quantifies the clinical relevance of model attention by measuring the fraction of high-activation regions that overlap with true membrane structures. As shown in equation \ref{eq:EC}, we propose EC to quantify stability, where \( \sigma \) denotes the standard deviation of predicted probabilities \( p_i \) across 10 Score-CAM runs per image. EC \( \in [0,1] \) evaluates the stability of explanations, with 1 indicating perfect consistency regardless of random Score-CAM sampling variations. Then we applied the relevance coverage (RC) formula in equation \ref{eq:RC}, where \( \mathbb{I} \) is the indicator function. RC \( \in [0,1] \) measures what percentage of annotated membrane area receives strong model attention (activation \( > 0.7 \)), directly assessing alignment with diagnostic regions. The activation threshold (\( \tau = 0.7 \)) follows established clinical interpretation standards for HER2 scoring \cite{wolff2018human}.


\section{Experimental Analysis}
The performance of the ResNet50 model was evaluated on three publicly available datasets: HER2-IHC-40x-WSI, BCI, and HER2-IHC-40x-Patch. In all three data sets, precision, recall, F1 score, and measure were calculated in the four classes: 0, 1+, 2+, and 3+. The performance of each dataset is summarized in the following Table \ref{classification_report}.



\begin{table*}
\centering
\caption{Classification performance of ResNet50 across three different Datasets}
\resizebox{\textwidth}{!}{%
\begin{tabular}{l|ccc|ccc|ccc}
\hline
Class & \multicolumn{3}{c|}{HER2-IHC-40x-WSI} & \multicolumn{3}{c|}{BCI Dataset} & \multicolumn{3}{c}{HER2-IHC-40x-Patch} \\
\cline{2-10}
 & Precision & Recall & F1-Score & Precision & Recall & F1-Score & Precision & Recall & F1-Score \\
\hline
Class 0 & 0.94 & 0.91 & 0.93 & 0.95 & 0.97 & 0.96 & 0.97 & 0.97 & 0.97 \\
Class 1+ & 0.82 & 0.83 & 0.82 & 0.95 & 0.90 & 0.93 & 0.91 & 0.93 & 0.92 \\
Class 2+ & 0.80 & 0.97 & 0.88 & 0.94 & 0.98 & 0.96 & 0.93 & 0.90 & 0.91 \\
Class 3+ & 1.00 & 0.99 & 0.99 & 0.97 & 0.94 & 0.95 & 1.00 & 1.00 & 1.00 \\
\hline
Accuracy &  & 93\% &  &  & 95\% &  &  & 96\% &  \\
\hline
Macro avg & 0.89 & 0.92 & 0.90 & 0.95 & 0.95 & 0.95 & 0.95 & 0.95 & 0.95 \\
Weighted avg & 0.93 & 0.93 & 0.93 & 0.95 & 0.95 & 0.95 & 0.96 & 0.96 & 0.96 \\
\hline
\end{tabular}%
}
\label{classification_report}
\end{table*}


As shown in Table \ref{classification_report}, the HER2-IHC-40x-WSI dataset, the model achieved notable performance with high precision and recall values for all classes and outstanding performance for class 3+. The overall accuracy was 93\%, indicating stable performance. Class 1+ possessed a precision of 0.82 and recall of 0.83, slightly lower, while class 2+ possessed a precision of 0.80 and recall of 0.97, reflecting the model's robustness in detecting moderate HER2 expressions but had some challenges in classifying weak expressions. In the BCI data set, the model exhibited an accuracy of 95\%. It showed excellent performance on class 3+. The precision was 0.95, and the recall was 0.90 for class 1+, indicating the ability of the model to identify weak HER2 expressions with good performance. The model also had high F1-scores for all classes, indicating its consistency in classification. Lastly, with the HER2-IHC-40x-Patch dataset, the model achieved its highest accuracy of 96\%. Performance was exceptionally strong in all classes, and class 3+ once again showed perfect results. The precision and recall for class 1+ were 0.91 and 0.93, respectively, while for class 2+, both precision and recall were 0.93, further demonstrating the model's ability in detecting both weak and moderate HER2 expressions.


\subsection{Confusion Matrix, AUC, and Model Training Performance}
The ResNet50 model was evaluated using three key visualizations: the AUC-ROC curve, the confusion matrix, and the training loss/accuracy curves. These visualizations provide an overall assessment of the performance of the model on the three datasets (HER2-IHC-40x-WSI, BCI, and HER2-IHC-40x-Patch).

\begin{figure}
\centering
\subfigure[]{\includegraphics[width=0.25\linewidth]{Scientific_Report_her2-Paper2/Images/confusion_40x_wsi.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.35\linewidth]{Scientific_Report_her2-Paper2/Images/loss_accuracy_40x_Wsi.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.33\linewidth]{Scientific_Report_her2-Paper2/Images/loss_accuracy_40x_Wsi.png}}\hspace{0.01\linewidth}
\caption{Performance Evaluation for the HER2-IHC-40x-WSI Dataset: The visualization shows the confusion matrix (a), AUC-ROC curve (b), and training accuracy/loss (c) plots for the HER2-IHC-40x-WSI dataset. The plot shows a general view of the model's performance, which shows strong classification, high AUC values, and proper convergence while training.}
\label{plots_WSI}
\end{figure}



In Figure \ref{plots_WSI}, the HER2-IHC-40x-WSI dataset, the confusion matrix illustrates that the model correctly classifies class 3+ with few misclassifications in other classes. The AUC-ROC curve shows the outstanding ability of the model to separate classes, with class 3+ achieving an AUC of 0.9998, indicating robust performance. The training loss curve shows a gradual decrease, while the accuracy curve rises throughout the training, reflecting successful convergence.


\begin{figure} [!t]
\centering
\subfigure[]{\includegraphics[width=0.25\linewidth]{Scientific_Report_her2-Paper2/Images/confusion_bci.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.35\linewidth]{Scientific_Report_her2-Paper2/Images/train_loss_accuracy_bci.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.33\linewidth]{Scientific_Report_her2-Paper2/Images/auc_bci.png}}\hspace{0.01\linewidth}
\caption{Performance evaluation of BCI dataset: The confusion matrix (a), AUC-ROC curve (c), and training loss/accuracy curves (b) for the BCI dataset are shown below. The visualization supports the model's ability to well-classify the data, with a high AUC and consistent improvements in training accuracy and loss.}
\label{plots_bci}
\end{figure}



The BCI dataset in Figure \ref{plots_bci} also shows strong model performance, as seen in the confusion matrix, with 3+ class being accurately classified. Class 3+ AUC scores 0.9999, confirming the model's ability to identify strong positive HER2 expression successfully. Training loss constantly decreased and accuracy increased during training, reflecting the effective learning process of the model. For the HER2-IHC-40x-Patch dataset in Figure \ref{plots_patch}, the confusion matrix shows accurate classification for all classes, particularly for class 3+. The AUC-ROC curve indicates strong discriminatory power for all classes, and the training loss curve decreases significantly, with accuracy approaching perfection as training progresses.


\begin{figure}
\centering
\subfigure[]{\includegraphics[width=0.25\linewidth]{Scientific_Report_her2-Paper2/Images/confusion_40x_patch.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.35\linewidth]{Scientific_Report_her2-Paper2/Images/40x-patch.png}}\hspace{0.01\linewidth}
\subfigure[]{\includegraphics[width=0.33\linewidth]{Scientific_Report_her2-Paper2/Images/40x-auc-patch.png}}\hspace{0.01\linewidth}
\caption{Performance evaluation for the HER2-IHC-40x-Patch dataset: The visualization presents the confusion matrix (a), AUC-ROC curve (c), and the training loss/accuracy (b) curves of the HER2-IHC-40x-Patch dataset, where it reflects the high performance of the model with ideal classification in class 3+ and perfect learning evident in the training loss/accuracy curves.}
\label{plots_patch}
\end{figure}


However, as the ResNet50 model was evaluated on the three different datasets and performances illustrated in Table \ref{classification_report}, indicate the notable performance of the model across all data sets, particularly in class 3+, where the model achieved perfect precision and recall in all cases. The HER2-IHC-40x-WSI dataset achieved an accuracy of 93\%, with the model performing slightly better for the higher HER2 expressions. The BCI dataset showed 95\% accuracy, with the best performance in classifying class 3+. The HER2-IHC-40x-Patch data set achieved the best accuracy of 96\%, which is the best performance of the model. This improvement can be attributed to the high-resolution patch-based data used in this dataset, which provides finer details of tissue architecture compared to lower-resolution whole-slide images. The higher resolution of the HER2-IHC-40x-Patch dataset allows the model to identify subtle differences in HER2 expression with more accurate predictions, particularly for weak to moderate expressions like class 1+ and class 2+. These results highlight the robustness of the model in identifying strong HER2 expression across data sets, with the HER2-IHC-40x patch dataset generating more accurate predictions, most likely due to the higher resolution of the data.
%%%%%%%%%%%%%%%%%%%%%%

Figure \ref{xai-outputs} illustrates consolidated Score-CAM visualizations across the three datasets, providing insight into how the model attends to diagnostically relevant regions under varying imaging conditions. Across all datasets, high-activation regions (red) are predominantly localized to membrane staining patterns in HER2-positive cases, while low-activation regions dominate negative samples, indicating consistent alignment between model attention and established pathological criteria for HER2 scoring.

\begin{figure*} 
    \centering
    \includegraphics[width=1\linewidth, keepaspectratio]{Scientific_Report_her2-Paper2/Images/XAI_outputs.png}
    \caption{(A) HER2-IHC-40x-WSI, (B) BCI dataset (10×), and (C) HER2-IHC-40x-Patch. For each dataset, original images are shown alongside corresponding Score-CAM heatmaps for representative HER2 classes (0, 1+, 2+, and 3+). }
    \label{xai-outputs}
\end{figure*}

Quantitative explainability metrics further contextualize these visual patterns. Table \ref{xai-probabilities-metrics}  summarizes three key explainability metrics across the three datasets. In the HER2-IHC-40x-WSI dataset, the mean activation intensity (MAI = 0.5124) was highest, reflecting strong and focused model attention, particularly for HER2 3+ cases. This was accompanied by a high mean confidence spread (MCS = 0.9989), indicating stable and confident predictions across samples. However, the relatively low mean explainability score (MES = 0.0056) suggests that while activations were sharp, they were concentrated within limited regions, resulting in less diffuse explanatory coverage across classes.

In contrast, the BCI dataset (10× magnification) exhibited a moderate MAI (0.3496) with similarly high prediction stability (MCS = 0.9980), but a slightly higher MES (0.0070). This pattern reflects more spatially distributed attention over broader tissue regions, consistent with lower-resolution imaging where architectural context rather than fine membrane detail contributes to classification.

The HER2-IHC-40x-Patch dataset demonstrated the lowest MAI (0.2386) but the highest MES (0.0814), indicating that although individual activations were less intense, model attention was more evenly distributed across clinically relevant membrane regions. This behaviour suggests improved capture of subtle staining patterns in high-resolution patches, particularly for intermediate HER2 classes (1+ and 2+). The slightly lower MCS (0.9644) reflects increased variability in predictions, which is expected given the finer granularity and heterogeneity of patch-level analysis.

\begin{table}
\centering
\caption{Explainability metrics across three different datasets}
\begin{tabular}{lccc}
\hline
Dataset & MAI & MCS & MES \\
\hline
HER2-IHC-40x-WSI &  0.5124 & 0.9989 & 0.0056 \\
BCI Dataset & 0.3496 & 0.9980 & 0.0070 \\
HER2-IHC-40x-Patch & 0.2386 & 0.9644 & 0.0814 \\
\hline
\end{tabular}
\label{xai-probabilities-metrics}
\end{table}

Overall, these findings indicate that explainability performance varies with image resolution and acquisition scale. High activation intensity and prediction stability do not necessarily correspond to broader or more informative explanatory coverage, underscoring the importance of combining complementary quantitative metrics with qualitative visualization. Together, the results demonstrate that the proposed framework produces clinically meaningful and magnification-robust explanations rather than relying solely on visually appealing heatmaps.


\subsection{Model Performance Across Varying Imaging Conditions}
As presented in Table \ref{dataset-comparison}, the higher pixel density and finer tissue details in the HER2-IHC-40x-Patch dataset resulted in the best performance of the model. This dataset benefited from patch-based data, which allowed the model to focus on detailed regions relevant to HER2 classification. Despite the lower resolution of the BCI dataset, the model still performed effectively, showcasing its adaptability in clinical settings where image quality may vary due to different scanning techniques or magnifications.

\begin{table}
\centering
\caption{Comparison between BCI and HER2-IHC-40x Datasets.}
\small
\begin{tabular}{llll}
\hline
\textbf{Aspect} & \textbf{BCI Dataset} & \textbf{HER2-IHC-40x} & \textbf{Observation} \\
\hline
Magnification Level & 10x & 40x & 10x provides a broader view, while 40x focuses on finer tissue details \\
Resolution & Lower & Higher & 40x captures finer details, improving HER2 expression classification \\
Field of View & Wider & Narrower & 10x covers larger areas, while 40x provides focused tissue regions \\
Pixel Density & Lower & Higher & Higher pixel density at 40x improves detail visibility \\
Tissue Detail & Coarser & Finer & 40x enables observation of intricate cellular and subcellular structures \\
Color Distribution & Less pronounced & More pronounced & Higher magnification enhances color contrast, aiding precise scoring \\
\hline
\end{tabular}
\label{dataset-comparison}
\end{table}





Despite the lower resolution imaging conditions. Figure \ref{multi} reveals how shared Layer3 weights enable this adaptability: 10x inputs produce diffuse activations capturing tissue architecture, while 40x patches yield focused membrane patterns. This magnification-agnostic behavior stems from our hybrid unfreezing strategy (Section \ref{unfreeziing}), where mid-level layers learn resolution-invariant features while maintaining sensitivity to HER2-specific patterns. The visualization confirms the model's ability to leverage the same feature extractor for both whole-slide (10x) and high-resolution (40x) analysis, explaining its robust performance across datasets (Table \ref{classification_report}).

\begin{figure}
    \centering
    \includegraphics[width=0.65\linewidth, keepaspectratio]{Scientific_Report_her2-Paper2/Images/multi-magnification.jpg}
    \caption{Multi-magnification feature adaptation in Layer3 Activation maps from shared convolutional weights processing 10x (left, diffuse tissue patterns) versus 40x (right, localized membrane features) inputs. Arrows indicate how the same filters adapt to resolution differences while maintaining HER2 detection capability.}
    \label{multi}
\end{figure}

\subsection{Computational Environment}

As shown in Table \ref{system-config}, the experiments were executed on a high-performance setup with PyTorch as the implementation environment, using NVIDIA Tesla V100 GPUs for faster computation. The setup consisted of 16 CPU cores, 64 GB RAM, and SSD storage for quick data access and processing. The models were trained with a batch size of 32, and the Adam optimizer was paired with a cosine annealing learning rate scheduler for effective convergence.

\begin{table}
\centering
\caption{System Configuration and Training Setup}
\begin{tabular}{l l}
\hline
Component & Specification \\
\hline
Framework & PyTorch \\
Hardware & NVIDIA Tesla V100 GPU \\
CPU & 16 cores \\
RAM & 64 GB \\
Storage & SSD (High-speed) \\
Batch Size & 32 \\
Optimizer & Adam \\
Learning Rate Scheduler & Cosine Annealing \\
\hline
\end{tabular}
\label{system-config}
\end{table}



\subsection{Ablation Study}
To rigorously evaluate the impact of the training strategies on HER2 scoring performance, we conducted an ablation study comparing three ResNet50 configurations across three datasets: HER2-IHC-40x-WSI, BCI (10), and HER2-IHC-40x-Patch. The configurations tested are:

\begin{itemize}
    \item Frozen Backbone: All convolutional layers were frozen and only the final classification layer \texttt{(fc)} was trained. This baseline transfer learning strategy reflects minimal adaptation.  
    \item Full Fine-Tuning: To achieve maximum adaptability, all ResNet50's layers, including the classification head and backbone, were unfrozen and trained end-to-end.
    \item Hybrid Unfreezing (Proposed): The classification head and Layers 3 and 4 of the ResNet50 backbone were unfrozen and adjusted. Earlier layers remained frozen to preserve general image features while enabling task-specific adaptation.
\end{itemize}

Table \ref{ablation-study} shows that the proposed hybrid unfreezing approach outperforms both the frozen baseline and full fine-tuning in terms of precision and the average macro F1 score. The frozen backbone model exhibits markedly reduced performance, particularly in macro F1 for BCI, underscoring the limitations of training only the classification head without backbone adaptation. Interestingly, full fine-tuning provides performance close to the hybrid method but without a significant advantage and at the cost of greater computational demand and risk of overfitting. However, this indicates that selectively fine-tuning deeper layers provides effective feature adaptation for a range of magnifications and staining conditions while maintaining generalizable low-level features.




\begin{table*}[t]
\centering
\caption{Comparison of ResNet50 training strategies in terms of classification accuracy and macro-averaged F1-score across three HER2 scoring datasets.}
\small
\setlength{\tabcolsep}{6pt}   % controls column spacing
\begin{tabular}{l|cc|cc|cc}
\hline
Configuration & \multicolumn{2}{c|}{HER2-IHC-40x-WSI} & \multicolumn{2}{c|}{BCI (10$\times$)} & \multicolumn{2}{c}{HER2-IHC-40x-Patch} \\
\cline{2-7}
 & Accuracy & Macro F1 & Accuracy & Macro F1 & Accuracy & Macro F1 \\
\hline
Frozen Backbone & 90\% & 0.85 & 73\% & 0.69 & 91\% & 0.89 \\
Full Fine-Tuning & 92\% & 0.85 & 91\% & 0.89 & 95\% & 0.94 \\
Hybrid Unfreezing (proposed) & 93\% & 0.90 & 95\% & 0.95 & 96\% & 0.95 \\
\hline
\end{tabular}
\label{ablation-study}
\end{table*}






The confusion matrices for the entire frozen backbone and full fine-tuning models, respectively, across all datasets, are shown in Figure \ref{confu_frezz}. In contrast to the frozen backbone, the hybrid and complete fine-tuning models lower misclassification errors in challenging borderline classes (1+ and 2+).  The frozen backbone shows increased confusion among equivocal cases, especially in the HER2-IHC-40x-Patch dataset, highlighting the significance of backbone fine-tuning for capturing subtle membrane staining patterns. This combined analysis underscores the effectiveness of the practical application of the hybrid unfreezing strategy in clinical HER2 scoring workflows by highlighting how well it maintains a strong balance between model accuracy and computational efficiency.



\begin{figure} [!t]
\centering
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/wsi-without-frezz.png}}\hspace{0.02\linewidth}
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/bci-without-frezz.png}}\hspace{0.02\linewidth}
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/patch-without-frezz.png}}\hspace{0.02\linewidth}
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/wsi-full-ft.png}}\hspace{0.02\linewidth}
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/bci-full-ft.png}}\hspace{0.02\linewidth}
\subfigure[]{\includegraphics[width=0.30\linewidth]{Scientific_Report_her2-Paper2/Images/patch-full-ft.png}}\hspace{0.02\linewidth}
\caption{Confusion matrices using the frozen backbone model and full fine-tuning model across three datasets. Frozen backbone model: (a) HER2-IHC-40x-WSI, (b) BCI (10×), and (c) HER2-IHC-40x-Patch. The model was trained with only the classification head unfrozen, demonstrating limited performance, particularly in borderline classes (1+ and 2+). Full fine-tuning model: (d) HER2-IHC-40x-WSI, (e) BCI (10×), and (f) HER2-IHC-40x-Patch. The model was trained end-to-end with all layers unfrozen, showing improved classification in most classes, especially in low-magnification and ambiguous cases.}
\label{confu_frezz}
\end{figure}



\section{Discussion}

Proposed ResNet50-based model achieved 96\% accuracy in HER2-IHC-40x-Patch data with nearly perfect discrimination among 3+ cases (AUC $>$ 0.999), while maintaining robustness across magnifications (10×–40×). Integration of Score-CAM with membrane-specific metrics (MAP = 79\%) provided clinically interpretable explanations that addressed the deep learning model's 'black-box' challenge. Notably, the hybrid unfreezing approach reduced the computational expenses by 72.7\% over full fine-tuning, while enabling effective deployment.


\subsection{Comparative Analysis with Prior Work}

\begin{table} [!t]
\centering
\caption{Comparative evaluation of HER2 scoring approaches across key dimensions, including dataset scale, explainability (XAI), robustness, and clinical utility.}
\resizebox{\textwidth}{!}{%
\begin{tabular}{p{1.4cm}p{1.6cm}p{1.9cm}p{1cm}p{1.9cm}p{3.6cm}p{3.9cm}}
\hline
Study & Model & Dataset & Result  & XAI  & Key Observations & Limitations \\
\hline
\cite{kuklyte2021evaluation} & CNN  & Single-center (40×) & 91\% & Grad-CAM & High accuracy at 40× but fails at 10× ($\Delta$F1 $>$ 0.15) & Magnification-sensitive; no quantitative XAI validation \\
\cite{wu2024challenges} & InceptionV3 & BCI (10×) & 89\% & None & Focused on accuracy, lacks clinical interpretability. & Black-box model; no multi-magnification testing. \\
\cite{rguibi2022cxai} & ResNet50 & Private IHC slides & 88\% & Grad-CAM & Heatmaps misalign with membranes (35\% MAP). & Subjective XAI; no pathologist benchmarks. \\
\cite{wang2024ms}  & HRNet & Multi-center (10×/40×) & 93\% & Attention maps & Robust to magnification but high compute cost. & Computationally expensive; no membrane-specific metrics. \\
\cite{liu2021swin} & SwinT & TCGA-WSI & 94\% & Layer-wise relevance & Strong performance but requires large datasets. & Data-hungry; lower generalizability to small cohorts. \\
\cite{dutta2025corr} & Corr-A-Net & BCI &  94.26\%  & Grad-CAM & Strong Predicts HER2 from H\&E only using correlated features; interpretable \& confident. & Trained/tested on single-institution data; Grad-CAM not yet validated by experts. \\
\cite{pateel2024automated} & GoogleNet, ResNet-50, ViT & Private &  95.43\%  & None & Patch-based HER2 scoring aggregated via majority voting to WSI-level results. & No external validation; 1+ class is underrepresented; no XAI employed \\
\cite{nabi2025explainable} & Custom CNN \& DenseNet121 & HER2-IHC-40x & 93\% & Grad-CAM \& SHAP & New dataset curation, and patch based scoring & No external validation, data imbalance in minor classes  \\
Our study & ResNet50 & BCI, HER2-IHC-40x & 96\% & Score-CAM  & Multi-magnification robustness. & Slightly lower 1+ sensitivity. \\
\hline
\end{tabular}%
}
\label{comparitive}
\end{table}



Recent studies in HER2 computational pathology have primarily focused on either high-magnification analysis approaches \cite{kuklyte2021evaluation}, or architecturally complex solutions such as HRNet \cite{wang2024ms} and SwinT  \cite{liu2021swin}, which often trade computational efficiency for performance. Table \ref{comparitive} provides a comparative summary of existing approaches and highlights how our proposed ResNet50-based method addresses several key limitations. Compared to the CNN-based method by \cite{kuklyte2021evaluation}, which performs well at 40× but suffers at 10× ($\Delta$F1~$<$~0.15), our model demonstrates strong cross-magnification performance with ($\Delta$F1~$<$~0.04) across 10× and 40× resolution, confirming improved robustness without requiring complex multi-scale architectures. In terms of explainability, our method outperforms Grad-CAM-based approaches [\cite{rguibi2022cxai} \cite{pateel2024automated} employing Score-CAM with quantitative validation through Membrane Activation Precision (MAP = 79\%), explanation consistency, and relevance coverage. In contrast, \cite{rguibi2022cxai} reported only 35\% MAP alignment using Grad-CAM. Compared to SwinT \cite{liu2021swin} and HRNet \cite{wang2024ms}, our approach achieves comparable precision (96\%) while using a simpler and lighter ResNet50 architecture. Despite being robust to magnification, HRNet lacks membrane-specific explainability metrics and has a high computing cost. SwinT requires large data sets and propagation of relevance in layers, which is impractical in many therapeutic contexts. Furthermore, previous models such as InceptionV3 \cite{wu2024challenges} and the GoogleNet/ResNet50 ensemble \cite{pateel2024automated} did not integrate explainability, evaluate performance on magnification scales, or provide clinical interpretability. Our approach combines robust classification, multi-resolution adaptability, and quantifiable explainability, a combination absent in existing literature.


\subsection{Clinical Relevance and Model Adaptability}
The ResNet50 model demonstrates strong potential for clinical use in HER2 expression classification by reliably distinguishing across different HER2 levels. Its high accuracy, particularly class 3+ (strong HER2 expression), is of extreme significance for the identification of HER2-positive breast cancer cases, which are vital for treatment. The incorporation of Explainable AI in the form of Score-CAM enhances model transparency by localizing tissue regions most influential to prediction. This interpretability is essential for clinicians, allowing them to validate the model’s decisions and increase trust in automated systems. The model's ability to generalize well across different datasets with varying magnifications (10x and 40x) enhances its suitability for clinical workflows, where data resolution and quality can vary. Overall, the model's performance and XAI results make it a valuable tool for clinical practice, allowing more confident decision-making in HER2 diagnostics.

\subsection{Limitations and Future Work}
Despite achieving 96\% accuracy, our ResNet50 model exhibits reduced sensitivity to weak HER2 expressions (class 1+ F1=0.85 vs. 3+ F1=0.99), particularly when trained on lower-resolution datasets like BCI (10$\times$), reflecting known challenges in manual scoring of weak membrane staining patterns \cite{wolff2018human}. While Score-CAM provided quantitative validation by Membrane Activation Precision and Explanation Consistency to assess the alignment and consistency of model explanations, it is important to note that formal validation by pathologists of these explanations has not been conducted. 

Future work will focus on addressing these limitations, including the synthetic augmentation of class 1+ cases using stain-aware generative models to improve performance in weak HER2 expressions. The integration of multimodal clinical data will also be explored to improve the generalizability of the model, particularly for cases on the borderline, and to improve overall performance in various clinical settings. Furthermore, future studies will seek to involve pathologists to validate and refine the model explanations in clinical environments. This step will be essential to improve clinical relevance, ensure trust, and further advance AI-driven HER2 diagnostics.



\section{Conclusion} 
This study demonstrates the effectiveness of the ResNet50 model in the automated classification of HER2 expression from histopathological images with satisfactory performance across datasets with varying magnifications and resolutions. The integration of Score-CAM enhances model interpretability, enabling clinicians to understand the decision-making process, which is critical for clinical adoption. The model showed robustness on high-resolution patch-based and BCI datasets, proving its adaptability to different imaging conditions. However, there remain challenges in improving the classification of weak HER2 expressions and generalization across different clinical settings. In conclusion, the combination of high-performance deep learning with explainable AI offers a promising solution to HER2 diagnostics, with the potential to improve precision and clinical decision-making in targeted therapies.

\section*{Author Contribution Declaration}
Md Serajun Nabi, Thinley Yeshey Choden, S M Asiful Islam Saky, Dema Yuden, and Mohammad Faizal Ahmad Fauzi contributed to the conceptualization and design of the study. Md Serajun Nabi developed the methodology, implemented the deep learning framework, conducted experiments, and performed the formal analysis. Md Serajun Nabi prepared the original draft of the manuscript. Thinley Yeshey Choden and S M Asiful Islam Saky, Dema Yuden contributed to manuscript review and editing. Hezerul Bin Abdul Karim and Mohammad Faizal Ahmad Fauzi supervised the research, provided critical revisions, directed the overall project, and acquired the research funding. All authors reviewed and approved the final manuscript.

\section*{Data Availability}
The dataset supporting this study is published in \cite{nabi2025her22}, with raw data available on Zenodo \url{https://www.kaggle.com/datasets/gunesevitan/breast-cancer-metabric}.



\section*{Funding Declaration}
The work is funded by the GLU Joint Research Collaboration Grant (MMUE/230049)


\bibliographystyle{ieeetr} 
\bibliography{Scientific_Report_her2-Paper2/Referencess}


\end{document}