The research team CUQI at DTU Compute has, in a collaborative effort, written software that addresses the reliability of their images, e.g., when scanning for unwanted features in an object. The software is simple to use; often five lines of code are enough for a complete analysis. In this article, the team tells about the work and explains how to use the software.
Text: Hanne Kokkegård, DTU Compute
Engineers often need to examine the interior of objects for possible defects without having to cut through the material, for example when looking for internal damage in oil and gas pipelines or wind turbine blades. Instead, they send X-rays or electricity through the objects and measure their attenuation.
By inserting the measured data into a mathematical model, they can create reconstructions, e.g. 3D images of objects’ internal structures to detect possible defects. However, the question is how much one can trust the reliability of the images because unwanted artifacts could be created by the computational methods from noise in the data.
Here, a new software package – CUQIpy – can help by quantifying the accuracy of the details in the image by ’reversing’ the computations, so to speak. Based on a given output (measurements) you can see how they have arisen – i.e. what the input is, e.g. errors in construction – and at the same time calculate the uncertainty in images, so that doctors, engineers, or others can base their decision-making on knowledge of the uncertainty.
The software has been developed in the research team CUQI (Computational Uncertainty Quantification for Inverse problems) at DTU Compute. It can be used for all sorts of so-called ‘inverse problems’; applications where you, based on measurements, try to say something about what is inside an object without opening and looking into it, i.e. using indirect measurements – in the industry as well as in the hospital.
“Normally you would have to write 1000 lines of code, but most people are not experts in e.g. both CT scans and inverse problem uncertainty analyses. That’s why we have simplified it, so you only have to write approximately five lines of code to set up a problem, solve it and visualize it. This makes it as simple as possible for everyone to use the software tool to analyze their problems,” says Senior Researcher Jakob Sauer Jørgensen, who leads the software people at CUQI.
The software was original released in the Autumn 2022, but the software is constantly evolving, and new features and improvements are added continuously.
“In March 2024, we released a major update, version 1.0, as a significant milestone, in connection with publishing a set of two articles (open access – find the links below) that extensively describe software, including a number of detailed case studies,” says Jakob Sauer Jørgensen.
One example (figure below) from the first article demonstrates uncertainty quantification for deblurring of an image – in line with the project name CUQI the example image is a cookie. From a blurred, noisy observed image and specification of the forward model of the blurring process, some statistical assumptions and the choice of an edge-preserving prior, CUQIpy produces a resulting sharp cookie image and an associated uncertainty image that highlights that most of the uncertainty is around the edges of the cookie.”

Same mathematical core regardless of the problem
Since 2019, the research initiative CUQI, with support from the Villum Foundation, has worked to develop mathematical models and methods that can perform uncertainty quantification and, in turn, help e.g. the industry with quality assurance of products.
“We use mathematics to turn abstractions into equations. Whether you are looking at applications with CT scans, blurred images, or trying to find a buried land mine or an oil/gas deposit, they have the same mathematical core, so you can describe it with the same type of equation – with the same mathematical structure. In CUQIpy, we have software building blocks that represent the mathematical building blocks, and thus the software is flexible and can be easily adapted to the specific problems,” explains Professor and Head of CUQI Per Christian Hansen.
The CUQI team has developed building blocks that describe typical problems using a number of demonstration problems that users can start working on. Users can therefore just enter a few specifications for their inverse problems – e.g. how to mathematically describe what happens inside the scanner, and then the software takes care of the rest.
“But at the same time, users can adapt the equations if the measurement geometry needs to be different, or if they want to carry out an uncertainty quantification of a completely different inverse problem, because this can be handled easily with the software,” says Per Christian Hansen.
The article continues below the figure.
CUQIpy – how to use the software
Briefly, CUQIpy – https://cuqi-dtu.github.io/CUQIpy – is based on a general formulation of inverse problems by the equation
b = Ax
where b is the measured data, x are the unknown parameters we seek to reconstruct, and A is the so-called forward model that describes the physics of how b arises from x.
In a CT scan, b consists of X-ray measurements, x is a cross-sectional image of the object, and A describes how X-rays are attenuated and the geometry of the scanner.
A typical workflow for a UQ analysis with CUQIpy is shown in the figure below. The user selects one of CUQIpy’s built-in forward models A or specifies their own, together with the measured data b. Next, the user specifies what prior information is available of e.g. image and noise in the form of probability distributions. From this, CUQIpy automatically sets up and solves the underlying Bayesian inverse problem, including the choice of an efficient sampling algorithm. The result is presented in the form of both reconstructed images, parameter distributions, and uncertainty information.

Unusual collaborative development
CUQIpy has been developed through an unusual, interdisciplinary collaboration, where the researchers have worked through a systematic approach to the different mathematical building blocks of the software. Professional software development tools have been used for version control, code testing, and documentation, and code development has taken place via the open platform GitHub.
Jakob Sauer Jørgensen was recruited to the CUQI project in April 2020 from The University of Manchester, where he had built and headed a research and software group, and he saw from the start that it would be beneficial to involve the entire CUQI team in the software development:
“Software is getting more and more important everywhere, and therefore we have to work systematically with development when we build new tools. Normally, everyone is busy writing papers about their own part of a project, but here we have built a software product across the group in close collaboration.”
The whole CUQI team has participated in training courses to achieve competence in software development so that everyone understands the processes and can contribute to the solution. In addition, they work with three-week plans where they concentrate on implementing certain features that the CUQI team requires in order to move forward. Daily they meet for short updates to coordinate and discuss.
And the CUQIpy team is growing. In the Autumn 2023 they hired yet another postdoc with a particular focus on developing methods to enable the use of CUQIpy for large-scale problems.
“We are already quite proficient in large-scale problems, but the boundaries are constantly shifting and users wish to handle larger and larger problems, not just with 10 or 100 unknowns, but millions or billions, Jakob Sauer Sørensen says.
“I am super excited about our work. It is also special that you can have this great focus on the software platform because often the work with software is just a minor part,” says Jakob Sauer Jørgensen.
Progress via collaboration
Per Christian Hansen is pleased that his thoughts were correct when he wrote the application for fund funds to CUQI.
“We have succeeded in attracting very talented people who understand the strategy of combining theoretical mathematics with applied mathematics and statistics – through collaborative software development instead of sitting with their own research in separate silos. By gathering people and working together, you move forward. It’s about creating the right environment, and I think CUQI is a good example of that.”
This is basic research. CUQI has not committed itself to specific deliverables in terms of applications but has promised that it would develop a general software platform. At the same time, the grant lasts till ultimo November 2025, so there is a nice overlap between PhD students and postdocs who do not have to start from scratch but can continue the work that has already been done.
The CUQI project regularly holds workshops in Denmark and abroad to demonstrate how to use the software, which is open access on the GitHub platform. The next workshop will be in the autumn of 2024. They also offer internships for MSc students, among others, in the autumn of 2024, so they can spend 2-3 months at DTU working with inverse problems and the CUQIpy software.
“It’s great that we have founding agencieslike the Villum Foundation, which support a project where you can be curious and have time to find solutions. I think that more solutions will emerge because the grant is of such a scale that we have the opportunity to bring people together both experts in the mathematical/numerical scale and people with software expertise, says Per Christian Hansen.
About CUQIpy
- As part of the research project CUQI (Computational Uncertainty Quantification for Inverse Problems) at DTU Compute (Department of Applied Mathematics and Computer Science at the Technical University of Denmark), a software team led by Senior Researcher Jakob Sauer Jørgensen consisting of postdocs Nicolai Riis, Amal Alghamdi and Chao Zhang has developed the software tool, with input from the rest of the CUQI team. In the picture at the top, the four are seen at a CUQIpy software hackathon at Bernstorff Castle in October 2023.
- The software is written in the Python programming language, which is emphasized by the name CUQIpy – with “py” added to the CUQI name. Read more https://cuqi-dtu.github.io/CUQIpy/
- The CUQIpy software is published in two open-access journal articles available at https://doi.org/10.1088/1361-6420/ad22e7 and https://doi.org/10.1088/1361-6420/ad22e8.
- The entire CUQIpy software is open source, including the forward models, Uncertainty Quantification (UQ) calculation methods, UQ analyses, visualizations, etc., and is so easy to use that even a person who is not an expert in mathematics and statistics, after a little introduction, can use the software and put in their own data and do their analysis. If, on the other hand, the user is an expert, all parameters can be controlled.
- The software can be used to calculate the uncertainty in all so-called ‘inverse problems; places where you based on measurements, try to say something about what exists or happens inside an object without opening and looking into it, i.e. indirect measurements – in the industry as well as in the hospital.
- Applications include X-ray tomography of objects, CT scans, blurred images, and biomedical applications. Another application is electrical impedance tomography, where electrodes are used to measure what happens inside the object – for example a chemical process in a tank, where the process stops if you open the tank, but also in hospitals, where the method is used to check lung capacity in premature babies.
- Since April 2020, the CUQI team has developed the software and methods according to the SCRUM principles (https://www.scrum.org) of agile software development, where for periods of two weeks you solve new sub-elements of a joint task together and meet for 15 minutes daily to update.
- An online book on uncertainty quantification for inverse problems with CUQIpy is being developed and a preliminary version is available at https://cuqi-dtu.github.io/CUQI-Book.
- CUQI is supported by the Villum Foundation. The project last 6 years and ends Nov. 30, 2025.
