Paper · Evaluation and safety · Version 1
Comparative analysis of open-source locally deployed LLMs for extraction of diagnostic information from clinical CMR imaging reports
First published: Scientific Reports, . Original
Copyright the authors. Licensed under Creative Commons Attribution 4.0 International.
This page holds the text of the paper, converted to HTML; figures may be left out.
Nine open-source models were run locally to pull diagnoses from heart MRI reports. Several reached high accuracy, which suggests hospitals can do this kind of extraction without sending reports outside.
Abstract
We investigated the utilization of privacy-preserving, locally-deployed, open-source Large Language Models (LLMs) to extract diagnostic information from free-text cardiovascular magnetic resonance (CMR) reports. We evaluated nine open-source LLMs on their ability to identify diagnoses and classify patients into various cardiac diagnostic categories based on descriptive findings in 109 clinical CMR reports. Performance was quantified using standard classification metrics including accuracy, precision, recall, and F1 score. We also employed confusion matrices to examine patterns of misclassification across models. Most open-source LLMs demonstrated exceptional performance in classifying reports into different diagnostic categories. Google’s Gemma 2(27B) model achieved the highest average F1 score of 0.98, followed by Qwen2.5(32B) and DeepSeekR1(32B) with F1 scores of 0.96 and 0.95, respectively. All other evaluated models attained average scores above 0.93, with Mistral(7B) and DeepSeekR1(7B) being the only exceptions. The top four LLMs outperformed our board-certified cardiologist (F1 score of 0.94) across all evaluation metrics in analyzing CMR reports. Our findings demonstrate the feasibility of implementing open-source, privacy-preserving LLMs in clinical settings for automated analysis of imaging reports, enabling accurate, fast and resource-efficient diagnostic categorization.
Introduction
Cardiovascular magnetic resonance (CMR) imaging has emerged as a cornerstone of non-invasive cardiovascular diagnostics, offering unparalleled advantages for assessing cardiac structure, function, and tissue characteristics. Unlike other imaging modalities, CMR provides unique insights into myocardial viability, inflammation, infiltration and fibrosis.
CMR interpretation requires synthesizing complex imaging data into focused and clinically meaningful reports. These reports typically include structured sections on patient history, imaging protocols, quantitative measurements, qualitative observations and—if possible—a final (suspected) diagnosis. While structured reporting templates promoted by the Society for Cardiovascular Magnetic Resonance (SCMR) improve consistency, many clinicians still rely on narrative to capture nuanced observations and to describe possible differential diagnoses, leading to heterogeneity in format, terminology, and detail. This variability complicates data curation for research, quality assurance, and longitudinal patient monitoring.
Large Language Models (LLMs) are rapidly transforming numerous fields, and healthcare is no exception, with their capacity to revolutionize medical report analysis. Recent research underscores the potential of LLMs in diverse medical applications, from clinical note summarization to assisting in diagnoses by analyzing complex patient data. LLMs like ChatGPT are being leveraged in clinical settings, demonstrating both impressive capabilities and areas for further development in their integration into healthcare.
The application of LLMs to “clinical report analysis” is associated with substantial challenges, particularly concerning patient privacy and data security. Closed-source LLMs, such as OpenAI’s ChatGPT, often necessitate accessing their capabilities through APIs, which inherently involves sharing patient data with external servers. This data transfer raises substantial compliance issues with General Data Protection Regulation (GDPR), as sensitive patient information may be processed outside of secure, local environments.
An alternative approach to mitigate these privacy concerns involves the deployment of locally run, open-source LLMs within hospital infrastructures. This strategy offers several advantages over cloud-based models. Primarily, processing clinical reports with a local LLM keeps patient data within the hospital’s secure network, significantly reducing the risk of external data breaches and facilitating compliance with stringent regulations like GDPR.
The present feasibility study aims to demonstrate the use of open-source LLMs in clinical settings for secure and efficient analysis of text-based CMR imaging reports. By evaluating the performance of locally deployed LLMs on these reports, we showcase an alternative to cloud-based solutions, which often raise privacy concerns when handling sensitive patient data.
Results
We evaluated the performance of nine open-source LLMs on a dataset of 109 clinical CMR reports, each assigned to one of eight diagnostic categories based on expert-defined ground truth labels. The task consisted of classifying free-text narrative report sections into the corresponding cardiac diagnosis. Model predictions were compared against the reference labels using standard evaluation metrics, including accuracy, precision, recall, and weighted F1 score.
A detailed analysis of model performance in CMR imaging report classification revealed consistently strong results: The bar chart in Fig. 1 compares nine LLMs, showing that most achieved excellent scores above 0.93. The Gemma 2(27B) model demonstrated the highest overall performance, with an average score exceeding 0.97 across all metrics. It was closely followed by Qwen2.5(32B) and DeepSeek-R1(32B), which attained F1 scores of 0.96 and 0.95, respectively. The reasoning model of Qwen2.5(32B), the QWQ(32B) model, achieved a comparable score to, and slightly higher than, that of our cardiologist.
Fig. 1 LLM comparison in terms of different evaluation metrics. The best model is determined based on the highest mean score across metrics ordered from left to right. The performance of human evaluator is highlighted.
The Mistral(7B) model performed slightly lower, with scores around 0.89, while DeepSeek-R1(7B) had the weakest performance at approximately 0.76. Most models exhibited consistent performance across all four metrics, indicating balanced classification capabilities with minimal trade-offs.
Figure 2 shows the weighted performance of F1 with 95% bootstrap confidence intervals for all evaluated models, including human benchmark, with bracket annotations indicating pairwise comparisons against Gemma 2(2B) and asterisks marking statistically significant differences ().
Fig. 2 Weighted F1 scores with 95% bootstrap confidence intervals for all evaluated models and the human benchmark. Confidence intervals were estimated using a percentile bootstrap approach with resampling at the patient level (n = 1000 bootstrap iterations). Gemma2(27B) achieved the highest weighted F1 score. Vertical brackets indicate pairwise comparisons against Gemma2; a single * denotes statistically significant differences ().
Figure 3 presents confusion matrices that visualize each model’s classification performance across eight cardiac diagnostic categories based on text-based CMR imaging reports. These matrices illustrate the relationship between true diagnostic labels (rows) and predicted labels (columns), with diagonal cells representing correct classifications and off-diagonal cells indicating errors. The intensity of the blue coloration reflects the number of cases in each cell.
Fig. 3 depicts confusion matrices illustrating model performance and human performance in classifying eight cardiac diagnostic categories from unstructured imaging reports. Strong diagonal dominance in Gemma 2(27B), DeepSeek-R1(32B), and Qwen2.5(32B), indicates high accuracy, with occasional misclassifications observed for myocarditis (MYO).
Overall, most models showed a strong diagonal dominance, particularly Gemma 2(27B), DeepSeek-R1(32B), Qwen2.5(32B), and Llama3.3(70B), indicating high classification accuracy. Normal cardiac findings and HCM were consistently classified with perfect or near-perfect accuracy. However, some categories showed characteristic misclassification patterns: For example, MYO was occasionally misclassified as ischemic (ICM) or dilated cardiomyopathy (DCM), while CS was sometimes confused with other conditions, particularly in the Mistral model. The DeepSeek-R1(7B) model showed the highest rate of misclassification, especially for cardiac amyloidosis (CA), myocarditis, ICM and DCM. These patterns underscore the strengths of top-performing models in distinguishing cardiac conditions from unstructured or less structured (narrative) text while highlighting persistent challenges in differentiating pathologically similar diseases. Myocarditis, in particular, was frequently misclassified as other cardiomyopathies, suggesting inherent difficulties in its classification, even for our human evaluator.
Figure 4 shows the execution time (seconds per patient) for each LLM evaluated and average time for our cardiologist evaluator. The results reveal significant differences in computational efficiency. The fastest model, LLaMA 3.2(3B), had an average execution time of 0.41 seconds per patient, followed by Mistral(7B) (0.59s) and Qwen2.5(32B) (1.35s). These models exhibit high computational efficiency, making them well-suited for real-time or high-throughput clinical applications. Gemma 2(27B) (1.61s) and Llama 3.3(70B) (3.18s) also demonstrated relatively low execution times, suggesting that smaller or optimized architectures can process reports with minimal latency.
Fig. 4 shows the execution time (seconds per patient) for each LLM and human evaluator, highlighting significant efficiency differences. Smaller models like Llama 3.2(3B) and Mistral(7B) were the fastest, while larger models, such as DeepSeek-R1(70B), had the highest execution time without a clear accuracy advantage.
Discussion
This study demonstrates the effectiveness of open-source, locally run LLMs in analyzing CMR imaging reports to automatically and quickly identify patient diagnoses based on descriptive report findings. Our present results indicate that most LLMs achieve exceptionally high scores across various evaluation metrics, highlighting their potential for automated diagnosis extraction from text-based imaging reports, circumventing the need for labor-intensive supervised training data curation.
The top four LLMs outperformed our board-certified cardiologist across all evaluation metrics in analyzing and classifying CMR reports. Notably, larger models like DeepSeek-R1(32B) and QwQ(32B) required significantly higher execution times (26.37s and 28.64s), with DeepSeek-R1(70B) recording the highest at 50.77 seconds per patient. Our evaluator spent a similar time of 23.79 seconds per patient.
Importantly, DeepSeek-R1(70B) that had the highest execution time, performed worse in classification accuracy, indicating that increased computation does not necessarily improve performance. The trade-off between model complexity and computational efficiency depends on the intended clinical use case. While predictive performance remains the primary requirement for diagnostic reliability, computational efficiency may also be relevant in settings involving large-scale processing of imaging reports or integration into structured reporting workflows.
Our findings show that existing LLMs enable classification performances above 0.93 across most evaluation metrics, highlighting their effectiveness and usefulness in automating the analysis of imaging reports. Bootstrap-based confidence intervals indicate that while some lower-performing models differ significantly from the top-performing model, differences among the highest-performing models are small and often not statistically significant, suggesting comparable performance at the upper end.
Analysis of the confusion matrices revealed consistent patterns of misclassification across both human expert and model evaluations. In the human reference assessment, uncertain cases were assigned an “unknown” label when a single definitive diagnostic category could not be determined from the report description alone. Misclassification is most frequently associated with myocarditis (MYO) and cardiac sarcoidosis (CS), reflecting its heterogeneous presentation and overlapping imaging features with other cardiomyopathies. Similarly, model-based errors were most pronounced in myocarditis cases. Even the best-performing model (Gemma2 27B) misclassified some myocarditis cases as hypertrophic cardiomyopathy (HCM) or ischemic cardiomyopathy (ICM). Across all evaluated models, myocarditis remained the most challenging diagnostic category. Overall, these patterns indicate that misclassifications are primarily driven by clinical ambiguity and overlapping imaging phenotypes rather than random error, and they mirror difficulties also observed in expert human interpretation.
Local deployment of open-source LLMs avoids external data transfer and may reduce data-sharing risks, supporting alignment with data protection principles such as GDPR Article 32 by keeping processing within hospital infrastructure. However, this does not guarantee comprehensive privacy protection or full regulatory compliance, which depend on broader technical and organizational safeguards. Potential risks, including protected health information (PHI) leakage and model vulnerabilities, are not addressed here. Notably, no fine-tuning on clinical data was performed, limiting risks related to data memorization. These considerations remain important for future work and clinical deployment.
Beyond the scope of this study, an important potential application of locally deployed LLMs is their use as automated data curation tools for large-scale clinical datasets. By systematically processing unstructured clinical reports, such models may enable scalable extraction of diagnostic categories, which could serve as pseudo-ground truth labels for downstream machine learning applications, including model training and retrospective cohort analysis. However, the observed misclassification patterns, particularly for myocarditis and cardiomyopathies, highlight the need for appropriate risk mitigation strategies. In practical settings, LLM-generated labels should be used in a supportive or semi-automated manner, for example with human verification for uncertain or clinically ambiguous cases, rather than as fully autonomous diagnostic outputs. This is particularly important for conditions with overlapping imaging features, where even expert interpretation may be challenging.
One limitation of this study is the limited number of imaging reports (n = 109) used to evaluate LLM performance, as well as the reliance on single-center data, which may limit the robustness and generalizability of the reported findings. Although the dataset was carefully curated to include multiple clinically relevant diagnostic categories with expert-validated ground truth labels, the sample size may not fully capture the variability present in broader clinical populations or across institutions.
To mitigate this limitation, we performed a bootstrap-based analysis to assess the stability and variability of model performance. However, such internal validation does not replace the need for external validation. Future work will therefore focus on evaluating the proposed approach on a substantially larger cohort (>4,000 cases) and, where possible, on multi-center datasets to better assess generalizability across different clinical settings and reporting styles.
A further limitation of this study is the use of multilingual Llama 3.3 model to translate reports from German to English. Although a consistent pipeline was applied, translation may introduce subtle semantic shifts or loss of clinical nuance, potentially affecting model performance. Future work should evaluate models directly on native-language reports. An ablation analysis comparing performance on original German text using multilingual models versus translated English text would provide further insight into this effect and represents an important direction for future work.
Methods
Cardiovascular magnetic resonance imaging reports
We retrospectively analyzed 109 CMR imaging reports from patients scanned at the Cardiac MRI Center of the University Hospital Munster in Germany. The cohort included various cardiac diseases: hypertrophic cardiomyopathy (HCM, n = 15), cardiac amyloidosis (CA, n = 14), cardiac sarcoidosis (CS, n = 14), myocarditis (MYO, n = 14), ischemic cardiomyopathy (ICM, n = 17), dilated cardiomyopathy (DCM, n = 16), and normal controls (n = 19). A cardiologist with extensive experience selected the reports based on well-established diagnostic criteria.
All reports were written in German following the structured reporting guidelines for CMR examinations and were reviewed by a senior cardiologist. The study protocol is in accordance with the ethical guidelines of the 1975 Declaration of Helsinki and with the laws and regulations of Germany. The protocol was approved by the local ethics committee (Ethikkommission der Ärztekammer Westfalen-Lippe) of the University Hospital Muenster, Germany (ID 2022-539-f-S). Written informed consent was obtained from the participants.
Each CMR report consists of two sections. The first section provides structured (primarily) quantitative data including ventricular volumes, ejection fractions, flow measurements, quantitative mapping, and aortic area measurements. The second section is less structured narrative text describing diagnostic findings and observations.
Ground truth diagnostic labels were assigned by a board-certified cardiologist with expertise in cardiovascular magnetic resonance imaging. For each case, a single primary diagnosis was determined based on a comprehensive evaluation of the full report, including both quantitative measurements (e.g., ventricular volumes, ejection fraction, and tissue characterization parameters) and the narrative description of imaging findings. The assignment of diagnostic categories was guided by established clinical criteria and current CMR reporting standards. In cases where reports contained non-definitive or suggestive language (e.g., “findings suggestive of”), the cardiologist integrated all available information within the report to determine the most likely diagnosis, reflecting standard clinical decision-making practice.
Preprocessing
Each CMR report was divided into a structured quantitative section and an unstructured narrative section in the first pre-processing step. The extraction of the narrative component was performed using a rule-based approach based on consistent report formatting, including predefined section headers and delimiters within the standardized reporting template. This ensured consistent separation of quantitative measurements from descriptive diagnostic content. The narrative section of the report is free-text describing the major findings and observations from the images and quantitative analyses. The second step includes translating the clinical text from German to English in order to enable analysis using different LLMs. The translation needs to be performed due to the fact that most of open-source LLMs have been trained on English text. The multilingual Llama 3.3(70B) model from Meta was used to translate text from German to English. The final step, analyzing the English text, involves setting up open-source LLMs locally and composing a prompt with the extracted context. Different steps are depicted in Fig. 5. This Figure also includes a representative anonymized example of a CMR report, illustrating both the structured quantitative measurements and the narrative description of findings used as model input.
Fig. 5 The proposed pipeline for analyzing imaging reports to automatically extract diagnostic information from the text, including three steps to (1) split clinical reports into a first quantitative and a second narrative information, (2) translate the narrative text from German to English, and (3) analyze the English text with open-source locally-run LLMs to infer the diagnosis.
Framework and models
To enable privacy-preserving deployment of LLMs in healthcare, we leveraged Ollama, an open-source framework for local LLM inference, eliminating the need to transfer sensitive patient data externally. This approach reduces the need to transfer sensitive patient data to external systems and thereby minimizes potential exposure of confidential information, while maintaining processing within the local hospital infrastructure under controlled access conditions. Inference was performed using default model settings, with the exception that the temperature parameter was set to 0 to ensure deterministic and fully reproducible outputs. No fine-tuning or task-specific hyperparameter tuning was performed. This standardized setup was used to ensure comparability across all models and reproducibility of results.
For further text evaluation, we compared the performance of nine different open-source LLMs: Meta’s Llama 3.2(3B) and Llama 3.3(70B), Google’s Gemma 2(27B), Mistral AI’s Mistral(7B), Deepseek’s distilled R1 (70B, 32B, 7B), and Alibaba’s Qwen2.5 (32B) and QwQ(32B) models. These models include both reasoning LLMs, which are optimized for complex inference and decision-making (e.g., Deepseek, QwQ), and non-reasoning models, which prioritize speed and efficiency in text processing (e.g., Llama, Gemma, Mistral, and Qwen). For all evaluated models, the parameter count is reported as a measure of model size and complexity. The parameter count refers to the total number of learnable weights in the neural network, which is commonly used as an indicator of model capacity and computational scale.
All models were evaluated using a standardized prompt template consisting of three components: an instruction defining the classification task, the translated narrative CMR findings, and a constrained output format requiring selection of one label from a predefined set of diagnostic categories. The same prompt structure was applied uniformly across all models to ensure comparability, without model-specific prompt tuning or optimization. The full prompt templates and implementation details are publicly available in the accompanying open-source code repository to ensure reproducibility of the evaluation framework.
Statistics
We conducted experiments to evaluate the performance of various models in identifying heart diagnoses from unstructured text. The LLMs are provided with context, which consists of descriptive findings from imaging reports, along with instructions to select the appropriate diagnostic category from a predefined list. To assess performance, the models generate responses in a structured JSON format, allowing for direct comparison with the ground truth diagnosis. Model performance was evaluated using accuracy, precision, recall, and F1 score. The weighted F1 score was selected as the primary evaluation metric due to the multi-class nature of the classification task. Although the dataset was relatively balanced across diagnostic categories (n = 14–19 per class), weighted F1 provides a robust overall measure by combining precision and recall while accounting for small variations in class distribution. This ensures a balanced evaluation of model performance across all diagnostic categories. To further evaluate the robustness of model performance, we performed a nonparametric percentile bootstrap analysis of weighted F1 at the patient level using 1000 resampling iterations. For each model, we computed 95% confidence intervals from the bootstrap distribution. Pairwise differences versus Gemma 2(27B) were then evaluated with paired bootstrap resampling on the same test set. Additionally, we measure and record the execution time for each model. All models were run on a single NVIDIA A40 GPU with 48 GB of Memory.
We evaluated the performance of models against a board-certified cardiologist with one year of experience and expertise in analyzing CMR scans. The cardiologist evaluation was performed using the original German CMR reports. In addition to the report text, the evaluator had access to representative imaging data, including three slices for each of the short-axis, four-chamber, and late gadolinium enhancement sequences, reflecting standard clinical diagnostic practice.
Data availability
The datasets analyzed during the current study can be made available from the corresponding author upon reasonable request. The code is available at https://github.com/sinaamirrajab/llm_CMR_report_analysis.
References
- [1] McDonagh, T. A. et al. 2021 ESC guidelines for the diagnosis and treatment of acute and chronic heart failure. Eur. Heart J. 42 (2021).
- [2] Ponikowski, P. ESC guidelines for the diagnosis and treatment of acute and chronic heart failure. Eur. Heart J. 37 (2016).
- [3] Hundley, W. G. Society for cardiovascular magnetic resonance (SCMR) guidelines for reporting cardiovascular magnetic resonance examinations. J. Cardiovasc. Magn. Reson. 24 (2022).
- [4] Bunck, A. C. Structured reporting in cross-sectional imaging of the heart: Reporting templates for CMR imaging of cardiomyopathies. RoFo Fortschritte auf dem Gebiet der Rontgenstrahlen und der Bildgebenden Verfahren 192 (2020).
- [5] Zhang, K. Revolutionizing health care: The transformative impact of large language models in medicine. J. Med. Internet Res. 27 (2025).
- [6] Thirunavukarasu, A. J. et al. Large language models in medicine. Nat. Med. 29, 1930–1940 (2023).
- [7] Meng, X. et al. The application of large language models in medicine: A scoping review. iScience 27, 109713 (2024).
- [8] Clusmann, J. The future landscape of large language models in medicine. Commun. Med. 3 (2023).
- [9] Park, Y. J. Assessing the research landscape and clinical utility of large language models: a scoping review. BMC Med. Inform. Decis. Mak. 24 (2024).
- [10] Gilbert, S. et al. Large language model ai chatbots require approval as medical devices. Nat. Med. 29, 2396–2398 (2023).
- [11] Pauws, S. Bridging the gap: A practical step-by-step approach to warrant safe implementation of large language models in healthcare. Front Artif. Intell. 8 (2025).
- [12] Grattafiori, A. et al. The llama 3 herd of models (2024). arXiv:2407.21783v3.
- [13] G. & T. Gemma 2: Improving open language models at a practical size (2024). arXiv:2408.00118v3.
- [14] Jiang, A. Q. Mistral 7b (2023). arXiv:2310.06825v1.
- [15] DeepSeek-AI et al. Deepseek-r1: Incentivizing reasoning capability in LLMs via reinforcement learning (2025). arXiv:2501.12948v1.
- [16] Qwen et al. Qwen2.5 technical report (2024). arXiv:2412.15115v2.
Acknowledgments
The authors acknowledge the Institute of Medical Informatics (IMI), University ofMünster, Germany, for providing GPU computing resources that were partially used in this study.
Funding
This study was partially supported by a research grant from the “Peter-Lancier-Stiftung”, Hamburg, Germany (project title “OPT-AI-CMR”, ID BD6505565).
Contributions
S.A., first author, conceived the study, designed and conducted the experiments, and wrote the main manuscript text. V.V. contributed to the experimental design and provided domain expertise throughout the research process. M.B. analysed the results and contributed to interpretation and visualization of the data. A.Y. supervised the project and provided critical revisions and clinical guidance. All authors reviewed and approved the final manuscript.
Ethics declarations
Competing interests
The authors declare no competing interests.