Abstract
Background and Aim
Since the initial release of the World Wide Web, the capabilities of web browsers have grown from presenting formatted documents to running complex programs, such as 3D game engines. The medical imaging community started to adopt technologies that came with the fifth major version of the HyperText Markup Language (HTML5). It led to the creation of various web-based radiological applications such as cornerstone.js or BrainBrowser. BrainBrowser supports both 3D and 2D rendering of neuroimaging data. However, it cannot run important image processing algorithms, such as brain extraction and linear registration, which are essential in most neuroimaging workflows. The most commonly used library that supports these algorithms is the FMRIB Software Library (FSL). We aim to build a web-based cross-platform neuroimaging platform that combines data visualization with image processing.
Methods
We built our system as an extension of BrainBrowser. We developed WebMRI in JavaScript and designed the user interface using HTML, CSS, and Bootstrap. We used Emscripten to port the brain extraction and linear registration tools of FSL to the web.
Results
We built WebMRI, a fully web-based extensible neuroimaging platform that combines the visualization capabilities of BrainBrowser with the brain extraction and linear registration tools of FSL by porting them from C++ to WebAssembly. We extended BrainBrowser with a plugin system that makes it easy to bring other processing algorithms into the platform. We released the WebMRI source code on Github: https://github.com/wpmed92/WebMRI.
Conclusions
We developed and released WebMRI, a web-based cross-platform open-source neuroimaging platform.
Introduction
The web was created to facilitate information-sharing between universities and institutes. Initially, it was a medium to exchange simple documents with links and basic formatting. After decades of development and innovation, modern browsers can play high-quality video streams, complex animations, games, and simulations and perform other computationally intensive tasks natively without using any third-party plugins. The possibility of plugin-free native application execution inside browsers came with the 2014 release of the asm.js specification [1]. Asm.js was introduced as a strict subset of JavaScript to be used as a low-level target language for compilers. It allows the browsers to perform ahead-of-time optimizations on the code and to run it with superior performance to unoptimized JavaScript. The de-facto compiler toolchain for asm.js is Emscripten [2]. It can compile C/C++ code bases by converting Low Level Virtual Machine (LLVM) [3] bitcode to asm.js. An early demonstration of the viability and ease of use of the toolchain was the porting of Unreal Engine 3 to the web, which was developed as a collaboration of Mozilla and Epic Games in 4 days [4]. The successor to asm.js is WebAssembly, which first appeared in 2017 [5]. It has similar goals to asm.js, most importantly to allow running computationally intensive programs in the browser, but instead of being a subset of JavaScript, it is a binary instruction format for a stack-based virtual machine. WebAssembly is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. Emscripten supports WebAssembly too, and changing the compilation target to WebAssembly instead of asm.js is straightforward.
Besides games and multimedia software, medical applications also benefited from modern-day web innovations. Although medical software systems, such as Health Information Systems (HIS), have been on the web for a long time, it was only after the introduction of the fifth major version of the HyperText Markup Language (HTML5) [6] the Web Graphics Library (WebGL) [7] and WebAssembly that computationally more involved medical programs, such as radiological software tools, started to appear on the web.
One such example is cornerstone.js [8], a framework that allows viewing Digital Imaging and Communications in Medicine (DICOM) [9] images inside the browser. It consists of a collection of libraries, each responsible for a specific task, like decoding DICOM images, connecting to a Picture Archiving and Communication System (PACS), or annotating medical images. For medical education-related use-case, Biodigital Human [10] is worth mentioning. It is an interactive 3D platform where one can explore, customize, and share 3D views of human anatomy, physiology, diseases, and treatments.
The neuroimaging community also started to adopt web technologies, an example of which is BrainBrowser [11], a web-based project that enables visualizing surface and volumetric data. The WebGL-based Surface Viewer is capable of rendering 3D surfaces in real-time, whereas the Volume Viewer uses HTML5 canvas to allow slice-by-slice traversal of volumetric data in Neuroimaging Informatics Technology Initiative (NIfTI) and various other neuroimaging formats.
Post-processing of neuroimaging data is often needed for accurate visualization. As an example, in the case of the simultaneous visualization of two MRI volumes of the same patient acquired at different times, overlaying the two on top of each other might not be sufficient because of the slightly different positions of the patient during the two image acquisitions. Linear registration of the two volumes is needed so that the same location on the two images refers to the same voxel (Fig. 1). This way, the two images can be overlaid on top of each other for more accurate evaluation. For linear registration to work robustly, another processing step has to be performed on the two input volumes. This is called brain extraction, which is the method of deleting non-brain tissue from an image of the whole head.
The most widespread tools for performing the aforementioned image processing techniques on neuroimaging data are the Brain Extraction Tool (BET) [12] and the FMRIB Linear Image Registration Tool (FLIRT) [13, 14] of the FMRIB Software Library (FSL) [15]. Another widely used software to perform linear registration is Slicer 3D [16], which focuses more on a graphical user interface-based approach, whereas the components of the FSL library are mainly used as command-line tools. Slicer 3D is also capable of performing brain extraction, however it is available as an extension and is not part of the software by default.
To the best of our knowledge, there is no fully client-side web-based neuroimaging workflow that supports brain extraction and linear registration. Our goal is to create a web-based, cross-platform, extensible neuroimaging platform that works in any modern web browser and does not require a web server for the computations. We aim to combine the visualization capabilities of BrainBrowser VolumeViewer, and the image processing power of FSL by porting FSL BET and FLIRT to WebAssembly and integrating them into BrainBrowser through an extensible plugin system.
Methods
Software architecture
Our project consists of three main parts:
- ●the porting of the brain extraction (BET) and linear registration (FLIRT) FSL tools to WebAssembly
- ●the integration of the ported tools into BrainBrowser through a plugin system
- ●creating a demo application to showcase multiple neuroimaging workflows using the ported tools
We created a version of FSL that can run on the web using a tool called Emscripten. Our approach involved customizing the software by selectively including only the components required for executing BET and FLIRT. These changes allowed us to generate WebAssembly programs that can be used to run BET and FLIRT in a web browser. To enhance user experience, we used web workers to run the tools, this way the browser window remains responsive while the program performs the computation. From a user perspective, the ported tools behave exactly like their native command-line versions, i.e., they can receive and parse the same command-line arguments, and they generate output files in the same manner.
We integrated our ported tools into BrainBrowser (Fig. 2), which allows visualization of NIfTI volumes through its VolumeViewer module.
Software functionalities
By default, BrainBrowser supports loading files in NIfTI, Medical Imaging NetCDF (MINC), and Massachusetts General Hospital (MGH) formats, but we extended it with two additional volume types: “dicom” and “blend”. The “dicom” loader allows DICOM slices to be loaded into the program by internally performing a DICOM to NIfTI conversion and then calling the NIfTI loader using the output of the conversion step as its input file. For the conversion, we used an Emscripten port of an open-source tool named dcm2niiX (the port is based on version v1.0.20170207). The “blend” loader allows overlaying two volumes on top of each other, which helps visualize two volumes that are linearly registered to each other.
To allow running our ported tools in BrainBrowser, we extended it with a plugin system. The plugin system is defined as a VolumeViewer module.
Plugins are defined as an array of plugin objects. Each object describes a specific plugin with “name”, “title”, “author”, “id”, “worker,” and “gui” attributes. The “author” property stores a link to the website of the author of the plugin, in our case, FSL. The “id” is a unique identifier for the plugin. The “worker” is a link to the web worker that invokes the WebAssembly module, and the “gui” is a link to the JavaScript Object Notation (JSON) file that describes the user interface of the plugin, which shows tweakable parameters and a button to run the tool. When the user clicks on the “Run” button on the plugin dialog, the UI handler loops through the input fields and creates name-value pairs, which in turn are passed to the web worker. The web worker will then run the WebAssembly program with the received command-line arguments.
Results
The entry point of our demo application showcasing WebMRI is the dashboard (Fig. 3). There is a navigation bar on the top with menu items “File”, “Tools”, and “About”. The “File” menu hosts actions such as opening DICOM series, a NIfTI volume, or creating a blended volume (“Create overlay”) out of two input volumes. The “Create overlay” functionality is an important last step in a linear registration workflow, as it simultaneously visualizes the two volumes registered to each other. The “Tools” menu shows the list of the plugins available in the application (BET and FLIRT), and through the “About” menu, users can access the developer documentation and user manual of WebMRI.
Under the navigation bar, we present the main screen, which is divided into the rendering section on the right, and the panel section on the left. The rendering section hosts the BrainBrowser VolumeViewer widget, which visualizes the loaded volume in sagittal, axial, and coronal planes. The panel section next to it hosts the “Workspace” and “Volume controls” widgets.
The “Workspace” widget (Fig. 4) shows the files currently opened in the application. These files can either be loaded by the user (input files) or generated by plugins (output files). The workspace has a root folder, which is a collection of files that are visible to plugins as input files and plugin-specific folders, into which plugins generate their output files. If the users want to further process output files, they first have to move the relevant files to the root folder by clicking on the blue up arrow next to the file names. This way, the selected files will be visible to the plugins. The “Volume controls” widget contains coordinate information, blending controls, and windowing sliders.
Our demo application showcases our two ported FSL tools. They can be accessed from the “Tools” menu. Figure 5 shows the automatically generated user interface for BET. The input volumes can be selected from a drop-down menu. The user is presented with a list of modifiable parameters, which will translate to command-line arguments by the plugin system when the “Run” button is clicked, and the underlying tool is invoked.
The most practical use case our system is capable of supporting in its current form is the multi-modal assessment of neuroimaging data. As an example, let us look at how cerebral microbleeds can be detected in an MRI volume. The most widespread way of analyzing microbleeds is to leverage susceptibility weighted imaging (SWI). Although SWI can help identify microbleeds with high sensitivity, their localization is challenging relying solely on this modality. T1-weighted MRI images preserve the anatomical features of the brain, so using the T1 modality in combination with SWI can help with localization. WebMRI can co-register an SWI to a T1 MRI volume thus enabling precise microbleed detection. To enhance registration result brain extraction can also be performed. Since our system can handle DICOM to NIfTI conversion, the only step the user has to perform before loading data into our system is to export the DICOM series from the PACS.
Discussion
With WebMRI, we built a cross-platform, extensible neuroimaging platform that supports brain extraction and linear registration and can be run in any modern web browser without using third-party browser plugins or a dedicated web server. For brain extraction, we used the BET, and for linear registration, the FLIRT tool of the popular neuroimaging library collection FSL. For the porting process, we used Emscripten to convert the native programs to WebAssembly binaries. We extended BrainBrowser with a plugin system to be able to load our ported tools into the system combining volumetric visualization with image processing. We built a demo application that incorporates the ported tools and demonstrates that a complete neuroimaging workflow from DICOM loading to linear registration can be performed inside a web browser.
Building on the foundations of BrainBrowser, we increased the scope of browser-based neuroimaging and showed that not only neuroimaging data visualization but computationally intensive processing algorithms could also be performed inside modern web browsers. In contrast to Slicer 3D (to which our system is similar in terms of modularity) or other not browser-based programs, our solution does not require an installation. By removing the need for a web server, and complex setup processes, we reduced the cost and improved the ease of use of certain neuroimaging workflows. These factors can improve the clinical adoption of new image-processing tools. Although we demonstrated the porting of two popular neuroimaging tools, there is no limit to bringing other algorithms into the WebMRI plugin system as long as they are written in a programming language that can be compiled to WebAssembly. As more and more programming languages used in computationally intensive application development (such as Rust) support compilation to WebAssembly, the number of libraries that can be ported to WebMRI will increase.
The limitation of our fully browser-based system is twofold. The memory usage of heavy workloads, such as processing large numbers of volumes in bulk, might exceed the resources available inside a browser tab. There is also a performance penalty for the porting due to the overhead of the WebAssembly runtime compared to fully native execution. The impact of these limitations varies between programs and browsers and can be mitigated using optimizations in the Emscripten toolchain or the original codebase. If these factors make it not possible to reliably run a given tool in the browser, it can still be run in a web server since Emscripten supports execution in a Node.js runtime.
In the future, we plan to increase our fleet of ported neuroimaging tools and make our plugin system more modular and extensible. We aim to make it easier to integrate our system into a clinical PACS environment, so there will be no need to export DICOM files. We also plan to support hybrid execution so that a given algorithm can be run on the client or server side, depending on the requirements of the given workload. We plan to improve the visualization capabilities of WebMRI by adding support for customizable volume viewer widgets and annotation of points of interest on the volumes.
Ethical statement
The study submitted to IMAGING have been conducted in accordance with the Declaration of Helsinki and according to requirements of all applicable local and international standards.
Authors' contribution
AH – Conceptualization, Software architecture design, Software development, Software testing, Drafting of the manuscript, Preparing the Figures. FK – Conceptualization, Software testing, Revision. SSz – Conceptualization, Software testing, Revision. TD – Conceptualization, Software testing, Revision. PB – Conceptualization, Software testing, Revision. AT – Conceptualization, Product design, Software testing, Revision. All authors reviewed the final version of the manuscript and agreed to submit it to IMAGING for publication.
Funding sources
No financial support was received for this study.
Conflict of interests
The authors have no conflict of interest to disclose.
Acknowledgments
Not applicable.
References
- [1]↑
Herman D, et al.: “asm.js” asm.js, 18 August 2014, http://asmjs.org/spec/latest/. Accessed 12 October 2022.
- [2]↑
Zakai A: Emscripten: An LLVM-to-JavaScript compiler. OOPSLA '11: Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companion, 22 10 2011: 301–312.
- [3]↑
Lattner C, Adve V. LLVM: a compilation framework for lifelong program analysis & transformation. In: Proceedings of the international symposium on code generation and optimization, CGO '04, Palo Alto, California, Mar 2004.
- [4]↑
Mozilla, and Epic Games: ‘Epic citadel’ demo shows the power of the web as a platform for gaming - future releases.The Mozilla Blog, 2 May 2013, https://blog.mozilla.org/futurereleases/2013/05/02/epic-citadel-demo-shows-the-power-of-the-web-as-a-platform-for-gaming/. Accessed 12 October 2022.
- [5]↑
Haas A. et al.: Bringing the web up to speed with WebAssembly, Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, 2017.
- [6]↑
Web Hypertext Application Technology Working Group: HTML Standard. HTML, 2004, https://html.spec.whatwg.org. Accessed 12 October 2022.
- [7]↑
Leung C, Salga A: Enabling WebGL. Conference: Proceedings of the 19th International Conference on World Wide Web, WWW 2010, Raleigh, North Carolina, USA, April 26–30, 2010.
- [8]↑
Hafey C: Cornerstone.js. Cornerstone.js, 2017, https://www.cornerstonejs.org. Accessed 12 October 2022.
- [9]↑
Bidgood WD, Jr., Horii SC, Prior FW, Van Syckle DE: Understanding and using DICOM, the data interchange standard for biomedical imaging. J Am Med Inform Assoc 1997; 4(3): 199–212.
- [10]↑
Qualter J, Sculli F, Oliker A, Napier Z, Lee S, Garcia J, et al.: TheBioDigital human: a web-based 3D platform for medical visualization and education. Studies in Health Technology and Informatics 2012; 173: 359–361.
- [11]↑
Sherif T, Kassis N, Rousseau MT, Adalat R, Evans AC: Brainbrowser: Distributed, web-based neurological data visualization. Front Neuroinf 2015; 8: 89.
- [12]↑
Smith SM: Fast, robust automated brain extraction. Human Brain Mapping November 2002; 17(3): 143–155.
- [13]↑
Jenkinson M, Smith SM: A global optimisation method for robust affine registration of brain images. Medical Image Analysis 2001; 5(2): 143–156.
- [14]↑
Jenkinson M, Bannister PR, Brady JM, Smith SM: Improved optimization for the robust and accurate linear registration and motion correction of brain images. NeuroImage 2002; 17(2): 825–841.
- [15]↑
Woolrich MW, Jbabdi S, Patenaude B, Chappell M, Makni S, Behrens T, et al.: Bayesian analysis of neuroimaging data in FSL. NeuroImage 2009; 45: S173–S186.
- [16]↑
Pieper S, Lorensen B, Schroeder W, Kikinis R: The NA-MIC Kit: ITK, VTK, Pipelines, Grids and 3D slicer as an open platform for the medical image computing community. Proceedings of the 3rd IEEE International Symposium on Biomedical Imaging: From Nano to Macro 2006; 1: 698–701.