Research in Focus: Using AI to Detect Bacteria in Wastewater

As part of #BiofilmWeek, we’re highlighting interesting and exciting biofilm research being undertaken across our NBIC partner research institutions by early career researchers, PhD students and our Interdisciplinary Research Fellows (IRFs).

We interviewed Gavin Melaugh, a Chancellors Fellow at the University of Edinburgh, and previous NBIC IRF. Gavin talks to us about his research, which focuses on computer simulation methods and experimental techniques to investigate the biophysical mechanisms by which clinically and industrially relevant bacteria aggregate.

Tell us about your current research

Recently my research is focused on aggregation of wastewater treatment bacteria, and I have a very strong industrial collaboration with the waste management company Veolia, who manage many of the wastewater treatment facilities here in Scotland and around the world.

What is the current situation within Wastewater Systems Sector?

There is a particular type of wastewater treatment called the Activated Sludge Process (ASP), which is an area of particular interest for me. In the ASP, wastewater goes from households and industry to a wastewater treatment facility, where the water is treated in several stages before being returned to the water cycle.


Representative microscopy images of healthy and unhealthy sludge isolated from a wastewater treatment plant. Images provided courtesy of Paul Banfield at Veolia.  

A crucial stage in wastewater treatment is the ‘Biological Treatment Process’. Here, a complex plethora of microorganisms, mainly bacteria, degrade the dissolved organic waste. For this to happen, the bacteria must be able to replicate, grow and divide, and then eventually the bacteria must stick together to form large dense clumps that can be easily separated from the water. The water then goes onto the next stage for further treatement. Crucial to this process is the presence of filamentous bacteria, too many or too few and the process breaks down. This can be very costly to the treatment process and the operators then must retrospectively add environmentally harmful and expensive chemicals to alleviate the problem.

What we’re doing here at the University of Edinburgh with Veolia is trying to better understand the biophysical mechanisms by which these filamentous cells mediate the aggregation of the bacteria in the wastewater treatment process.


What problem is your research addressing?

There is both healthy and unhealthy sludge, and in order for operators to assess the health of their sludge within their wastewater treatment plants, they take regular samples from the tanks in which these bacteria reside. They then image the samples under a microscope to determine if the sludge is healthy or not, which can be very subjective. Our research with Veolia is attempting to integrate machine learning algorithms into this process to automate the decision making, so that ideally, we can take a microscopy image from a sample and then the algorithm can determine the health of the sludge. Veolia have provided us with thousands of images from their sites across the world to help better train our machine learning algorithms to modernise the wastewater treatment industry.

Another issue we have is with the filamentous cells. When these cells become too abundant, we have a problem called ‘filamentous sludge bulking’ and we hope that our machine learning algorithm will support us in developing a sludge characterization platform. Through this platform, we would aim to revolutionize and modernize protocols used to identify the onset of filamentous sludge bulking, which would make it easier for operators to assess the risk of it occurring in their system so they could take preventative action instead of retrospectively adding the environmentally harmful and expensive chemicals.


How is your work distinctive from other work taking place in this field?

Machine learning is a very fashionable subject these days both in industry and scientific research. However, to the best of our knowledge there are not too many examples of it being applied to wastewater treatment. I think through our collaboration with Veolia we could really be at the forefront of cutting-edge research in this area.

With respect to understanding the aggregation mechanisms of filamentous cells, we will be looking at this from a fundamental physics perspective, whereas other research groups tend to focus on the molecular biology, the genomes, microbial composition and the metabolism. We will be mainly focused on the physics of how filamentous bacteria stick together to form biofilms and dense aggregates.


Have you received any funding to support your research?

In collaboration with Veolia, we were awarded a BBSRC Impact Acceleration Award to attempt to implement machine learning algorithms to understand and asses the health of these sludge samples taken from wastewater treatment, which we have successfully achieved. This project is still ongoing, and to date we can differentiate between healthily and unhealthy sludge samples, with an accuracy greater than 80%.

I have also been awarded £30k from the NBIC Proof of Concept programme in collaboration with Veolia, to use computer simulation methods and experiments to better understand the biofilms physical mechanisms by which filamentous cells aggregate in wastewater treatment.


How has NBIC supported your career development?

NBIC have been brilliant for my personal and career development, particularly because they have offered these small pots of money to support biofilms research through both their Proof of Concept programme, and also their seed funding awards which were made available to the NBIC IRFs. Their awards have supported me in securing my own grants, managing my own funding and developing my CV in order to move into a career in academia.  


What experiences have you have with industry engagement?

Related to my research, we had a knowledge exchange day with Veolia. In Dec 2019, myself and my Edinburgh colleagues visited the wastewater treatment site in Edinburgh in the morning, where we were given a tour of the facilities, and Veolia highlighted some scientific issues that had been occurring. Then, in the afternoon Veolia visited the Institute for Condensed Matter and Complex Systems, here at Edinburgh and we showcased our expertise and equipment and forged a route by which we could collaborate and perform research together in the future. 


Have you been involved in any public biofilm outreach activities?

I have been involved in biofilm outreach activities targeted at a younger audience. One was a workshop which took place at our local IKEA in Edinburgh where we were teaching kids all about how the dental plaque on teeth originates from bacterial biofilms. I was also part the ‘Sherlock Holmes and the Biofilms Mystery,’ an interactive self-guided tour for the Edinburgh Science Festival, where I played the voice of Moriarty.

Find out more


If you are interested in learning more about Gavin’s work and would like to connect with him, please contact NBIC at


Gavin Melaugh, Chancellors Fellow at the University of Edinburgh


gavin melaugh