ImageM: a user-friendly interface for the processing of multi- dimensional images with Matlab [version 1; peer review: 1 approved with reservations]

Modern imaging devices provide a wealth of data often organized as images with many dimensions, such as 2D/3D, time and channel. Matlab is an efficient software solution for image processing, but it lacks many features facilitating the interactive interpretation of image data, such as a user-friendly image visualization, or the management of image meta-data (e.g. spatial calibration), thus limiting its application to bio-image analysis. The ImageM application proposes an integrated user interface that facilitates the processing and the analysis of multi-dimensional images within the Matlab environment. It provides a user-friendly visualization of multi-dimensional images, a collection of image processing algorithms and methods for analysis of images, the management of spatial calibration, and facilities for the analysis of multi-variate images. ImageM can also be run on the open source alternative software to Matlab, Octave. ImageM is freely distributed on GitHub: https://github.com/mattools/ImageM.


Introduction
Modern imaging devices provide a wealth of data often organized as images with many dimensions, for instance 2D/3D, time and channel. This leads to new challenges in the exploration, visualization and processing of multi-dimensional data. In particular, multi-spectral images require the application of methods at the intersection of spectroscopy and image processing.
Matlab (The Mathworks, Natick, MA), is an efficient software solution for image and signal processing that provides native support for multi-dimensional arrays, a large number of image processing methods, and a great facility for adding custom developments. However, it lacks many features for facilitating the interactive interpretation of image data, such as a user-friendly visualization of multidimensional images, or the management of image meta-data (e.g. spatial calibration), thus limiting its application to bio-image analysis.
The ImageJ/Fiji software (Schneider et al., 2012) is an alternative that provides an intuitive graphical user interface for image exploration, and many image processing functions that take into account spatial or channel calibration. The basic functionalities can by extended by a large collection of plugins. The integration of custom developments is possible via macros or plugins, but this often requires advanced programming skills.
The ImageM software aims at providing a user-friendly interface for the interactive exploration, processing and analysis of multi-dimensional imaging data within the Matlab environment, while taking into account meta-data and facilitating the integration with custom algorithm developments.

Implementation
ImageM strongly relies on Matlab's Object-Oriented Programming. The core feature is an "Image" class that handles arrays up to five dimensions, corresponding to three spatial dimensions, the channels, and the time. It also encapsulates image meta-data such as spatial calibration, image name, or channel names.
The user interface relies on various image viewers adapted to the type (grayscale, color, label, multivariate) and the dimensionality of the image (Figure 1a). Interactive tools allow for quick image exploration, for example histograms, line profiles and 3D visualization. The architecture was kept modular to facilitate the inclusion of new features.

Operation
To have the whole functionalities, Matlab (v2020a) is required, as well as the Image Processing and the Statistics toolboxes. The Gui Layout Toolbox (Sampson, 2021) is required to benefit from flexible image viewers. ImageM runs on a typical workstation. The application is launched by typing "ImageM" from the command line.
Menus provide quick access to common image processing operators, organized in a way to make them easily discoverable by a non-expert user. When necessary, intuitive dialogs allow for setting up parameters. Preview of the results facilitates the choice of relevant settings. Region of interest may be defined interactively to perform interactive measurements.
To facilitate usage during scripting and integration with custom developments, images can be easily imported from and exported to the workspace. Applying an operator results in a log entry that can be integrated into a script for quickly generating a workflow from the succession of operations.

Segmentation and analysis of regions
ImageM integrates a large family of image processing operators (linear filtering, mathematical morphology, segmentation). Intuitive dialogs allow tuning of parameters and preview of the result, facilitating the choice of relevant settings (Figure 1c). The type of the result image is automatically inferred to provide the most adequate visualization (Figure 1d and e).
Segmentation algorithms result in binary or label images that can be used for quantitative analysis of regions. The spatial calibration of images is considered when available. Features can be visualized as geometric overlays on the image or exported to data tables (Figure 1f).

Multivariate image analysis
Multi-channel images or microscopy images contain pixels represented of several values. Multivariate image analysis provides a convenient formalism to analyze such images by taking account both the spatial and the spectral dimensions (Geladi & Grahn, 2006). ImageM can convert multi-variate images into data tables, allowing their exploration through multi-variate analysis tools such as Principal Component Analysis or k-means clustering (Figure 2). Resulting tables can be easily back-converted to images to facilitate the visual interpretation.
Octave ImageM can also run within the open-source platform, Octave, after some modification of the code (see Extended data (Legland & Devaux, 2021)).

Use case
We present here a use case describing image segmentation and region analysis of the 3D image presented in Figure 1. The Extended data (Legland & Devaux, 2021) contains the sample files, and more detailed use cases.
• First, run the application by typing "ImageM" from Matlab command line.
• In the menu, select "File->Open Image …" and choose the file "arabidopsis-embryo.tif". This opens an image viewer for the 3D image. • Reduce the noise in the image, by selecting "Process->Gaussian Filter …". This opens a dialog.
• Choose value 1 for each of the "sigma" values, and click "OK". The filtered image appears in a new viewer.
• Perform 3D segmentation of the cells. Select menu entry "Process->Extended Min Watershed …". Choose a basin dynamic equal to 6, the "C6" connectivity, and result type as "basins". This results in a new 3D label image in a new viewer, where each label is displayed with a different color.
• Some regions do not correspond to cells. They can be removed manually. Select the menu "Process->Replace Value(s) …" and fill in with "1, 2, 28, 29" (values can be identified by moving the mouse cursor and inspecting the status bar).
• Morphometric features can be computed from 3D label images, by selecting the menu "Analyze->Analyze Regions …". After choosing the features and clicking "OK", the selected features appear in a new data table frame that can be saved as a text file or exported to the workspace.
• The 3D representation of the Figure 1g can be obtained by selecting the menu entry "View -> Show 3D isosurface", choosing a "smoothing radius" value equal to 1 and checking the options "Reverse Z-axis" and "Rotate Ox".

Summary
The ImageM application proposes a convenient user interface for the visualization and exploration of multi-dimensional images within Matlab. It also provides basic support for regions of interests, the management of data tables. Its modular architecture should facilitate the future incorporation of new functionalities. The current work focuses on a better management of regions of interest, and on the inclusion of user plugins.  (Legland, 2021).

Data availability
Underlying data All data underlying the results are available as part of the article and no additional source data are required.
This project contains the following extended data: