# Stroke Lesion Segmentation in Clinical Workflows: A Modular, Lightweight, and Deployment-Ready Tool

Yann Kerverdo, Florent Leray, Youwan Mahé, Stéphanie Leplaideur, Francesca Galassi

► To cite this version:

Yann Kerverdo, Florent Leray, Youwan Mahé, Stéphanie Leplaideur, Francesca Galassi. Stroke Lesion Segmentation in Clinical Workflows: A Modular, Lightweight, and Deployment-Ready Tool. 2025. [hal-05335119](https://hal.science/hal-05335119v1)

HAL Id: hal-05335119

https://hal.science/hal-05335119v1

Preprint submitted on 28 Oct 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# STROKE LESION SEGMENTATION IN CLINICAL WORKFLOWS: A MODULAR, LIGHTWEIGHT, AND DEPLOYMENT-READY TOOL

Yann Kerverdo¹ Florent Leray¹ Youwan Mahé¹,² Stéphanie Leplaideur¹,³,⁴ Francesca Galassi¹

¹ Univ Rennes, Inria, CNRS, Inserm, IRISA UMR 6074, Empenn, Rennes, France

² Siemens Healthineers, Courbevoie, France

³ CHU Rennes, Physical Medicine and Rehabilitation Department, Rennes, France

⁴ Centre de Kerpape, Ploemeur, France

## ABSTRACT

Deep learning frameworks such as nnU-Net achieve state-of-the-art performance in brain lesion segmentation but remain difficult to deploy clinically due to heavy dependencies and monolithic design. We introduce *StrokeSeg*, a modular and lightweight framework that translates research-grade stroke lesion segmentation models into deployable applications. Preprocessing, inference, and postprocessing are decoupled: preprocessing relies on the Anima toolbox with BIDS-compliant outputs, and inference uses ONNX Runtime with *Float16* quantisation, reducing model size by about 50%. *StrokeSeg* provides both graphical and command-line interfaces and is distributed as Python scripts and as a standalone Windows executable. On a held-out set of 300 sub-acute and chronic stroke subjects, segmentation performance was equivalent to the original PyTorch pipeline (Dice difference < $10^{-3}$), demonstrating that high-performing research pipelines can be transformed into portable, clinically usable tools.

**Index Terms—** stroke lesion segmentation, nnU-Net, ONNX Runtime, clinical deployment, BIDS, software engineering

## 1. INTRODUCTION

Stroke is a leading cause of long-term disability worldwide [1]. In the sub-acute and chronic phases, structural magnetic resonance imaging (MRI) is routinely used to assess lesion extent, monitor recovery, and guide rehabilitation strategies [2]. Accurate lesion segmentation is essential for quantifying brain damage and linking imaging to functional outcomes. Manual delineation, however, is time-consuming and subject to inter-rater variability [3], motivating automated methods. Recent deep learning advances, notably nnU-Net [4], have achieved state-of-the-art performance in post-stroke lesion segmentation on datasets such as ATLAS v2.0 [5]. Di Matteo et al. [6] further trained stroke-specific nnU-Net v2 models on T1-weighted (T1w)

and T1w+FLAIR MRI, releasing pretrained weights and inference code. We use these models as a case study to present a general framework for translating nnU-Net pipelines into lightweight, deployable tools applicable across medical imaging tasks.

Existing toolkits such as TorchIO [7] and pymia [8] support reproducible preprocessing for research, while system-level frameworks like MONAI Deploy [9] and PACS-AI [10] enable integration with DICOM and PACS infrastructures. However, these solutions do not address a key practical challenge: transforming a pretrained research model into a lightweight application that can run directly on a clinical workstation.

This work addresses this limitation by introducing *StrokeSeg* [11], a versatile application that translates high-performing research models into deployable, clinically usable tools. Specifically, it (i) restructures the nnU-Net pipeline into independent, interoperable components, (ii) improves computational efficiency and portability through ONNX Runtime and *Float16* quantisation, and (iii) delivers a reproducible implementation suitable for clinical research workflows.

## 2. METHODS

### 2.1. Architecture overview

Our goal was to transform the stroke-specific nnU-Net-based segmentation pipeline of Di Matteo et al. [6] into a lightweight, portable, and reproducible research tool. The design needed to satisfy two distinct user groups: (i) clinical researchers, who require a simple, installable application for routine analysis, and (ii) computer vision researchers, who expect transparency and modularity for further development. Bridging these domains - computer vision research, software engineering, and clinical practice - introduces specific technical and usability constraints (Fig. 1). To address them, the development was structured along three axes: (1) modular architecture, separating preprocessing, inference, and post-processing; (2) performance optimisation through runtime and model-level improvements; and (3) packaging for repro-
ducible, cross-platform deployment. Two packaging targets were defined to reflect typical usage scenarios: Windows systems for clinical research applications and Linux systems for computer vision research and high-performance computing (HPC) environments.

<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Challenges at the intersection of research, engineering, and clinical practice. Each overlap highlights domain-specific constraints addressed in this work.</figcaption></figure>

## 2.2. Scientific package

The original nnU-Net-based pipeline [4, 6] was refactored into three independent stages.

**Preprocessing.** Brain extraction and spatial normalisation are performed with the Anima toolbox [12], wrapped in a dedicated module. Both monomodal (T1w) and bimodal (T1w + FLAIR) inputs are supported; FLAIR volumes, when provided, are rigidly registered to T1w. Intermediate files are organised following BIDS conventions to ensure traceability and interoperability.

**Inference.** Pretrained models from [6] were exported to the ONNX graph format and executed with ONNX Runtime, removing heavy training-only dependencies. As in nnU-Net [4], the inference module implements patch-based prediction and Gaussian-weighted merging. Inference can be executed on either CPU or CUDA backends, and only the required dependencies are packaged for each target.

**Postprocessing.** Network logits are converted to probability maps via softmax. The lesion channel produces a probability map and a binary mask after configurable thresholding (default 0.5). Optionally, outputs can be saved in MNI space, with inverse transforms applied to recover subject-space results.

## 2.3. Performance-oriented inference

Inference performance was compared between the native PyTorch implementation and the ONNX Runtime version. The ONNX-based approach markedly reduced software dependencies and overall package size (Sec. 3.2) while preserving accuracy (Sec. 3.1). Model weights were converted from

Float32 to Float16, reducing storage requirements by about 50%. After preliminary optimisations, brain extraction emerged as the main runtime bottleneck. To address this, StrokeSeg introduces two optimisations: (i) a dedicated Brain Extraction Only mode, and (ii) a caching mechanism allowing either re-use of previously processed data or loading of externally prepared brain-extracted volumes, thereby avoiding redundant computations. During inference, GPU acceleration is used automatically when a compatible CUDA runtime is available; otherwise, execution seamlessly falls back to the CPU. This behaviour is essential in clinical environments, where most workstations lack discrete CUDA GPUs.

Runtime measurements (Sec. 3.2) were obtained on two representative hardware configurations: (1) an Ultrabook laptop (Intel i7-10610U CPU, 16 GiB RAM, no dedicated GPU) representing typical clinical research hardware; and (2) a workstation laptop (Intel i7-13850HX CPU, NVIDIA RTX 5000 Ada GPU, 32 GiB RAM) representing a computer vision research setup. Ten subjects T1w were processed with the monomodal pipeline using the 16-bit quantised model executed via ONNX Runtime. Runtime measurements were aggregated across three processing stages: brain extraction, registration, and model inference.

## 2.4. Packaging and distribution

### 2.4.1. Main packaging target

For classical Windows-based clinical environments, StrokeSeg is packaged as a fully self-contained application using Embedded Python and an NSIS installer generated via CMake/CPack. Self-containment is essential for clinical end users, who typically have limited interaction with command-line tools. To ensure a user-friendly experience, a lightweight C++ bootstrapper launches the Python graphical interface, hides the console window, and presents the software as a single executable (Fig. 2). This bootstrapper serves as the main entry point, supporting three modes: command-line (headless), graphical (GUI), and combined debug mode. The installer bundles all required dependencies, removing the need for a system-wide Python installation or internet access to download models. This fully contained build ensures reproducibility, as all package versions are fixed at compile time, and avoids conflicts with any existing Python environments. The resulting package supports OS-compliant installation and uninstallation procedures, providing clean integration and removal.

### 2.4.2. Secondary packaging targets.

For Linux-based research environments, the scientific package is deployed via a Bash script that installs all dependencies in the appropriate directories within a Python virtual environment. This setup requires root privileges, internet access, and sufficient Bash expertise to manage potential edge cases.
<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Overview of the *StrokeSeg* packaging workflow. The CMake project compiles the C++ launcher and gathers the scientific Python modules, embedded Python environment, and pretrained models. CPack then builds a platform-specific installer (e.g., NSIS for Windows) supporting both graphical and command-line execution. The resulting package can be launched directly by end users without manual environment configuration.</figcaption></figure>

## 2.5. Software design and extensibility

Model management features include ONNX model registration and selection. The architecture enables transparent integration of any 3D nnU-Net model after ONNX conversion, allowing rapid adaptation to new MRI modalities (e.g., T2w, T1c) or to other lesion types such as traumatic brain injury and multiple sclerosis. The codebase is organised into three repositories: (i) the C++ bootstrapper, (ii) the build and packaging scripts using CMake/CPack, and (iii) the core Python scientific package. The CMake/CPack repository provides a simple, dependency-free build process that automatically bundles all required components. This modular structure facilitates integration into broader clinical or research pipelines, ensuring transparency, portability, and maintainability while providing a lightweight alternative to Docker-based deployment. The tool runs on Windows and Linux, with macOS support planned pending further CPack development. Key features include automatic viewer launch for the first processed subject, probability map export, configurable lesion thresholds, and optional MNI-space outputs. System paths for logs, models, and configuration follow OS conventions: `AppData` and `ProgramData` on Windows; `~/.local/share` and `~/.config` on Linux.

# 3. RESULTS

## 3.1. Accuracy

Quantitative validation on 300 unseen stroke subjects (ATLAS v2.0 [5] test-set) verified numerical equivalence between PyTorch nnU-Net and the `Float16` ONNX implementation. A mean Dice difference of < $10^{-3}$ (lowest agreement 0.9977) confirmed model behavior preservation. Lesion Dice scores were consistent with published results [6], with mean values 68.8 (T1w) and 75.6 (T1w+FLAIR).

## 3.2. Performance and size

Packaged application sizes are reported in Table 1. ONNX conversion reduced overall package size by approximately 60% compared with the original PyTorch builds.

<table><caption>**Table 1.** Packaged application size comparison.</caption><thead><tr><td>OS (Hardware)</td><td>PyTorch</td><td>ONNX</td><td>Reduction</td></tr></thead><tbody><tr><td>Fedora (GPU+CPU)</td><td>6.20 GB</td><td>2.50 GB</td><td>~60%</td></tr><tr><td>Windows (GPU+CPU)</td><td>7.25 GB</td><td>2.73 GB</td><td>~62%</td></tr><tr><td>Windows (CPU only)</td><td>2.10 GB</td><td>0.80 GB</td><td>~62%</td></tr></tbody></table>

<table><caption>**Table 2.** Runtime comparison across processing stages.</caption><thead><tr><td>Task</td><td>Ultrabook laptop</td><td>Workstation laptop</td></tr></thead><tbody><tr><td>Brain Extraction</td><td>198.5 s/volume</td><td>36.6 s/volume</td></tr><tr><td>Registration</td><td>15.1 s/volume</td><td>3.1 s/volume</td></tr><tr><td>Inference</td><td>149.2 s/volume</td><td>0.9 s/volume</td></tr></tbody></table>

Execution times are summarised in Table 2. Averaged end-to-end processing time per subject was 6.0 min on the CPU-only laptop and 41 s on the GPU workstation. As expected, performance was strongly affected by hardware configuration. On the workstation, GPU-accelerated inference achieved a ~165× speedup over the CPU-only laptop (0.9 s vs. 149.2 s per volume). Preprocessing steps showed more moderate but still substantial improvements: brain extraction was 5.4× faster (36.6 s vs. 198.5 s per volume), and registration improved by 4.9× (3.1 s vs. 15.1 s per volume). These results confirm that inference is the most GPU-sensitive stage, while brain extraction - limited by CPU performance per core [13] - remains the dominant contributor to total execution time. Caching or importing preprocessed volumes therefore provides the most effective way to reduce overall processing time in repeated analyses.
## 4. DISCUSSION AND CONCLUSION

StrokeSeg demonstrates that research-grade nnU-Net models can be transformed into a practical, lightweight tool without compromising accuracy. This confirms that engineering optimisations can achieve deployability gains while preserving scientific fidelity. No systematic performance differences were observed across lesion sizes, indicating that precision quantisation did not preferentially affect small or large lesions. The use of ONNX Runtime and Float16 quantisation substantially reduces software dependencies and package size, while the modular design and dual GUI/CLI interfaces improve usability across research and clinical contexts.

**Limitations.** Current constraints are (i) lack of DICOM I/O (NIofTI only), (ii) restricted throughput due to serial execution, and (iii) research-only without CE/FDA clearance.

**Future work.** Upcoming developments will address limitations (i) and (ii), and introduce a native C++/Qt interface for improved usability. We also plan a full C++ implementation using ONNX Runtime to further reduce footprint and improve portability. These efforts aim toward a coherent, lightweight, standalone C++ application. We intend to support heterogeneous inference backends across diverse hardware (AMD, NVIDIA, Intel), including integrated GPUs commonly used in clinical environments and NPU built-in CPUs.

## 5. COMPLIANCE WITH ETHICAL STANDARDS

This study used retrospectively processed MRI data from the publicly available ATLAS v2.0 dataset [5], together with pretrained models [6]. In accordance with the licensing terms of the dataset, additional ethical approval is not required.

**Software availability:** StrokeSeg executables and guide are provided as research software at [11]. The application displays a startup disclaimer and is not CE-marked.

**Conflicts of Interest:** The authors have no relevant financial or non-financial interests to disclose.

## 6. REFERENCES

[1] Valery L Feigin, Benjamin A Stark, Catherine O Johnson, and GBD 2019 Stroke Collaborators, “Global, regional, and national burden of stroke and its risk factors, 1990–2019: a systematic analysis for the global burden of disease study 2019,” *The Lancet Neurology*, vol. 20, no. 10, pp. 795–820, 2021.

[2] Julie Bernhardt, Karen Borschmann, Lara Boyd, et al., “Agreed definitions and a shared vision for new standards in stroke recovery research: the stroke recovery and rehabilitation roundtable taskforce,” *International Journal of Stroke*, vol. 12, no. 5, pp. 444–450, 2017.

[3] Ramsha Ahmed, Aamna Al Shehhi, Bilal Hassan, et al., “An appraisal of the performance of ai tools for chronic

stroke lesion segmentation,” *Computers in Biology and Medicine*, vol. 164, pp. 107302, 2023.

[4] Fabian Isensee, Paul F. Jaeger, Simon A. A. Kohl, Jens Petersen, and Klaus H. Maier-Hein, “nnu-net: a self-adapting framework for u-net-based medical image segmentation,” *Nature Methods*, vol. 18, no. 2, pp. 203–211, 2021.

[5] Sook-Lei Liew, Jessica M. Anglin, Marty A. Banks, et al., “The atlas database of stroke structural images and manual lesion segmentations,” *Scientific Data*, vol. 5, pp. 180011, 2018.

[6] Alessandro Di Matteo, Youwan Mahé, Stéphanie S Leplaideur, Isabelle Bonan, Elise Bannier, and Francesca Galassi, “Deep Learning and Multi-Modal MRI for the Segmentation of Sub-Acute and Chronic Stroke Lesions,” hal-04647365, 2025, working paper or preprint.

[7] Fernando Pérez-García, Rachel Sparks, and Sébastien Ourselin, “Torchio: A python library for efficient loading, preprocessing, augmentation and patch-based sampling of medical images in deep learning,” *Computer Methods and Programs in Biomedicine*, vol. 208, pp. 106236, 2021.

[8] Alain Jungo, Olivier Scheidegger, Mauricio Reyes, and Fabian Balsiger, “pymia: A python package for data handling and evaluation in deep learning-based medical image analysis,” *Computer Methods and Programs in Biomedicine*, vol. 198, pp. 105796, 2021.

[9] Project MONAI, “Monai deploy: Medical ai deployment framework,” https://monai.io/deploy.html, 2023, Accessed: 2025-09-22.

[10] Pascal Theriault-Lauzier, Denis Cobin, Olivier Tastet, et al., “A responsible framework for applying artificial intelligence on medical images and signals at the point of care: The pacs-ai platform,” *Canadian Journal of Cardiology*, vol. 40, no. 10, pp. 1828–1840, 2024.

[11] Empenn Research Team, “StrokeSeg: Documentation,” https://strokeseg-doc.readthedocs.io, 2025, Research software documentation (version 0.1.0).

[12] Inria / IRISA Empenn Team, “Anima and animascripts pipelines for medical image analysis,” https://anima.irisa.fr/, Accessed: 2025-10-19.

[13] Gene M. Amdahl, “Validity of the single processor approach to achieving large scale computing capabilities,” in *Proceedings of the April 18-20, 1967, Spring Joint Computer Conference*, New York, NY, USA, 1967, AFIPS '67 (Spring), p. 483–485, Association for Computing Machinery.