Introduction

Biofilms are commonly defined as communities of surface-attached microorganisms embedded in an extracellular matrix that are attached to a surface. In most natural environments, polymicrobial biofilms are predominant and their survival often relies on intercellular communication and interactions1,2. In the last few decades, biofilms have attracted great attention in areas ranging from environmental studies to industrial water systems, from the food industry to chronic infections3,4,5,6. In fact, 60–80% of human bacterial infections, including many bloodstream and urinary tract infections, are caused by bacterial biofilms7,8,9,10. Biofilm-based infections are extremely difficult to cure, as biofilms are intrinsically much less susceptible to antimicrobial agents than non-adherent, planktonic cells. There are two main mechanisms for antimicrobial tolerance in biofilms. The first is the failure of an antimicrobial agent to diffuse and penetrate into the depth of the biofilm. This is due to the extracellular polymeric matrix that forms the biofilm and that is known to retard the diffusion of antimicrobial agents11, and solutes in general. Hence the substratum, i.e., the surface-bound underside of the biofilm, remains protected. The second mechanism is that some of the biofilm cells experience nutrient limitation and, therefore, exist in a slow-growing or starved state8,9,10,11,12,13,14. Because of their much slower metabolism, slow-growing or non-growing cells are more tolerant of antimicrobial agents.

Recent studies have also shown that microorganisms growing in a biofilm are highly resistant to antimicrobial agents15,16,17,18,19. The antibiotic resistance in biofilms is generally caused by mutations and is driven by the repeated exposure of the bacteria to high levels of antibiotics as a consequence of treating the biofilm-associated infections, for instance20,21. The minimum inhibitory concentration (MIC), defined as the lowest concentration of an antimicrobial that will inhibit the visible growth of a microorganism, is often considered as the “gold standard” for determining the susceptibility of microorganisms to antimicrobials22,23. As a result from both biofilm tolerance and antimicrobial resistance, it is known that a subset of the sessile bacteria in biofilms can survive in the presence of up to 1000 times MIC, compared to the planktonic cells24,25.

To account for this discrepancy, new pharmacodynamic parameters, such as the minimum biofilm inhibitory concentration (MBIC) and the minimum biofilm eradication concentration (MBEC) have been introduced. To evaluate antimicrobial activity on sessile bacteria, in-vitro systems with abiotic surfaces have been developed over the last decade24,25,26,27. Closed systems (batch culture), such as multi-well plate assays, the Calgary device, and open systems (continuous culture), such as substratum suspending reactors and the flow cell systems, are some of the most used in-vitro biofilm models for susceptibility studies28, but they often require staining and/or dissolving the biofilms for visualisation and quantification, so they are typically destructive and do not allow monitoring the progression of antimicrobial activity.

Despite all of the advances made in biofilm antimicrobial resistance and tolerance studies, a highly sensitive system that is able to monitor biofilm formation and dispersion in real-time, non-destructively and quantitatively, is still missing. Monitoring the cell attachment and colonisation stage is paramount to this effort, as it allows for taking control of the early stages of biofilms and developing strategies for the prevention of mature biofilm formation. Similarly, monitoring the substratum of the biofilm is essential for understanding when antimicrobial action is completed. To address this challenge, we introduce the technique of resonant hyperspectral imaging to the monitoring of biofilms. We demonstrate the real-time monitoring of cell attachment and the development of micro-colonies of Escherichia coli (E. coli) bacteria on the sensor surface with a range of initial inoculum density, starting from 2 × 105 CFU per mL. Owing to the high surface sensitivity of the guided-mode resonance we employ, we are able to focus on the underside of the biofilm where antibiotic access is most challenging. We are able to provide a clear picture of the early-stage of biofilm formation and of the response of the biofilm to a range of antibiotics with varying doses. The unique information provided by resonant imaging may support the development of novel therapies for treating biofilm-associated infections.

Results

Hyperspectral images of early-stage biofilms

The key element of our biofilm sensor is a grating that supports a guided-mode resonance (GMR)29. The grating is fabricated in a 150 nm thick silicon nitride (Si3N4) film on a glass substrate. Si3N4 has a high-refractive index to support the guided-mode, it exhibits minimal absorption at visible and near-infrared wavelengths, and most importantly, it is biocompatible, chemically inert and mechanically robust30,31. We first simulate the grating design using rigorous coupled-wave analysis (RCWA) and fabricate structures with a period of 569 nm and a filling factor (defined as the fraction of high-refractive index material in one period) of 80% for a resonance wavelength operating at 850 nm. The evanescent tail of the guided-mode extends beyond the grating layer and into the sensing region and thereby defines the detection volume. The size of the detection volume is determined by the difference between the effective index of the GMR and the refractive index of the sensing region, as is apparent from fundamental guided-mode theory32; the detection volume is typically 100–200 nm in depth and only extends into the first bacterial layer of the biofilm. Therefore, the sensor is able to monitor the very early stages of biofilm formation and the biofilm substratum, and is not susceptible to the background signal that arises from the bulk biofilm and the surrounding media.

Figure 1 is a schematic drawing of the experimental setup. The grating is placed into a flow cell to simulate the typical environment of interest, for instance a water pipe or the inside of the bladder, and to discourage settling of the bacteria. The flow is generated by a peristaltic pump with sterile silicone tubes. We used E. coli cultured in Luria-Bertani (LB) medium with an initial concentration of 2 × 108 CFU per mL and kept the bacteria in a 37 °C water bath and flowed them through the sensor with a flow rate of 5 mL s-1. Images from the sensor are formed hyperspectrally by taking a sequence of bright-field images that are typically obtained in less than 3 min depending on the camera’s integration time (usually set to be 1 s) and the wavelength resolution (usually set to be 0.2 nm), each at a different illumination wavelength achieved via a tunable monochromatic light source. For example, it takes just over 2 min for a scan of 25 nm wavelength range with 0.2 nm resolution, i.e., 125 images, and a hyperspectral image of the resonance is then generated within seconds. By analysing the intensity values of each bright-field image, the resonance wavelength for each pixel can be determined. By plotting the resonance wavelengths of all pixels in the array, we produce the hyperspectral images of the grating at resonance (for example in Fig. 2(a–d)). The resulting hyperspectral image contains the spectral response at every pixel within the microscope’s field of view. The region of interest (i.e., the centre of the GMR grating) consists of 200 × 200 pixels on the camera (corresponding to approximately 250 × 250 µm2 in size). We then combine the resonance wavelengths of all 200 × 200 pixels in each hyperspectral image as a histogram (see Fig. 2(e–h)), and by fitting a Gaussian curve to this histogram, we obtain a central resonance wavelength (λn) for each hyperspectral image. It is worth nothing here that the distribution in the resonant wavelengths at time 0, defined as λ0, arises predominately from nanofabrication tolerances in a GMR grating. This uncertainty follows a normal distribution33; hence, a Gaussian distribution is used to determine the central resonant wavelength and the resonance uniformity. Finally, the shift in the central resonance wavelength (Δλ = λn – λi, while λi is defined as the base value of the resonance wavelength, averaged over the first 30 min after the flow of culture is started) caused by the refractive index change given by the bacterial attachment and the formation of micro-colonies, is plotted over time (see Fig. 2(i)). It appears that the shift in resonant wavelength, Δλ, saturates after ~5 h, which indicates that the first layer of the biofilm has been established (also see Supplementary Figs. 1 and 2); while it is understood that the biofilm continues to grow, the technique is not sensitive to further increases in thickness. We also note here that in the plane of the grating surface, the spatial resolution is 2 μm along the grating grooves and 6 μm in the direction perpendicular to the grating grooves34.

Fig. 1: Experimental setup.
figure 1

A broadband light source (SM30, Leukos) combined with a grating-based monochromator is employed to generate a single illumination wavelength with a spectral width of 0.6 nm, which is then guided into an inverted microscope with a 5x objective lens (Olympus NeoDplan). A GMR grating is mounted on the bottom of a flow cell with PDMS; the flow of E. coli culture is generated by a peristaltic pump with sterile silicone tubes from a reservoir of culture in a 37 °C water bath. The flow cell is used to avoid detection of the planktonic cells that happened to land on the grating but are not involved in biofilm formation. The camera used here is a CoolSnap Myo (Photometrics) with 970 x 730 pixels. Images are captured using LabView, and image analysis and curve fitting are performed using MATLAB.

Fig. 2: Hyperspectral images and resonance wavelength shifts.
figure 2

ad Hyperspectral images generated by the biofilm sensor at times 0, 2, 3.5 and 6 h from the start of the experiment. The colour represents the resonance wavelength; eh histogram data of resonance wavelengths of all pixels in ad correspondingly, and Gaussian fit (red curve) to determine the central wavelength: λ0 (at 0 h), λb (at 2 h), λc (at 3.5 h) and λd (at 6 h); i plot of the resonance wavelength shift, Δλλ = λnλi), against time (dots represent the central resonance wavelength λn from each Gaussian fit; shaded areas illustrate standard deviations of corresponding Gaussian fits and delineates the distribution of the resonance wavelengths of all 200 x 200 pixels) and the solid line is a sigmoidal fit to the data. λi is defined as the base value of the resonance wavelength, averaged over the first 30 min after the flow of culture is started. Data showing long term (45 h) stability of the biofilm sensor with fresh LB media introduced into the flow cell at 24 h. The initial E. coli concentration used here is 2 × 108 CFU per mL.

Biofilm formation as a function of bacterial concentration

Cultures of E. coli were diluted to different concentrations, ranging from 2 × 105 to 2 × 108 CFU per mL. These dilutions were then used in separate experiments to inoculate the sensor and to study the rate of biofilm formation. We choose this range due to known clinical practice, where a specimen is considered positive for urinary tract infection in adults if the uropathogen concentration is >105 CFU per mL35. We then set the sensor to obtain a hyperspectral resonant image at intervals of 9 min. Figure 3(b–e) shows that resonance wavelength shift is characteristic of early-stage single species biofilm formation, which appears with a similar shape of typical growth curves of planktonic cells36, although the mechanisms behind the curves are rather different. The biofilm formation profiles detected within a 15-h window can be described by three phases. Initially, planktonic bacteria attach to the surface —although some attachments are reversible (named “planktonic” phase). The attached cells then aggregate to form micro-colonies while excreting extracellular polymeric substances, making their attachment irreversible (named “colonies” phase). The bottom-layer of the biofilm is then considered established and continues to mature into a multi-layered cluster (“mature” phase). The “mature” phase, which can be upwards of multiple micrometres in thickness, is beyond the detection volume of our sensor and is, therefore, not “seen”, hence the resonance wavelength shift, Δλ, saturates. It is also known that the embedded biofilm cells do not divide and instead, their excess energy is used to maintain the extracellular matrix11,37. This explains why the resonance wavelength, i.e., the refractive index on the sensor surface, remains constant after a certain period of time.

Fig. 3: Biofilm formation time as a function of E. coli concentration.
figure 3

a LB broth only, for reference. Concentrations of (b) 2 × 105, (c) 2 × 106, (d) 2 × 107, (e) 2 × 108 CFU per mL in LB. At least three independent replicates were performed for each concentration and reference. The solid lines are sigmoidal fits to the data and the fitting parameters are presented in Table 1. The shaded region indicates the duration of the reversible cell attachment, tplank.

Table 1 List of fitting parameters in Fig. 3, with the R2 value for each fit.

A modified sigmoidal function is used to model the biofilm formation curves, see Fig. 3. As discussed above, the characteristic “S”-shaped biofilm formation curve appears similar to the typical shape of planktonic bacterial growth curve, where sigmoidal models, such as Gompertz model, are commonly employed in analysis36,38. Our modified sigmoidal function can be expressed in terms of the resonant wavelength shift, as follows:

$${\Delta} \lambda = \frac{1}{{1/A + {\mathrm{exp}}[ - \alpha \ast (t - t_{{\mathrm{plank}}})]}},$$
(1)

where A is the amplitude of the profile, tplank is the time duration of the reversible cell attachment, which is indicated with a shaded region in Fig. 3, and \(\alpha\) is the biofilm formation rate. The relationship between the bacterial seeding density and the “planktonic” phase time tplank is discussed in Supplementary Information (see Supplementary Fig. 3). Although it is intuitive that a higher initial inoculum density leads to a shorter biofilm formation time, the technique readily allows us to quantify this formation time. More importantly, the technique allows us to quantify the biofilm’s response to antibiotics, as discussed in the next section.

Response of E. coli biofilms to antibiotics

Next, we use the sensor to study the response of biofilms to antibiotic challenge, especially the response of the cells at the bottom-layer of the biofilm. With monitoring the changes on the grating surface, we aim to detect which antibiotic can effectively disrupt the biofilm substratum. If the antibiotic causes a disruption to the distribution of the biofilm substratum, or partial or full detachment of the biofilm, we should observe a change in resonance wavelength of the grating. We use a concentration of 2 × 108 CFU per mL in order to speed up the process; using this concentration, the bottom-layer of the biofilm is typically established within 5–6 h (see Supplementary Fig. 1 and 2). Our real-time, non-destructive monitoring capability then allows us to introduce antibiotics before, during and after a biofilm has been formed on the sensor surface.

For uncomplicated lower urinary tract infections in adults, current UK NICE (The National Institute for Health and Care Excellence) guidelines recommend nitrofurantoin (which inhibits the citric acid cycle, as well as synthesis of DNA, RNA, and protein, also a bactericidal antibiotic) and trimethoprim (a folic acid synthesis inhibitor, a bacteriostatic antibiotic) as first line antibiotics due to their low risk of microbial resistance39. We, therefore, choose these two drugs as our model antibiotics. The MIC and the minimum bactericidal concentration (MBC) were pre-assayed with planktonic E. coli cells in 96-well plates (see Supplementary Information and Supplementary Fig. 4 for details). The MIC of trimethoprim for this strain is determined to be < 1 μg mL−1 and the MBC as 16–32 μg mL−1. Trimethoprim with a dose of 1 μg mL−1 is, therefore, introduced into the culture at times 0, 3.5 and 5.0 h. We make the following observations (Fig. 4):

  • When the antibiotic is injected at time 0 h, it completely halts cell attachments, and no colonisation and subsequent multi-layered biofilm formation is observed on the sensor surface;

  • When the antibiotic is added at 3.5 h, the colonies stop developing immediately upon introduction of the drug, halting any further establishment of the biofilm;

  • When 1x MIC of trimethoprim is added at 5.0 h (after the profile shows “saturation”), there is no observable change, i.e., the curve looks identical to the one without antibiotics added (see Supplementary Information). This indicates that there is no change, i.e., in terms of colony density or detachment, at the bottom-layer of the biofilm.

Fig. 4: Antimicrobial susceptibility testing in early-stage biofilms.
figure 4

A 1x MIC dose of trimethoprim is introduced to the culture at 0 h and at 3.5 h (as indicated by the vertical dashed lines). The solid black line is a sigmoidal fit to the data. After introducing the antibiotic, the data are fit to a straight line.

In order to study the biofilm tolerance, we increase the dose of trimethoprim from 1 to 500x MIC (equivalent to 20x MBC approximately). The antibiotic solutions are administrated at 5 h from the start of the experiments, i.e. after the monolayer of biofilm is established. There is no significant effect on the detected resonance wavelength at any dose (see Fig. 5(a) for 500x MIC and more details in Supplementary Fig. 5). As the sensor probes the substratum of the biofilm, i.e., the volume that is in direct contact with the grating, the results indicate that even with extremely high doses of trimethoprim, the sensor does not detect significant changes. A separate study on nitrofurantoin reveals very similar results to trimethoprim (see Supplementary Fig. 6 for more information). We can, therefore, conclude that nitrofurantoin and trimethoprim are effective against planktonic cells, but not against biofilms formed by the same strain.

Fig. 5: Three different techniques to monitor biofilms: GMR sensor (left), confocal fluorescence microscope (middle), and phase contrast microscope (right).
figure 5

Trimethoprim (final dose of 500x MIC, ae) and ciprofloxacin (final dose of 300x MIC, fj) injected at 5 h (dashed line) from the beginning of the experiment and microscopic images are obtained after 10 h (dash dotted line) from the start of the experiments. Confocal microscopic images (b, c and g, h) and phase contrast images (d, e and i, j) are all taken at 10 h from the start of the experiments; c and h, e and j are confocal and phase contrast images of biofilms with antibiotic injected at 5 h from the start of the experiments, respectively; The scale bars in the micrographs are all 10 μm long.

Confocal fluorescence microscope images confirm our findings (Fig. 5b, c, g, h). Following the addition of 500x MIC of trimethoprim, introduced to the culture at 5 h, the biofilm is allowed to continue “growing” for at least a further 5 h with the antibiotic present. We observe that there is still a good bacterial coverage on the grating after the multiple wash steps that are required during the staining process, and the majority of cells attached to the surface are still alive (Fig. 5c, and more confocal fluorescence images in Supplementary Fig. 7). This confirms that the bottom-layer of the biofilm is undisrupted, in agreement with our sensor result. As clearly observed in Fig. 5(c), there are too many surviving bacteria in the 500x MIC case that remain attached to the sensor surface to consider this a biofilm eradication concentration (MBEC). This observation indicates that the MBEC is higher than 500x MIC, i.e., 0.5 mg mL−1 in this case, which is also consistent with other reports employing fluorescent testing methods24,25. Colony counting on agar plates after 24 h incubation revealed that there are living cells in the remaining biofilms.

So our recognition that trimethoprim is not effective against biofilms is confirmed by multiple control methods.

We then tested two other bactericidal antibiotics, i.e., rifampicin (an RNA synthesis inhibitor, can be bacteriostatic or bactericidal depending on concentrations) and ciprofloxacin (inhibits DNA replication and exhibits both bacteriostatic and bactericidal activities), and they have been suggested because of their efficacy against biofilms. Identifying the best antimicrobials against biofilms is an active area of research13,40,41 that may benefit from a simple and real-time, non-destructive technique such as ours.

With our biofilm sensor, the disruption at the bottom of biofilm is observed as a shift of the resonance wavelength shortly after the administration of ciprofloxacin to a biofilm after 5 h of growth (Fig. 5(f)). Confocal microscopy with the live/dead assay confirms that the coverage of bacteria on the sensor surface is significantly reduced, and the cells in one remaining colony attached to the surface are also mostly dead (red colour) or injured with compromised cell membranes (yellow colour), shown in Fig. 5(h). This outcome is significantly different to what we observe with the other antibiotics, even though the phase contrast images of all these samples are rather similar (Fig. 5d–e and i–j). The phase contrast images include not only the cells attached to the surface, but also the biofilm cells that are detached from the surface but near the surface, as well as some planktonic cells. In contrast, confocal microscopy with the Live/Dead staining involves a few washing steps during the process (see “Methods”), therefore, the confocal images represent the biofilm cells that are still firmly attached to the sensor surface. In Fig. 5f, it certainly appears that 300x MIC ciprofloxacin results in a rapid and significant disruption on the bottom of the biofilm. Indeed, this disruption seems to cease after 5 h and our hypothesis is that ciprofloxacin causes removal of majority of the biofilm on the sensor surface, leaving a small number of cells possibly with some exocellular matrix remaining on the surface, which is reflected by a small resonance wavelength shift after 10 h in Fig. 5(f). In short, our GMR sensor, compared to the conventional microscopic techniques, provides a non-destructive, rapid, dynamic sensing and analysis technique, which can provide real-time information of the very bottom of biofilm.

For ease of comparison and reproducibility, all of these studies have been performed in LB broth and each set of experiments has been repeated for a minimum of three times. We have also performed total biofilm removal experiments with 70% ethanol wash followed by a piranha etch (a 3:1 mixture of sulfuric acid and 30% hydrogen peroxide). This protocol removes any organic residues on the grating surface including the extracellular matrix. A total recovery of the original resonance wavelength is observed, which indicates that complete removal of biofilms can be detected by our sensor. To ensure clinical relevance, we have also demonstrated that the technique is compatible with undiluted human urine (see Supplementary Fig. 8).

Discussion

In summary, we have introduced the technique of resonant hyperspectral imaging to monitoring the formation of Escherichia coli biofilms and have studied the response of these biofilms to a range of antibiotics. The key aspect that makes the technique so suitable for studying biofilms is that it only images the first few 100 nm from the bottom, i.e., the substratum, of the biofilm, which is the most important section of the film in terms of both early formation and antibiotic challenge. As the technique is only sensitive to the substratum, the sensing signal is not affected by the media, the thickness of the biofilm or to any planktonic cells suspended in the media, so it is easy to achieve a high signal to noise ratio. Furthermore, within the same assay, a quantitative indication of the bacteria concentration can be readily obtained by monitoring the time it takes for the onset of biofilm formation. Given this real-time monitoring capability, the technique also allows antimicrobial resistance testing in-situ, therefore offering the opportunity of quantitatively analysing the action and progression of different antibiotics against the biofilm within minutes to a few hours. The non-destructive nature of the technique is a unique advantage, compared to, e.g., fluorescence-based microscopy techniques.

We envisage that our system can be miniaturised into a hand-held device that could be implemented as a diagnostic within a clinical environment; such a realisation would allow for, e.g., the tailoring of antibiotic therapies to individual patients. Alternatively, the technique could be used for in-field biofilm detection, such as within water treatment plants or domestic water delivery pipes, food processing plants and equipment, heating, ventilation, and air-conditioning (HVAC) systems etc.. One can also envisage further improvements in terms of response time by accelerating bacterial attachment by using antibodies or carbohydrate coatings such as mannose. Undoubtedly, in a real biological or industrial system, the environment is far more complicated and polymicrobial biofilms tend to dominate. Although the polymicrobial nature of biofilms would not limit the performance of our sensor, additional sample or surface treatments may be used with our sensing system in order to improve specificity. For instance, pre-filtering or surface functionalisation could be employed in biofilm related bloodstream infection studies in order to gain some insight on the roles of each species in a biofilm community. Reports have also shown that the growth dynamics of a polymicrobial biofilm involve some extra phases42, which can be further explored using our sensor system in future work.

Overall, we believe that our technique may be widely applicable both in industry and healthcare for fundamental studies and for applications that require the detection and monitoring of biofilms. With its high sensitivity to any changes in the substratum of biofilms, our sensor can be used in conjunction with other conventional techniques in order to gain a comprehensive understanding of biofilm formation, tolerance and antimicrobial resistance.

Methods

Bacterial strain and growth conditions

E. coli K-12 carrying the F conjugative plasmid, also known as E. coli TG1, is chosen in this work as it has been shown previously to promote thick, mature biofilms within a short period of time43,44. A single colony is inoculated into a test tube containing 25 mL of liquid Luria-Bertani (LB) broth and placed in an orbital rotating shaker at 4 x g overnight at 37 °C. Some of this culture is then transferred and diluted within a fresh tube of LB broth to obtain the required concentrations of the microbial suspension. Optical density (OD) measurements are performed alongside separate cell counting on LB agar plates to determine bacterial concentrations. For example, OD600nm = 0.2 corresponds to a 2 × 108 CFU per mL concentration.

Fabrication of resonance gratings and flow cell

In order to fabricate the gratings, a 150 nm Si3N4-on-glass substrate is cleaned in a piranha solution (hydrogen peroxide: sulfuric acid = 1:3 ratio), rinsed in acetone and isopropanol, and dried with nitrogen. The substrate is then coated with e-beam resist (ARP-13, AllResist GmbH), spun at 280 x g for 60 s, and baked at 180 °C for 10 min, resulting in a film of approximately 400 nm. For charge dissipation during e-beam exposure, a thin film of aluminium (20 nm) is deposited on top of the resist using a thermal evaporator (HEX, Mantis). The grating pattern is defined in the e-beam resist using an electron beam lithography system (Raith GmbH Voyager 50 kV), followed by pattern transfer into the substrate using reactive ion etching with a gas mixture of CHF3 and O2. The depth of the grating in the substrate is 150 nm. The aluminium layer is removed in phosphoric acid and the residue of e-beam resist is removed with Microposit resist remover 1165 (MicroChem). The fabricated grating is then fixed to the bottom of a sterile quartz glass container. The flow of E. coli culture is generated by a peristaltic pump with sterile silicone tubes from a reservoir of culture, typically a total of 40 mL, in a 37 °C water bath. Each set of experiments (including each E. coli concentration, references, each antibiotic and different concentrations) were repeated a minimum of three independent times.

Live/dead staining and confocal microscopy

After a certain time of growth, the grating is taken out from the flow cell, gently washed with phosphate buffered saline (PBS) buffer (Sigma-Aldrich) three times to remove the remains of the medium and planktonic cells, as well as loosely attached non-biofilm cells, and then incubated for 15 min in the dark with the BacLight Live/Dead viability kit (Thermo Fisher Scientific) to stain the cells with two fluorescent dyes, SYTO® 9 (green) and propidium iodide (red). Samples were then rinsed twice with PBS buffer and sealed under a coverslip. The stained biofilms on the grating are visualised using a ZEISS LSM 880 Confocal Microscope with a plan apochromat 63x oil-immersion objective. The Live/Dead viability kit stains live cells green, dead cells red and some cells appear yellow or orange indicating that those bacteria are injured with possibly compromised cell membranes45.

Antibiotic preparation and MIC assay

Stock solution of 10 mg mL1 of four antibiotics, i.e. trimethoprim, nitrofurantoin, rifampicin and ciprofloxacin (Sigma-Aldrich), are prepared by dissolving in dimethyl sulfoxide, diluting in deionized water and filter sterilising (0.22 µm syringe filter, Fisher Scientific). A microdilution assay was also performed on 96-well plates by exposing E. coli TG1 to a serial dilution of trimethoprim, nitrofurantoin, rifampicin and ciprofloxacin, in order to determine the MIC of each drug. The reporter dye resazurin was added to indicate the viability status of the cells46. For more details on the protocol, see Supplementary Information. The MIC measurements were performed with OD = 0.2, i.e., 2 × 108 CFU mL1, and repeated for four times.

Bacteria-spiked urine sample

For the bacteria-spiked urine sample shown in Supplementary Information, an overnight-grown suspension of E. coli cells in LB broth is centrifuged at 14,000 x g for 10 min, and washed in syringe-filtered human urine (0.22 µm filter, Fisher Scientific). This process is repeated three times. Then the E. coli cells are resuspended in syringe-filtered human urine and the final concentration is made to be 2 × 108 CFU per mL in urine.

Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.