Brillouin microscopy

Context

Brillouin microscopy is rapidly emerging as a powerful technique for imaging the mechanical properties of biological specimens in a label-free, non-contact manner. Different approaches can be used to acquire the Brillouin signal (e.g. spontaneous, stimulated, time-domain) but ultimately they all collect a spectrum for each voxel in the image. For more information you can find many reviews about the topic, e.g. Kabakova et al 2024 and Prevedel et al. 2019.

Despite its growing adoption, standardized methods for storing, sharing, and analyzing spectral data and associated metadata are still lacking. We recently proposed a standardized file format based on ZARR, together with a web app, BrimView, to visualize and analyze the data. You can read more about it in our preprint.

Aims

There are several aspects of the web app that need improvements. During the hackathon, we focused mainly on two tasks:

Implementing data processing with GPGPU

Typical Brillouin datasets consist of >10,000 spectra. Most commonly, the data is analyzed by fitting a known function (e.g. Lorentzian) to the Brillouin peaks. This can easily take tens of minutes when using standard fitting algorithms on the CPU. We therefore wanted to explore the possibility of using GPGPU to accelerate these fits in the browser. There is one project we know that uses CUDA kernels on NVIDIA GPUs that makes it quite fast called GPUfit, so we would look into using it but in the website.

Extending the support of local ZARR files to ZARR directories in addition to .zip files

A ZARR file consists of an entire directory, but the current version of BrimView only supports reading zipped folders. We therefore wanted to implement support for reading directories as well.

Achievements

GPGPU acceleration

First, we explored how to run CUDA kernels from a website with a client’s NVIDIA GPU. Our search quickly found it was impossible. Then, we resorted to use WebGPU to implement fitting on the GPU in the browser. With the help of a Claude Code agent, we ported Gpufit to WebGPU. The results of this port are available in the gpufit-wgpu GitHub repository. An initial integration into the BrimView app is available in a forked repository. Preliminary tests showed a substantial speedup of fitting (about 1 s for more than 10,000 spectra).

Reading local directories

After exploring different options, including the Filesystem Access API (which has limited support in major browsers) and the MEMFS filesystem in Pyodide, we resorted to using the webkitdirectory property of HTMLInputElement, which allows loading a directory as a list of files that can then be mapped to a Zarr store.

Next steps

We plan to test the new code and fully integrate it into the existing codebase.