Density shaping in photokinetic bacteria or colloids relies on the connection between density and local speed. The density ρ ⁢ ( 𝐫 ) ∝ 1 / v ⁢ ( 𝐫 ) is always a steady-state solution of the master equation of a self-propelled particle with isotropic reorientation dynamics and spatially varying speed v ⁢ ( 𝐫 ) (Cates and Tailleur, 2015). In our case, v ⁢ ( 𝐫 ) = v ⁢ ( I ⁢ ( 𝐫 ) ) where 𝐫 = ( x , y ) is the position in the two dimensional image space and I ⁢ ( 𝐫 ) the light intensity at 𝐫 . This result assumes that all bacteria have the same response to light and that they instantaneously adapt to intensity variations so that the speed only depends on the local value of I . However, suspensions of swimming bacteria, are known to be characterized by motility properties that occur in broad distributions and, in principle, a broad spectrum of light responses could be found. To quantify the effect of light on the speed distributions of our strain, we monitored bacterial dynamics while projecting a chessboard pattern consisting of 12 different levels of light intensity. To do this we couple a DLP projector to a custom video-microscopy setup working in both bright-field and dark-field mode (see Figure 1 and Materials and methods).

Figure 1 Download asset Open asset Scheme of the experimental setup. Schematic representation of the custom inverted-microscope used in the experiments (see Materials and methods). Green light from a DMD based DLP projector is filtered by a bandpass filter F1 (central wavelength 520 nm) and than coupled to the microscope objective through a dichroic mirror (DM). A long pass filter (F2) prevents illumination light to reach the camera. Bacteria are sealed in a square microcapillary glued on a metallic sample holder with a circular aperture. https://doi.org/10.7554/eLife.36608.003

Using differential dynamic microscopy (DDM) (Cerbino and Trappe, 2008; Wilson et al., 2011; Maggi et al., 2013) we extract the light dependent values of the mean v and standard deviation σ of the speed distributions (Figure 2(a)) (see Materials and methods). Although the absolute value of the swimming speed depends on several factors (strain, growth medium, etc.) we find a non linear speed response that is consistent with what previously reported for PR expressing bacteria. In particular the speed versus intensity curve is very well fitted by a hyperbola showing saturation for large light intensity values as already reported in (Walter et al., 2007; Schwarz-Linek et al., 2016; Vizsnyiczai et al., 2017; Arlt et al., 2018).

Figure 2 Download asset Open asset Light dependent speed distribution. (a) Mean value v (circles) and standard deviation σ (squares) of bacterial speeds as a function of light power density. Symbols and error bars are respectively the mean and standard deviation of 14 repeated measurements of v and σ . Curves are fits with hyperbolas. (b) Parametric plot of σ vs v . The line is a linear fit passing through zero. https://doi.org/10.7554/eLife.36608.004

We also find that, throughout the intensity range, v and σ are directly proportional (see Figure 2(b)) suggesting a homogeneous growth law for individual cell speeds v i ⁢ ( I ) = v i s ⁢ f ⁢ ( I ) , where v i s is the saturation speed for the i -th cell and f ⁢ ( I ) is a dimensionless function saturating at one for large intensities. Interestingly, in this scenario, the mean speed v ⁢ ( I ) will also be proportional to f ⁢ ( I ) so that the probability density ρ i for the generic i -th cell will be proportional to the inverse of the local mean speed:

ρ i ⁢ ( 𝐫 ) ∝ 1 v i ⁢ ( I ⁢ ( 𝐫 ) ) ∝ 1 f ⁢ ( I ⁢ ( 𝐫 ) ) ∝ 1 v ⁢ ( I ⁢ ( 𝐫 ) ) .

This implies that, despite broad speed distributions, the local density is expected to be only determined by the mean local speed, as set by the light intensity pattern and measured by DDM. To validate this hypothesis we use a DLP projector to display a complex light pattern onto a 400 µm thick layer of cells (Figure 1) that have been preliminarily exposed to a uniform bright illumination for 5 min. This time is much longer than the speed response time of bacteria (Figure 4) thus ensuring that cells are initialized to swim at maximal speed. The projecting system has an optical resolution of 2 µm approximately matching the size of a single cell which represents the physical ‘pixel’ of our density images. This value sets the limit for the minimum theoretical resolution of density configurations that would be achievable if bacteria could be precisely and statically arranged in space. In practice, as we will see, the real resolution will always be larger for two main reasons: (i) bacteria do not respond instantly to light temporal variations thus introducing a blur in the target speed map, (ii) the stationary state is an ensemble of noisy patterns that constantly fluctuate because of swimming and Brownian motions of bacteria. After projecting an inverted Mona Lisa image, bacteria start to concentrate in dark regions while moving out from the more illuminated areas. After about 4 min, dark field microscopy reveals a recognizable bacterial ‘replica’ of Leonardo’s painting, where brighter areas correspond to regions of accumulated cells. Once a stationary pattern is reached, we collect a time averaged image from which we extract the bacterial density ρ * shown in Figure 3 normalized to be one when uniform (see Materials and methods).

Figure 3 Download asset Open asset Shaping density with light. (a) Dark-field microscopy image of the sample obtained after projecting a static light pattern for 4 min (averaged for 2 min). Scale bar 100 µm. (b) Local speed map obtained by interpolating the data-points of Figure 2(a) at the values of the local (projected) light intensity pattern. (c) The circles represent the mean value of the normalized sample density over image pixels corresponding to the same light intensity, plotted as a function of the corresponding inverse local speed. The dashed line is a linear fit of the high-speed points. The error bars are the standard deviation of the density at the same value of the computed inverse average speed. Solid line represent the prediction from the memory blur model described in the text. https://doi.org/10.7554/eLife.36608.006

We split the density image into components corresponding to the same illumination level I . We then average the density within each component and report in Figure 3(c) the obtained value as a function of the inverse mean speed 1 / v ⁢ ( I ) obtained from the speed vs intensity curve in Figure 2(a). The high speed side of the graph can be very well fitted by a straight line with a finite intercept q = 0.5 . This suggests that 50% of the total scattering objects in the field of view responds to light and can be spatially modulated while the remaining 50% can be attributed to cells which are non-motile or insensitive to light and also to stray light generated away from the focal plane. The ratio between the maximum and minimum modulation of the light sensitive component can be obtained as max ⁢ [ ρ * - q ] / min ⁢ [ ρ * - q ] = 2 . A strong deviation from linearity is evident in the high density/low speed region. A violation of the ρ ∝ 1 / v law can be attributed to many factors that are not included in the simple theory discussed above. In particular, the theory assumes that speed is a local function of space which would only be the case if bacteria instantly adapt to temporal changes in light intensity. However, previous studies have evidenced that speed response is not instantaneous but it displays a relaxation pattern characterized by multiple timescales. In addition to a fast relaxation time associated to the membrane discharge (Walter et al., 2007), ATP synthase and the dynamics of stator units of the flagellar motors introduce slower timescales in the speed relaxation dynamics (Tipping et al., 2013; Arlt et al., 2018). Using DDM we measured speed response to a uniform light pattern whose intensity switches between two values every 100 s. Results are reported in Figure 4 and clearly show the presence of two timescales. The short time scale is smaller than our time resolution (1 s) and appears as an instantaneous jump that accounts for about a fraction β = 0.44 of the total relaxation. A slower relaxation follows and it is well fitted by an exponential function with a time constant τ m = 35 s that is the same for both the rising and falling relaxations. As a result, bacteria will experience an effective speed map that is a blurred version of what we would expect for an instantaneous response V ⁢ ( 𝐫 ) = v ⁢ ( I ⁢ ( 𝐫 ) ) . In the case of smooth swimming cells, with a two-step light response, we calculate that, for weak speed modulations around a baseline value V 0 , the actual speed map can be obtained as a simple convolution (see Materials and methods):

Figure 4 Download asset Open asset Speed response to light step. Average bacteria speeds as a function of time during periodic illumination with a square wave of period 200 s. Open circles represent experimental data averaged over eight periods while solid line is a fit with a step response followed by an exponential relaxation. https://doi.org/10.7554/eLife.36608.008

(1) w ⁢ ( x , y ) ≃ β ⁢ V ⁢ ( x , y ) + ( 1 - β ) ⁢ ∫ V ⁢ ( x - x ′ , y - y ′ ) ⁢ γ ⁢ ( x ′ , y ′ ) ⁢ 𝑑 x ′ ⁢ 𝑑 y ′

with γ ⁢ ( x , y ) a convolution kernel that is analytic in Fourier space:

(2) γ ~ ⁢ ( q ) = k q ⁢ arctan ⁡ ( q k )

where q = q x 2 + q y 2 is the modulus of the wave vector and k − 1 = v 0 τ m . Assuming that the stationary distribution will remain isotropic even in the presence of memory, the relation ρ ∝ 1 / w will then still be valid provided one uses the actual, blurred speed map w and not the original map V corresponding to instantaneous response. We can then anticipate the stationary density once we calculate the actual speed map w with the convolution formula (1). Recalling that only a fraction α of cells is motile the estimated normalized stationary density will be

(3) ρ ∗ ( x , y ) = α ( w ( x , y ) − 1 w − 1 ¯ − 1 ) + 1

where w − 1 ¯ is the spatial average of the inverse actual speed w ⁢ ( x , y ) . Plotting ρ * as a function of 1 / V we find that this simple model quantitatively explains the density behavior in Figure 3 with the natural choice of free parameters α = 0.5 , β = 0.44 , and k - 1 = v ¯ ⁢ τ m = 59 µm where v ¯ is the spatial average of V ⁢ ( x , y ) . This result is certainly encouraging and prompts for a deeper and more systematic investigation using simpler light patterns. Our aim here, however, is to investigate the resolution limits of density shaping with photokinetic bacteria. Although memory effects could be reduced by deleting ATP-synthase genes (Arlt et al., 2018), resulting in a suppression of the slow component in speed relaxation, response will never be truly instantaneous. In addition to memory effects, steric and/or hydrodynamic interactions will always affect density by hindering bacteria penetration and further accumulation in densely packed regions. The combined action of these effects on the stationary density map cannot be easily incorporated in a theoretical model that provides precise quantitative predictions with a priori known parameters.

An alternative and more practical strategy to improve the accuracy of density shaping, is to implement a feedback control loop. We set up an automated control loop that performs one iteration every 20 s, comparing the current density map to the desired target image and updating the illumination pattern accordingly (see Materials and methods). Light levels are increased in those regions with a density that exceeds the target value and decreased where density is lower. At each step the light intensity increment is simply proportional to the pixel by pixel difference of target and actual density images. We quantify the distance between the obtained density pattern and the target image by the sum of the squared pixel-by-pixel difference after a proper rescaling procedure (see Materials and methods).

As soon as the feedback is turned on at time t 0 = 6 min (Figure 5(a)) the distance from the target starts to decrease reaching a new stationary value after about 4 min. The final stationary density map shows a level of detail significantly higher than the image obtained before the feedback was turned on (Figure 5(b,c)). The image is stable and resolution does not deteriorate for hours. However a dark region surrounds the illuminated area so that swimming cells that exit the field of view do not come back and the number of motile cells in the illuminated area is reduced by about 50% in one hour. This issue is the main limiting factor for the lifetime of our patterns and could be solved in the future by using sample chambers that match the size of the illuminated area. As evidenced in Figure 5(d), the feedback precompensates this blurring effect due to memory by converging to a sharpened version of the initial target image. Results of comparable quality have been replicated four times in each of the two independent biological replicates.

Figure 5 Download asset Open asset Improved density control with a feedback loop. (a) Time evolution of the distance from the target normalized to the initial value (circles) before and after activating the feedback loop (gray area). The yellow and green bars indicate the time interval over which we average the density maps (shown in (b)) before and after feedback respectively. The full curve is a fit with a double exponential. (b) Comparison of the density map obtained by averaging for 2 min before (top) and after the feedback loop has been turned on (bottom) (see colored bars in (a)). (c) Time averaged density profile (6 min) with feedback on. (d) Projected light intensity patterns at t = 0 (left) and after feedback optimization (right). Scale bars are 100 µm. https://doi.org/10.7554/eLife.36608.010

A remarkable feature of this optically controlled material lays in its intrinsic dynamic and reconfigurable nature. As a demonstration of this property we show the dynamic morphing of a bacterial layer from an Albert Einstein’s to a Charles Darwin’s portrait (see Figure 6 and Video 1). The morphing is triggered by instantly switching between the two target images on the DLP projector and exponentially converges to the second target in a characteristic time of 1.8 min.

Figure 6 Download asset Open asset Reconfigurable density patterns. Starting from the stationary density modulation (a) we switch to a new light pattern at time 0 and record the density distribution of bacteria as it morphs through the intermediate state (b) and reaches the final state (c). (d) Time evolution of the normalized squared distances between instantaneous density maps and the initial (blue circles) and final (orange circles) targets. Curves are exponential fits. https://doi.org/10.7554/eLife.36608.012