## Abstract

Active particles can self-propel by exploiting locally available energy resources. When powered by light, these resources can be distributed with high resolution allowing spatio-temporal modulation of motility. Here we show that the random walks of light-driven bacteria are rectified when they swim in a structured light field that is obtained by a simple geometric transformation of a previous system snapshot. The obtained currents achieve an optimal value that we establish by general theoretical arguments. This optical feedback is used to gather and confine bacteria in high-density and high-activity regions that can be dynamically relocated and reconfigured. Moving away from the boundaries of these optically confined states, the density decays to zero in a few tens of micrometers, exhibiting steep exponential tails that suppress cell escape and ensure long-term stability. Our method is general and scalable, providing a versatile tool to produce localized and tunable active baths for microengineering applications and systematic studies of non-equilibrium phenomena in active systems.

## Introduction

The possibility of having a light-controllable self-propulsion speed at the microscale has been recently demonstrated in both synthetic active particles^{1,2,3,4} and motile biological cells^{5}. This, coupled with spatial light modulators, allows the study of active matter with motility characteristics that can be precisely controlled in space and time. For instance, stationary distributions of non interacting active particles with a space dependent speed are characterized by a constant value of the product *ρ**v* between local values of density *ρ* and velocity modulus *v*^{6,7}. This has been exploited in light driven bacteria to paint reconfigurable structures using static light patterns, where cells accumulate in darker and thus slower regions^{8,9}. Static light patterns, however, cannot be used to generate stationary currents in systems of purely photokinetic particles because of the time reversal symmetry of microscopic dynamics^{10}. Furthermore, the study of photokinetic cells in static patterns is often limited in time because of continuous escape of motile cells outside the observation area. This is because structured illumination is confined by the finite size of the spatial light modulator, so that the system is surrounded by a dark region of particles with *v* = 0. Since the product *ρ**v* must remain approximately constant throughout the system, bacteria will over time be absorbed by the low-motility surroundings. To avoid this we must develop new light control strategies to generate stationary currents that counterbalance the leaking of active particles outside of the illumination area. Methods to achieve a net current in light-driven systems range from taking advantage of an orientational response to light intensity gradients in a system of synthetic photoactivated microparticles^{11,12} to breaking time reversal symmetry at a microscopic level^{13} by projecting dynamic light patterns with a time asymmetry^{10,14,15}. Another possible strategy is to break time reversal symmetry through particle interactions as proposed in simulations^{16}. None of these methods, however, combines the efficiency and scalability that are required to accumulate large numbers of active particles in regions of high density and high motility.

Here we demonstrate that, by projecting back onto a suspension of photokinetic bacteria a properly transformed image of the system at an earlier time, we can guide cells with maximum efficiency along a designable flow field. Specifically, an optical feedback keeps the cells under a binary illumination pattern such that only bacteria moving in the desired direction are illuminated by a bright green spotlight and swim fast. Other cells are kept under a background of low light intensity and swim slower until a tumble turns them in the right direction. We exploit this method to optically gather and confine large collections of cells in high density and high activity regions over long time periods. The spatial structure of these confined stationary states is quantitatively described by a run and tumble model of active particles with a self propulsion speed that depends on both position and direction. Furthermore, we prove that these active formations can be split, merged and relocated in space, while conserving the total number of trapped cells. In a broader context, controllable currents of active particles^{17,18} may have important applications for the transport of passive cargoes in microfluidic environments^{19,20,21}, for microengineering^{22,23,24}, and for fundamental studies in the statistical physics of active systems^{25,26,27,28,29}.

## Results

### A Maxwell demon for active particles

Let us suppose that one has complete knowledge of the individual positions and velocities of active particles. Such a “Maxwell demon”^{30} could use this information to generate a net flow in a desired direction \(\hat{{{{{{{{\bf{n}}}}}}}}}\) by adjusting individual particles’ speeds. The maximal current that the demon could produce in this way would be obtained by giving the maximum available speed *v*_{1} to all particles with a positive velocity component along \(\hat{{{{{{{{\bf{n}}}}}}}}}\), and the minimum available speed *v*_{0} to those moving in the opposite direction:

where *θ* is the angle that the particle velocity forms with \(\hat{{{{{{{{\bf{n}}}}}}}}}\). In a 2D system, with an isotropic and homogeneous reorientational dynamics, the average velocity component in the \(\hat{{{{{{{{\bf{n}}}}}}}}}\) direction would have a magnitude of:

In photokinetic bacteria, swimming speed is a function of incident light so that individual speeds can be controlled by projecting tailored light patterns. Although feasible in principle, the control strategy described above would require continuous particle tracking which may make it difficult to implement and not easily scalable to large systems. We devise a much simpler, faster and scalable strategy consisting of three main steps. Using dark-field optical microscopy, we first capture a snapshot of the system in which bacteria appear as white spots on a dark background. We then dilate the image using a circular kernel and apply a threshold so that every cell in the original image is replaced by an approximately circular blob of average radius *R*. Then we remap this image by a plane transformation that moves the content of every pixel by a distance Δ towards the desired flow direction \(\hat{{{{{{{{\bf{n}}}}}}}}}\) and finally we project it back onto the system after a delay time *τ* (Fig. 1a). In this way, bacteria that are moving in the positive \(\hat{{{{{{{{\bf{n}}}}}}}}}\) direction would be constantly under the spotlight and swim fast while bacteria moving in the opposite direction would be in the dark and swim slow. Like a “Maxwell demon”, the feedback loop rectifies the motion of bacteria by “opening or closing the door”, i.e. bright or dark exposure, depending on the direction of motion of the particles.

To implement the method experimentally, we fill a 10 μm height chamber with genetically modified *E. coli* bacteria expressing the light-driven proton pump proteorhodopsin (see Methods). The chamber is sealed so that, after the cells have consumed all the oxygen in the buffer through respiration, the proton motive force drops down and the flagellar motors stop spinning and start responding to external green light stimuli^{5}. Using a digital light projector, we can spatially control swimming speeds by illuminating the sample with green light patterns. In particular, using the feedback algorithm described above, we generate a binary image with bright spots of intensity *I*_{1} = 4.6 mW mm^{−2} over a background of intensity *I*_{0} = 0.2 mW mm^{−2}. As shown in Fig. 1b, when we apply a shift in the positive *x* direction (axial transformation in Fig. 1a), bacteria that swim towards the right move faster than those swimming to the left. This is evidenced in the figure by the white traces obtained by integrating images acquired in the previous 2 s and which are clearly longer for bacteria moving to the right. A net drift speed of \({\bar{v}}^{* } \sim 2\) μm s^{−1} is obtained, and cells start to accumulate in the dark right margin of the observation area (See Supplementary Movie 1).

### Controllable velocity field

We next study how to optimize cell rectification by tuning the feedback parameters. The radius of the spotlight *R* must be clearly larger that the cell size to ensure a stable illumination against cell fluctuations in orientation and position. At the same time, *R* should be small enough to reduce unwanted overlaps with spotlights from different cells. In all experiments we choose *R* values in the range 2–4 μm. Our *E. coli* cells reorient by “tumbling”, random reorientation events caused by transient unbundling of flagella^{31} and occurring with rate *λ* ≈ 1 s^{−1}. For this reason the delay time *τ* is naturally constrained to be significantly smaller than the persistence time of the trajectories (i.e. *τ* ≪ *λ*^{−1}) so we can assume that bacteria move in straight lines during the time interval *τ*. We empirically find that delays in the range 0.1 − 0.5 s produce optimal results (see Supplementary Fig. 1) and always keep *τ *≤ 0.2 s in all experiments. To maximize net speed we want to be as close as possible to an angular speed dependence as that of Eq. (1). Ideally, for point-like bacteria, we could make sure that the speed is maximum for swimming directions ∣*θ*∣ < *π*/2 when Δ is chosen as (see Fig. 2a):

For a given choice of *R* and *τ*, we experimentally scan different Δ values, track swimming cells and compute the drift speed \(\bar{v}\) as the average *x* component of cell velocities over time (Fig. 2b). Theoretically, for point-like cells, all swimming with the same speeds *v*_{0} and *v*_{1} when exposed to the two light levels *I*_{0} and *I*_{1}, we would only expect to see a non-zero average speed in the interval *v*_{1}*τ* − *R* < Δ < *v*_{1}*τ* + *R* with a maximum speed \({\bar{v}}^{* }\) at Δ^{*}. We measure a drift speed around 2.5 μm s^{−1} for Δ*V* = *v*_{1} − *v*_{0} = 6.5 μm s^{−1}, which is in substantial agreement with the theoretical limit of \({\bar{v}}^{* }=2.1\) μm s^{−1}. The experimental results present a peak at a position that is close to Δ^{*} but much broader than expected. This broadening is possibly due to the finite cell size along with the large variability of swimming speeds in the sample^{9,32}. In particular, for the two mean speeds *v*_{1} = 10 μm s^{−1} and *v*_{0} = 3.5 μm s^{−1}, the corresponding standard deviations are \({\sigma }_{{v}_{1}}=3.5\) μm s^{−1} and \({\sigma }_{{v}_{0}}=1.5\) μm s^{−1}.

The polar plot of the instantaneous velocities (Fig. 2c, d) clearly shows that this method can produce strongly angular dependent speeds. For large displacements Δ ≫ *R*, all the bacteria are illuminated with low light intensity, and thus have isotropically minimum velocity modulus (*v*_{0}). On the other hand, for very small displacements Δ = 0, the cells are always illuminated with a high intensity, thus the modulus of the velocity is maximum (*v*_{1}) for every direction *θ*. The optimum case where the flow is maximized is of the order of Δ ~ *R*, and the velocity field has maximum modulus for small *θ* and minimum modulus for large *θ*. The experimental shape is similar to the theoretical Eq. (1) (discontinuous gray line in Fig. 2d), with a smoother transition around ∣*θ*∣ = *π*/2.

### Optical confinement in high activity regions

A common problem when dealing with light-driven particles is that we can usually modulate light over a finite field of view within an otherwise dark and non motile sample. In these situations we have a constant outflow of active particles that, once they enter the surrounding darkness, stop swimming and are lost forever. We now show that, using our dynamic feedback, we can use light to confine bacteria in regions of tunable size, density, and motility. The obtained steady states have a density that decays exponentially towards the boundary, thus minimizing particle loss. Let us first theoretically analyze the structure of the steady state that is obtained if bacteria swim with the maximum speed *v*_{1} in a central band of width 2*a*. Outside of the band the speed has an angular dependence as in Eq. (1) where \(\hat{{{{{{{{\bf{n}}}}}}}}}=-\hat{{{{{{{{\bf{x}}}}}}}}}\) for *x* > *a* and \(\hat{{{{{{{{\bf{n}}}}}}}}}=\hat{{{{{{{{\bf{x}}}}}}}}}\) for *x* < − *a* (see Fig. 3a). For *x* > *a*, the number density *P*(*x*, *θ*, *t*) of bacteria swimming at position *x* with an angle *θ* will evolve in time with the equation^{33}:

where we assumed 2D run and tumble dynamics with a tumbling rate *λ* and introduced the total number density *ρ*(*x*, *t*) = ∫*P*(*x*, *θ*, *t*)*d**θ*. The first term on the right side of Eq. (4) represents the divergence of the particles’ current, the second one particle loss due to tumbling and reorientation, while the last term corresponds to the particle gain due to tumbling from all other directions into *θ*. We now look for stationary states where the spatial and angular densities factorize as *P*(*x*, *θ*) = *ρ*(*x*)*χ*(*θ*):

which by separating variables becomes:

where *k* is a constant whose value can be find by imposing the normalization condition:

A trivial solution is given by *k* = 0 and thus *ρ*(*x*) = constant and *χ* = 1/2*π* corresponding to a steady homogeneous flow with mean speed *v** and extending to infinity. To find a zero flux steady state we need a non vanishing solution for Eq. (7) which can be obtained by numerical solution or, with excellent approximation, by the analytic expression (see Supplementary Note 1):

Remarkably, for *x* > *a* the corresponding density *ρ*(*x*) ∝ *e*^{−kx} decays exponentially on a length scale that, for typical speeds and tumbling rates, can be a few tens of micrometers. For *x* < *a* the stationary density will be uniform while at the boundary *x* = *a* the internal and external currents must satisfy the continuity conditions:

so that:

And the full solution reads:

To check this theoretical prediction we simulate non-interacting run and tumble particles with an angular dependent speed as in Fig. 3a when ∣*x*∣ > *a*, while moving at maximum speed *v*_{1} for ∣*x*∣ < *a* (see Fig. 3a). Simulation results are reported Fig. 3b showing an excellent agreement with Eq. (10). In an experimental system, however, this axial geometry would be still affected by cell leakage at the top and bottom boundaries. This could be solved by driving bacteria radially towards a circular region contained in the illuminated area (see Fig. 3c). Remarkably the solution in Eq. (10) still provides a near-perfect description of the density profile from simulations performed in the radial geometry, as expected when *a* is much larger than the persistence length ≈ *v*_{1}/*λ*. To demonstrate this possibility experimentally, we modify the last step in the feedback algorithm by substituting the lateral shift in \(\hat{{{{{{{{\bf{n}}}}}}}}}=\hat{{{{{{{{\bf{x}}}}}}}}}\) of the dilated image with a radial contraction by a constant displacement in the direction \(\hat{{{{{{{{\bf{n}}}}}}}}}=-\hat{{{{{{{{\bf{r}}}}}}}}}\) (Fig. 3b). With this, we guide the bacteria towards a central circle of radius *a* where we set a uniform light intensity *I*_{1} corresponding to isotropic swimming with maximum speed *v*_{1}. Outside of the disk we get, for the optimal case Δ = Δ^{*}, a mean cell velocity that can be still approximated by Eq. (1), where now *θ* is the angle formed by the swimming direction and the inward radial vector \(-\hat{{{{{{{{\bf{r}}}}}}}}}\). Starting from a uniform density at \(t=0\ {{{{\min }}}}\) we turn on the radial feedback and observe a radial flow of bacteria moving towards the central circle shown in green (Fig. 4a), where the number of bacteria increases until a stationary density profile is reached in a few minutes (Fig. 4c). The timescale *τ*_{r} for this relaxation can be estimated as the time needed for bacteria to travel at the drift speed \({\bar{v}}\approx 2\) μm s^{−1} over a distance *L* ≈ 400 μm from the edge to the center of the illuminated area. This gives \({\tau }_{r}\approx L/{\bar{v}}\approx 3\) min which is in agreement with experimental observations. With an initial radius of *a* = 145 μm we observe a 3 fold increase in bacterial density within the accumulation circle (Fig. 4c). The density profile of the stationary state is characterized by an exponential decay for *r* > *a* with a fitted decay length of *ℓ* = 1/*k* = 19 μm. For a radius *a* that is much larger than bacteria persistence length we expect, as also confirmed by simulations in Fig. 3b, that an exponential decay with the same *k* as in Eq. (8) could still describe the steady state in the radial case. The fitted *k* value is consistent with the theoretical prediction in Eq. (8) if we assume a tumbling rate *λ* = 0.8 s^{−1} together with the measured values for *v*_{0} = 5 μm s^{−1} and *v*_{1} = 10 μm s^{−1}. The quantitative agreement between experiments and the theoretical predictions for the non-interacting run and tumble model, also suggests that interactions, steric or hydrodynamic, do not play a relevant role here. When we keep decreasing *a*, we find that internal density increases up to ~ 7 fold with respect to the initial uniform density, while the total number of cells is conserved. The relaxation time is much shorter in this case, due to the fact that the travel distance is just the change in radius Δ*a* = 18 μm instead of *L*. We keep each radius fixed for 10 min to get a well averaged density profile and verify the stability of the method over long timescales. This proves that our method can indeed be used to optically concentrate and confine thousands of actively swimming bacteria within regions of independently tunable density and activity (Fig. 4b, c). All stationary density profiles in Fig. 4d can be fitted by Eq. (10) with *k* and a global factor as the free fit parameters. The agreement of the fits improves for larger confinement radius *a* which can be partly due to the fact that we assume *a* much larger than persistence length in the theoretical model. Ultimately, this is a fully reversible process, i.e. when switching off the feedback loop and applying constant illumination to the full sample area, the accumulation dissolves in just a few seconds (Fig. 4d). This provides further evidence of the high activity of the confined cells (see Supplementary Movie 3).

As a further feature of our method we show that it is possible to split, relocate and merge again optically confined clouds of highly motile bacteria (Fig. 5, see Supplementary Movie 4). To do that we apply our optical feedback with a radial transform that constantly drives bacteria towards two centers (Fig. 1a). This allows to effectively redistribute bacteria in space conserving the total number of trapped cells as shown in the density profiles in Fig. 5. This is not the case when using a sequence of static patterns^{9} for dynamic density shaping of photokinetic bacteria: while we could concentrate bacteria inside a dark disk within an illuminated area and then move the disk to transport bacteria, by moving the dark disc the bacteria on the trailing edge will be re-exposed to light and, for the most part, swim away forever.

## Discussion

In summary, we demonstrated an optical feedback loop that couples swimming bacteria to their past configurations, thereby breaking time reversal symmetry and rectifying their random walks into designable flow fields. The feedback is based on simple geometric transformations of a system image taken at an earlier time, so it is robust and scalable to large and concentrated suspensions, although a decrease in efficiency is expected when interparticle distances become comparable with the spotlight size. We show that bacteria swimming in this dynamic structured illumination can be confined in regions with simultaneous high density and high activity. As predicted by a run and tumble dynamics with anisotropic speed, the stationary density of these optically confined states is characterized by rapidly decaying exponential tails that prevent cell escape and allow the total number of particles to be conserved for hours, as opposed to other approaches that accumulate slow bacteria and deplete density over time^{8,9}. By dynamically changing the applied geometric transformation we can split, relocate and finally merge these optically confined clouds of swimming bacteria always preserving the total cell number. Although we used photokinetic *E. coli* the method could be easily adapted to many natural or synthetic microswimmers with light controlled motility. This research also opens up many new directions for future developments, including the possibility of having adjacent bacterial clouds with independently controlled density and motility parameters to study non-equilibrium phenomena such as active pressure. Additionally, the use of more complex convolution kernels for dilation could, for example, help sort bacteria by their maximum speed. More generally, optical transport and confinement of active matter will provide a versatile tool to produce reconfigurable active baths for controllable powering of micromachines or systematic studies of non-equilibrium phenomena in active systems.

## Methods

### Bacterial Strain

For all the experiments we used the *E. coli* strain AUG, constructed using the *E. coli* AB1157 obtained from the CGSC (Coli Genetic Stock Center). Using lambda red recombination with the recombination plasmid pKD46^{34} we deleted the operon econding the ATP Synthase complex as in ref. ^{8} (corresponding to the position 3,915,643-3,922,426 of the *E. coli* MG16555 chromosome). We replaced it with the CmR cassette flanked by 50 bp homology amplified using as template pKD3 (see Supplementary Note 2). PCR reactions confirmed the desired genotype, we thus obtained a strain AB1557 Δ *unc::cmR*. Then we transformed it with the plasmid pBAD-His C encoding the SAR86 *γ*-proteobacterial photorhodopsin (PR) (a kind gift from Judith Armitage, University of Oxford)^{35}.

### Sample preparation

*E. coli* colonies from frozen stocks are grown overnight at 30 °C on LB agar plates supplemented with ampicillin (100 μg/ml). A colony is picked and cultivated overnight at 30 °C at 200 rpm in 10 ml of LB with ampicillin. The next day, the overnight culture is diluted 100 times into 5 ml of TB containing ampicillin, and grown at 30 °C, 200 rpm for 4h. Then all-*trans-retinal* (20 μM) and l-arabinose (1 mM) are added to ensure expression and proper folding of PR in the membrane. The cells are collected after 1 hour of induction by centrifugation at 1300 × *g* for 5 min at room temperature. The supernatant is removed and the bacterial pellet is resuspended in a motility buffer, containing 10mM potassium phosphate (pH 7.0), 0.1 mM EDTA (pH 7.0), 0.02% Tween20 and l-Lactate 10 mM. This washing procedure is repeated three times in total, then the cells are resuspended at the desired concentration (OD). This medium allowed the cells to be motile without allowing growth or replication, so the concentration of the cells remained constant throughout the experiments.

2 μL of the prepared bacterial suspension is injected into a glass chamber (Leja, 10 μm sample), hermetically sealed at both sides with UV glue (Norland Optical Adhesive NOA81). Oxygen is depleted by bacteria in around 30–45 min for OD = 0.5. Once this has happened, the bacteria swim only where there is green light, and their speed increases with the intensity of the light.

### Microscopy and light projection

We use a custom inverted optical microscope in dark field mode, equipped with a 10x magnification objective (Nikon; NA=0.30) and a high-sensitivity CMOS camera (Hamamatsu Orca-Flash 2.8). Light patterns are generated using a digital light processing (DLP) projector (Texas Instruments DLP Lightcrafter 4500) coupled to the same microscope objective used for imaging. Green light from the DLP projector is filtered by a bandpass filter (central wavelength 520 nm) and then coupled to the microscope objective through a dichroic mirror. A long pass filter prevents illumination light to reach the camera, as in ref. ^{9}. The size of a DLP projector pixel imaged on the sample plane is 0.75 μm.

## Data availability

The data that support the findings of this study are available from the corresponding author upon request.

## References

Palacci, J., Sacanna, S., Steinberg, A. P., Pine, D. J. & Chaikin, P. M. Living crystals of light-activated colloidal surfers.

*Science***339**, 936–940 (2013).Buttinoni, I. et al. Dynamical clustering and phase separation in suspensions of self-propelled colloidal particles.

*Phys. Rev. Lett.***110**, 238301 (2013).Kümmel, F. et al. Circular motion of asymmetric self-propelling particles.

*Phys. Rev. Lett.***110**, 198302 (2013).Palacci, J. et al. Light-activated self-propelled colloids.

*Philos. Trans. R. Soc., A***372**, 20130372 (2014).Walter, J. M., Greenfield, D., Bustamante, C. & Liphardt, J. Light-powering

*Escherichia coli*with proteorhodopsin.*PNAS***104**, 2408–2412 (2007).Cates, M. E. & Tailleur, J. Motility-induced phase separation.

*Annu. Rev. Condens. Matter Phys.***6**, 219–244 (2015).Arlt, J., Martinez, V. A., Dawson, A., Pilizota, T. & Poon, W. C. Dynamics-dependent density distribution in active suspensions.

*Nat. Commun.***10**, 1–7 (2019).Arlt, J., Martinez, V. A., Dawson, A., Pilizota, T. & Poon, W. C. K. Painting with light-powered bacteria.

*Nat. Commun***9**, 768 (2018).Frangipane, G. et al. Dynamic density shaping of photokinetic

*E. coli*.*Elife***7**, e36608 (2018).Maggi, C., Angelani, L., Frangipane, G. & Di Leonardo, R. Currents and flux-inversion in photokinetic active particles.

*Soft Matter***14**, 4958–4962 (2018).Lozano, C., ten Hagen, B., Löwen, H. & Bechinger, C. Phototaxis of synthetic microswimmers in optical landscapes.

*Nat. Commun***7**, 12828 (2016).Lozano, C. & Bechinger, C. Diffusing wave paradox of phototactic particles in traveling light pulses.

*Nat. Commun***10**, 2495 (2019).Angelani, L., Costanzo, A. & Leonardo, R. D. Active ratchets.

*EPL***96**, 68002 (2011).Geiseler, A., Hänggi, P., Marchesoni, F., Mulhern, C. & Savel’ev, S. Chemotaxis of artificial microswimmers in active density waves.

*Phys. Rev. E***94**, 012613 (2016).Merlitz, H., Vuijk, H. D., Brader, J., Sharma, A. & Sommer, J.-U. Linear response approach to active brownian particles in time-varying activity fields.

*J. Chem. Phys.***148**, 194116 (2018).Stenhammar, J., Wittkowski, R., Marenduzzo, D. & Cates, M. E. Light-induced self-assembly of active rectification devices.

*Sci. Adv.***2**, e1501850 (2016).Tailleur, J. & Cates, M. E. Sedimentation, trapping, and rectification of dilute bacteria.

*EPL***86**, 60002 (2009).Bricard, A., Caussin, J.-B., Desreumaux, N., Dauchot, O. & Bartolo, D. Emergence of macroscopic directed motion in populations of motile colloids.

*Nature***503**, 95–98 (2013).Koumakis, N., Lepore, A., Maggi, C. & Di Leonardo, R. Targeted delivery of colloids by swimming bacteria.

*Nat. Commun***4**, 2588 (2013).Sokolov, A., Apodaca, M. M., Grzybowski, B. A. & Aranson, I. S. Swimming bacteria power microscopic gears.

*PNAS***107**, 969–974 (2010).Kaiser, A. et al. Transport powered by bacterial turbulence.

*Phys. Rev. Lett.***112**, 158101 (2014).Di Leonardo, R. et al. Bacterial ratchet motors.

*PNAS***107**, 9541–9545 (2010).Angelani, L., Di Leonardo, R. & Ruocco, G. Self-starting micromotors in a bacterial bath.

*Phys. Rev. Lett.***102**, 048104 (2009).Vizsnyiczai, G. et al. Light controlled 3D micromotors powered by bacteria.

*Nat. Commun.***8**, 15974 (2017).López, H. M. et al. Turning bacteria suspensions into superfluids.

*Phys. Rev. Lett.***115**, 028301 (2015).Lavergne, F. A., Wendehenne, H., Bäuerle, T. & Bechinger, C. Group formation and cohesion of active particles with visual perception-dependent motility.

*Science***364**, 70–74 (2019).Battle, C. et al. Broken detailed balance at mesoscopic scales in active biological systems.

*Science***352**, 604–607 (2016).Ginot, F., Theurkauff, I., Detcheverry, F., Ybert, C. & Cottin-Bizonne, C. Aggregation-fragmentation and individual dynamics of active clusters.

*Nat. Commun***9**, 1–9 (2018).Bechinger, C. et al. Active particles in complex and crowded environments.

*Rev. Mod. Phys.***88**, 045006 (2016).Leff, H. & Rex, A. F.Maxwell’s Demon 2. Entropy, Classical and Quantum Information, Computing (CRC Press, 2002).

Berg, H. C.

*E. coli in Motion*(Springer, 2004).Wilson, L. G. et al. Differential dynamic microscopy of bacterial motility.

*Phys. Rev. Lett.***106**, 018101 (2011).Schnitzer, M. J. Theory of continuum random walks and application to chemotaxis.

*Phys. Rev. E***48**, 2553 (1993).Datsenko, K. A. & Wanner, B. L. One-step inactivation of chromosomal genes in

*Escherichia coli*K-12 using PCR products.*Proc. Natl Acad. Sci. USA***97**, 6640–6645 (2000).Tipping, M. J., Steel, B. C., Delalez, N. J., Berry, R. M. & Armitage, J. P. Quantification of flagellar motor stator dynamics through in vivo proton-motive force control.

*Mol. Microbiol.***87**, 338–347 (2013).

## Acknowledgements

The research leading to these results has received funding from the European Research Council under the ERC Grant Agreement No. 834615 (R.D.L.).

## Author information

### Authors and Affiliations

### Contributions

H.M.-C., C.M., G.F. and R.D.L. designed the experiments. H.M.-C. performed experiments and analyzed data. C.M. performed simulations. G.F. was responsible for the strain construction. G.F. and H.M.-C. were responsible for the growth of bacterial strains. H.M.-C., C.M., G.F. and R.D.L. wrote the manuscript.

### Corresponding author

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Peer review

### Peer review information

*Nature Communications* thanks the other anonymous reviewer(s) for their contribution to the peer review of this work. Peer review reports are available.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Massana-Cid, H., Maggi, C., Frangipane, G. *et al.* Rectification and confinement of photokinetic bacteria in an optical feedback loop.
*Nat Commun* **13**, 2740 (2022). https://doi.org/10.1038/s41467-022-30201-1

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41467-022-30201-1

## Comments

By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.