All-optically untangling light propagation through multimode fibres

When light propagates through a complex medium, such as a multimode optical fibre (MMF), the spatial information it carries is scrambled. In this work we experimentally demonstrate an all-optical strategy to unscramble this light again. We first create a digital model capturing the way light has been scattered, and then use this model to inverse-design and build a complementary optical system - which we call an optical inverter - that reverses this scattering process. Our implementation of this concept is based on multi-plane light conversion, and can also be understood as a diffractive artificial neural network or a physical matrix pre-conditioner. We present three design strategies allowing different aspects of device performance to be prioritised. We experimentally demonstrate a prototype optical inverter capable of simultaneously unscrambling up to 30 spatial modes that have propagated through a 1m long MMF, and show how this enables near instantaneous incoherent imaging, without the need for any beam scanning or computational processing. We also demonstrate the reconfigurable nature of this prototype, allowing it to adapt and deliver a new optical transformation if the MMF it is matched to changes configuration. Our work represents a first step towards a new way to see through scattering media. Beyond imaging, this concept may also have applications to the fields of optical communications, optical computing and quantum photonics.

As their name suggests, multimode optical fibres (MMFs) support the transmission of multiple spatial modes, recognisable as unique patterns imprinted in the electric field of guided laser light [1].These spatial modes are capable of acting as independent information channels, offering the tantalising prospect of ultra-high density information and image transmission through hair-thin strands of optical fibre [2,3].Such technology has a wealth of applications, from highresolution micro-endoscopy deep inside the body [4][5][6], to space-division multiplexing through short-range optical interconnects in data centres [7,8], and emerging forms of quantum communication and photonic computing [9][10][11].However, there are significant challenges to overcome before the high data capacity of MMFs can be fully unlocked.
An optical field illuminating one end of a MMF typically emerges from the other end unrecognisably spatially scrambled -a consequence of modal dispersion and cross-talk.This presents a major hurdle to spatial signal transmission and imaging through MMFs, as the light must somehow be unscrambled again to recover images and data [3].A number of techniques to achieve this are currently under development.A widely applicable strategy involves first creating a digital model of the way the fibre scrambles light.This can be accomplished by measuring the fibre's transmission matrix (TM) -a linear operator encapsulating how any spatially coherent optical field will be transformed upon propagation through the MMF [12].Once the TM is known, it links monochromatic fields at either end of the MMF, and so knowledge of the field at one end enables computational recovery of the field at the other end [13,14] -a technique closely related to coherent optical multiple-input multiple-output (MIMO) in the optical communications domain [15,16].
Knowledge of the TM also enables scanning imaging through MMFs to be accomplished [17].This method, known as wavefront shaping [18], uses a spatial light modulator (SLM) to dynamically structure input optical fields so they transform into focused spots after propagation through the fibre [19].By scanning a spot over the scene, and recording the total return signal that has emanated from each of the known spot locations, reflectance or fluorescence images can be reconstructed.Wavefront shaping is a powerful technique that has enabled a wide variety imaging modalities through MMFbased micro-endoscopes [20][21][22][23][24][25][26][27].However, in these methods the spatial information is essentially unscrambled one mode at a time -which severely limits imaging frame-rates, and is not compatible with wide-field or super-resolution imag-ing [28,29] through fibres.
To take full advantage of the parallel information channels supported by MMFs, we would ideally be able to disentangle all propagating spatial modes simultaneously, to a high fidelity, and with minimal computational overhead [30][31][32].In this article, we show how the unscrambling operation can be achieved passively in an all-optical manner, with a latency limited only by the speed of light.Armed with knowledge of a fibre's TM, we design a complementary optical systemcrafted through the process of inverse design -that reverses the scattering process imparted by the MMF.We refer to this device as an optical inverter [33].It brings closer the vision of being able to simply look through an optical fibre to directly see the scene at the other end.
An optical inverter must precisely manipulate many spatial modes simultaneously.Realisation of photonic systems capable of on-demand high-dimensional spatial mode transformation is a challenging task, with techniques still in their infancy [34][35][36].Despite their high resolution, a single reflection from a two-dimensional SLM or metasurface cannot achieve an arbitrary multi-modal transformation -for this the interaction of light with a three-dimensional photonic architecture is required [37].Our concept, shown in Fig. 1, relies on a technology known as multi-plane light conversion [38], and can also be understood as a physically realised diffractive artificial neural network [39].Light emerging from the MMF reflects from a cascade of specially designed diffractive optical elements -here referred to as 'phase planes' (see Fig. 1(b)), each separated by free-space.These static phase planes successively rearrange the spatial information carried by the light, operating on all modes simultaneously, and enacting the inverse transformation to that applied by the fibre itself.After this process, images of input optical fields are formed at the output of the inverter, without the need for any computational processing.
We recently proposed this optical inversion concept, as a way to unscramble light propagation through MMFs, in a numerical study [33].Here we experimentally implement a prototype optical inverter, with its design tuned to a specific MMF supporting up to ∼30 spatial modes.We also demonstrate how this prototype inverter can be adapted to match a new fibre TM if the bend configuration of the MMF is perturbed -pointing towards future applications involving flexible fibres.While our work predominantly targets imaging applications, the concepts we introduce here may also prove fruitful in the fields of optical communications, optical computing and quantum photonics.

Optical inverter design
We design an optical inverter complementary to a short length (1 m) of step-index MMF with a core diameter of d = 25 µm, and numerical aperture NA = 0.1.At a wavelength of λ = 633 nm, this MMF supports N = 42 spatial modes per polarisation channel (given by N ∼ (πdNA/2λ) 2 ).
We demonstrate three inverse design protocols that enable different performance criteria to be optimised.

Eigenmode-based inverter design:
We start by considering how to unscramble light transmitted through an ideal MMF.Under the weakly guiding approximation (i.e.low NA), the MMF eigenmodes are a set of N circularly polarised propagation invariant modes (PIMs) [40].The PIMs maintain an unchanging transverse field profile as they propagate along the fibre, denoted by Ψ n , where n indexes the mode: n ∈ {1, 2, 3, ..., N } -see Fig. 2(a) and Supplementary Information (SI) §4 for examples.Being eigenmodes of the system, the ideal PIMs exhibit negligible mode-dependent loss and modal coupling during propagation.
Each PIM has a mode-dependent propagation constant β -describing the rate at which its global phase shifts as it propagates along the fibre.Consequently, mode n picks up a mode-dependent global phase delay of β n L upon reaching the output of a fibre of length L. This spatial mode dispersion causes the interference pattern cast by a superposition of PIMs to be different at the input and output fibre facets, resulting in the observed spatial scrambling of optical fields.Therefore, in matrix form the TM of an ideal MMF, in a single circularly-handed polarisation state and represented in real-space (pixellated) input and output bases, is wellapproximated by T fib = PDP † .Here P transforms from fibre mode space to real-space, and D is a diagonal unitary matrix encoding the phase delay accumulated by the PIMs along its diagonal.This TM links the arbitrary vectorised input field u to the corresponding output field v via: v = T fib u.
In this ideal case, the task of the optical inverter is to reverse these mode-dependent phase delays: it should enact the transform Ψ n → Ψ n exp(−iβ n L) for all N PIMs simultaneously.Therefore, the TM of the optical inverter is given by T inv = PD † P † .The TM of the combined MMF-inverter system is given by T fib-inv = T inv T fib = PP † , which now represents only the spatial filtering applied to light fields transmitted through a fibre (due to the fibre's limited NA), with spatial scrambling corrected.
The PIMs spatially overlap with one another, so separating them to impart the required mode-dependent phase delay onto each PIM is the key challenge we face in the design of an optical inverter [33].The technique of multi-plane light conversion is emerging as a front-runner to efficiently manipulate tens of arbitrarily shaped spatial light modes simultaneously [37,[41][42][43][44][45][46][47][48].Here we aim to design a multi-plane light converter (MPLC) that has a relatively low number of planes, rendering the design practical to build: we unscramble the N = 42 spatial channels using a cascade of M = 5 phase planes.
The phase profiles of the layered MPLC structure can be efficiently inverse-designed using methods analogous to the back-propagation algorithms used to train layered electronic artificial neural networks [43,49,50].Transforming many spatial modes with only a few phase planes typically means that not all of the input light can be fully controlled.This situation is dependent upon the desired transform asked of the MPLC, but typically occurs if the number of planes M 2N .To overcome this problem, here we employ a bespoke MPLC design algorithm that allows a high degree of tunability in the low-plane number regime.We recently introduced this algorithm for generalised mode sorting [37], and here we apply it to optical inverter design.Our iterative algorithm relies on gradient ascent with an objective function that enables the trade-off between fidelity and efficiency to be adjusted on a mode-by-mode basis -see Methods and ref. [37] for a detailed description.SI §3 shows a comparison of our gradient ascent algorithm to conventional approaches -in particular, the well-known 'wavefront matching method' (WMM) [43,49].These simulations demonstrate that our gradient ascent algorithm gives access to substantially higher fidelity inverter designs in this scenario.
Figure 2(a-b) shows a simulation of the performance of an optical inverter designed using gradient ascent.As can be seen in Fig. 2(a), the target output PIMs are projected into a disk in the output plane, and uncontrolled light is directed around the edge of this disk where it can be discarded or blocked.When the optical inverter is coupled to an MMF, this output disk becomes an image of the field illuminating the input facet of the fibre.The optical inverter will unscramble spatially coherent laser light, or spatially incoherent (or partially coherent) light, within the spectral bandwidth of the combined MMF-inverter system.Figure 2(b) shows simulated examples of spatially incoherent images transmitted through the combined MMFinverter system with high fidelity.The resolution of these images are diffraction limited, governed by the NA of the MMF.
The incoherent imaging capabilities of this system can be understood by considering that light emanating from a diffraction limited point on the input facet of the MMF is re-imaged to a corresponding point at the output of the inverter.Therefore, the operation of the system does not rely on interference between light from neighboring points, meaning there is no requirement for spatial coherence of the input optical field.The bandwidth, ∆λ, is thus limited by the spectral dispersion of the combined system, which for a step-index fibre, is typically constrained by the fibre itself (∆λ fib ).For imaging at the output facet of a step-index fibre, ∆λ fib ∼ 2n c λ 2 /(LNA 2 ).Although relatively narrow, this spectral bandwidth substantially increases if the image plane is moved away from the end of the fibre, as discussed in ref. [33].Therefore, far-field imaging through MMFs [26,27] may be achieved over a broad spectral bandwidth.SI §6 shows simulations of the spectral bandwidth of the optical inverters designed in this work.
Singular value decomposition-based inverter design: Next, we study the design of an optical inverter matched to a real step-index MMF of 1 m in length, nominally with the same core diameter and NA as simulated above (d = 25 ± 3 µm, NA = 0.1).We first experimentally measure the TM of this fibre, T f-exp , at a wavelength of 633 nm, in a single circular input and output polarisation state [12,17].A digital micromirror device (DMD), placed in the Fourier plane of the input facet and acting as a programmable diffraction grating, is used to shape the laser light projected into the fibre [51,52].The TM is measured by scanning a focused spot over a hexagonal grid of points across the input facet, and holographically recording the fields emanating from the output facet.See Methods for experimental details, and SI §1 for a schematic of the full optical set-up.
To represent a realistic use-case, the fibre is held in place in a curved configuration (as shown in SI §2) and so the TM features non-negligible levels of spatial mode and polarisation coupling.Our prototype optical inverter is designed to operate on a single polarisation state, and so we filter out one circular polarisation of light exiting the fibre, rendering the measured TM non-unitary.We note that a polarisation-resolved TM of a short fibre is typically close to unitary [40], and our approaches could be naturally extended to vectorial optical inverters capable of operating on both polarisation states simultaneously [53].
Rather than the eigenvalue decomposition applied above, it is now more appropriate to design the optical inverter by considering the singular value decomposition (SVD) of the fibre TM: T f-exp = UΣV † , where unitary matrices U and V contain the left-hand and right-hand singular vectors, respectively, along their columns, and diagonal matrix Σ contains the singular values along its diagonal.Figure 2(e) shows a plot of the first 100 singular values in descending order.We see the distribution of singular values is dominated by ∼ 30 large values, corresponding to speckle field profiles that approximate linear combinations of ideal PIMS.These speckle patterns transmit the majority of the power through the MMF.This number of high singular values agrees well with the theoretical mode capacity calculated from the fibre geometry when also factoring in the manufacturing tolerance on core radius.We observe a long tail of lower singular values, a phenomenon which we interpret as due to core-cladding modes that are weakly excited by light scattering out of the core.
In this scenario, the inverse transform that our optical inverter must apply can be approximated by the pseudo-inverse of Here we regularise the inverse by setting all but the largest N = 30 singular values to zero.Therefore, we design an MPLC to simultaneously pairwise map the N spatial modes represented by the left-hand singular vectors (held on columns of U) with the largest singular values, to the corresponding N spatial modes defined by the right-hand singular vectors (held on columns of V).As before, when reformatted to a 2D array, these right-hand singular vectors fit into a disk representing an image of the input facet of the fibre formed at the output of the inverter.Examples of these left and right singular vectors are shown in Fig. 2(c) and SI §5, along with simulated outputs from the SVD-based inverter.
As the TM of the MMF is non-unitary, the singular vectors do not have a uniform magnitude.In this situation an ideal inverter would somehow boost the power in the singular vectors with lower singular values to compensate for this effect -a feature that at first sight appears incompatible with a passive linear optical system.However, given a low-plane MPLC is inherently lossy, and we have independent control over the transform efficiency of each singular vector, our algorithm can, within limits, be used to re-balance these mode dependent losses by boosting the transform efficiency of certain modes -see Methods.
Figure 2(d) shows the simulated performance of this SVD-based optical inverter design, when matched to the experimentally measured fibre TM.In this case the fidelity of imaging is slightly reduced -in particular on the left-handside of the field-of-view (FoV).This is due to the non-unitary nature of the single-polarisation channel TM.In particular, some of the light transmitted from the left-hand-side of the input facet is transformed into the polarisation channel, or into singular vectors that are filtered out.Characterising and inverting both polarisation channels simultaneously could overcome this loss of information [53].
Optical inversion via speckle mode sorting: So far we have designed optical inverters capable of reconstructing images of arbitrary continuous fields incident anywhere on the input fibre facet.However, in the more realistic non-unitary case this gives us no direct control over the spatial variation in reconstruction fidelity.In our final strategy, we investigate an inversion method that allows us to arbitrarily specify the regions of the fibre facet that we wish to reconstruct with high fidelity.
Our measured fibre TM T f-exp maps a set of input focused spots to the corresponding speckle patterns emerging from the other end of the fibre.We now design an MPLC to perform the inverse mapping, and directly transform these speckle patterns back into focused spots.In this design protocol, we can arbitrarily specify the number and position of diffraction limited spots at the input facet which are unscrambled and re-imaged to the output of the inverter.For example, we are able to lower the number of channels to fewer than the maximum supported by the fibre, which allows a smaller set of channels to be unscrambled with higher fidelity.
If the input channels (i.e.focused spots) are not spatially overlapping, then the performance of this 'speckle mode sorter' can be quantified by a cross-talk matrix, which depicts the fraction of light input into channel index i at the MMF input facet that appears in output channel index j after the inverter (see Methods).Figure 3(b) shows the numerically simulated cross-talk matrix of a speckle sorter-based inverter designed to operate on 19 spatially separated channels using 5 phase planes.Here we limit the design to an experimentally achievable resolution to compare with the experiments detailed below.In this case we design the speckle mode sorter by optimising the correlation between the target and actual output modes, which is equivalent to the WMM.SI Movie 1 shows a simulation of the spatial transformation undergone by input speckle fields as they propagate through the phase planes of a speckle mode-sorter inverter design.We note that our tunable inverse design algorithm can be used to substantially suppress cross-talk in future high-resolution speckle mode sorter designs [37].

Experimental realisation
We now experimentally implement a prototype optical inverter matched to the 1 m long MMF characterised earlier.
Figure 1 shows a simplified schematic of our experiment, and SI §1 shows the full experimental setup.Our inverter is constructed from an MPLC with 5 reflections from a liquid crystal SLM.The phase planes are designed using knowledge of the experimentally measured fibre TM T f-exp .The output fibre facet is magnified and imaged onto the first phase plane of the MPLC.When processing tens of spatial light modes, the complexity of the required phase profiles means that pixel-perfect alignment of each phase plane is critical.This is demanding to achieve given the numerous alignment degrees-of-freedom (as discussed in detail in ref. [37]).To mitigate alignment difficulties, we create a range of MPLC designs incorporating the expected span of residual experimental errors in the scaling and defocus of the input fields, and distance between planes, and implement an auto-alignment protocol based on a genetic algorithm that simultaneously optimizes the choice of phaseplane set and the lateral position of each phase plane on the SLM.Once the fibre is secured in position on an optical table, and the MPLC is aligned, we find the system is stable for days at a time.
Experimentally, the resolution of the SLM limits us to relatively low resolution MPLC designs, which best suit the speckle-sorter based optical inverter, since the SVD-based design requires much higher resolution phase patterns [37].We first test the performance of the inverter to unscramble 19 channels evenly distributed over a hexagonal grid across the input facet of the fibre.Figure 3(a) shows two examples of input spots transformed into speckle patterns via propagation through the MMF, and then back into focused spots by the optical inverter.Our experimentally realised device compares well with simulations.Figures 3(b-c) show a comparison of the simulated and experimentally measured cross-talk matrices in this case.The slightly higher system cross-talk levels observed experimentally are mainly due to the effects of coupling between adjacent SLM pixels (i.e. the phase setting of one pixel affects the phase of neighbouring pixels), which may be mitigated by using higher-resolution or multiple SLMs to display the required phase profiles with greater accuracy.SI Movies 2 and 3 show the inverter outputs as all input channels are sequentially excited, for a 19-mode and 30-mode inverter.
All-optical image transmission through MMFs: Figure 3(de) demonstrates all-optical incoherent image transmission through the MMF-inverter system.We design and implement optical inverters supporting both 19 channels (Fig. 3(d)) and 30 channels (Fig. 3(e)).In these experiments, we mimic the effect of incoherent light transmitted through the system by illuminating each excited channel sequentially with the DMD, and time-averaging the intensity images at the output of the inverter -this captures the level of cross-talk expected for the transmission of incoherent light within the spectral bandwidth of the system.We transmit a variety of simple pixellated binary images of numbers, letters, smiley faces and symbols, and observe that all images are recognisable without the need for any additional processing at the output of the inverter.The contrast of the transmitted images reduces as their sparsity decreases (i.e. as more channels are simultaneously excited)as is expected from the additive effects of incoherent channel cross-talk.Imaging contrast also reduces when the number of channels is increased from 19 to 30, due to the additional load placed on the MPLC-based speckle sorter to simultaneously sort more modes in 5 phase planes.

Adaptive optical inversion:
As with all approaches that rely on knowledge of the TM of a scattering medium, our inversion strategy will fail if the fibre configuration changes enough to significantly modify the TM.The transmission properties of optical fibres are notoriously sensitive to such perturbations.Therefore, if changes are anticipated, the fibre TM should be regularly re-estimated (which can be achieved with only a few probe measurements [54]) and the MPLC patterns updated when needed.We explore this scenario in Fig. 4. Starting from an aligned MMF-inverter system (Fig. 4, left-hand column), we deliberately change the fibre configuration by re-routing one of its bends (see SI §2 for details).This almost entirely disrupts the unscrambling operation, as seen by the disappearance of the prominent diagonal in the cross-talk matrices shown in Fig. 4, middle column.Performance is restored by remeasuring the TM of the MMF, and re-configuring the phase-planes of the optical inverter to match the new TM, as shown in Fig. 4, right column.
We note that in micro-endoscopy applications, the input end of the fibre may not be optically accessible -thus complicating continuous TM monitoring of flexible MMFs.Nonetheless, there are a variety of methods under development to achieve single-ended TM measurement in this scenario [6,[55][56][57].Even once a new TM is known, in future adaptive applications it will be important to minimise the computational complexity associated with re-designing an entire optical inverter on-the-fly whenever the fibre state changes.To address this issue, we showed in ref. [33] that modulating only a single, carefully chosen phase plane can correct for a wide range of fibre states.Furthermore, selecting from a pre-designed library of inverters, matched to the range of expected fibre TMs, would bypass the need for any synchronous inverter design [6], offering a viable route towards adaptive inversion operating at liquid crystal SLM update rates in the future.

Discussion
We now consider our work in the context of other emerging techniques and give an outlook towards future directions.An MPLC is equivalent to the more recently coined diffractive artificial neural network (DNN) [39] -the two concepts share the same physical structure, and are inverse designed using analogous approaches.DNNs have recently begun to be applied to computational imaging operations [58,59].Viewed from the perspective of artificial neural networks, an ideal MMF optical inverter is capable of reconstructing any transmittable image after being 'trained' (i.e.inverse-designed) on a minimal yet complete set of fibre responses.This minimises the training time, and prevents any undesired bias towards particular classes of image being frozen into the final network design.
More crucially, the all-optical nature of our physicallyrealised network conserves the phase and coherence informa-tion carried by optical fields flowing through it.This responsiveness to the optical phase renders the inversion problem linear and well-posed, offering advantages over conventional neural networks tasked with this class of light unscrambling problem.For example, electronic neural networks have been applied to unscramble coherent images transmitted through MMFs [60,61].When trained on intensity-only images cast by spatially coherent light, these methods are faced with a non-linear mapping problem that is highly ill-posed, as many different inputs can result in the same intensity profile at the output of the fiber, differing only by their phase information [4].That said, conventional neural networks currently offer additional flexibility in terms of accommodating perturbations to fibre state [62,63].
Single-shot incoherent computational imaging directly through MMFs has also been previously explored.This technique relies on measurement of the 'intensity TM', M, which links incoherent optical fields at either end of a fibre [33,64].Measurement of the intensity pattern of a spatially incoherent field at one end of the fibre, a, then permits the intensity pattern at the other end, b, to be computed by solving the inverse problem Mb = a for b.However, in this approach, the spatial information is encoded in low contrast speckle patterns such as those shown in Fig. 3(c,d) (top rows).This means that matrix M is poorly conditioned, and the solution to the inverse problem is very sensitive to small changes in a.For example, we see that in Fig 3(d) (top row), the speckle patterns emanating from the fibre look very similar when transmitting images of '2', '3' and '8' -making accurate computational reconstruction of these images sensitive to noise.Therefore, this direct inversion technique is hampered by very low signalto-noise ratios, and typically works best when imaging sparse scenes [65].
An ideal inverter physically solves this incoherent imaging inverse problem without the need for any further computation.However, even an imperfect inverter, possessing nonnegligible levels of channel cross-talk (such as our 30-channel prototype), has advantages here: it represents a physical preconditioning element, thus reducing the condition number (i.e. the ratio of the largest to the smallest singular value) of the intensity TM describing the optical system.This improves the stability of final computational image reconstruction.For example, in our experiments the inclusion of the inverter lowered the condition number κ of matrix M from κ = 14.1 (MMF alone) to κ = 5.5 (MMF-inverter) in the 30-channel case, and from κ = 8.8 to κ = 3.1 in the 19-channel case (see Methods).We anticipate the benefits of physically pre-conditioning in this way will grow with the dimensionality of the system.
How scalable is our concept in terms of the length and mode capacity of the fibre?The main challenge presented by longer fibres is the stability of their TM, which becomes increasingly susceptible to external perturbations (e.g.changes in temperature, or vibrations).Therefore long fibres would necessitate low latency adaptive optical inversion.Regarding mode capacity: in this work we experimentally unscramble up to 30 modes using 5 phase planes, i.e. a mode-to-plane ratio of 6, with an efficiency of ∼ 20% (ignoring SLM losses).SI §7 provides a table of performance metrics for all of the inverters designed in this work.In the general case of arbitrary unitary transformations, to unscramble light with high fidelity and efficiency, the number of planes scales linearly with the number of modes [66].However, this scaling can be improved by sacrificing transform efficiency while preserving fidelity [37].Interestingly, certain transformations can be efficiently achieved with a far more favorable mode-to-plane scaling [43,67].We recently showed that the transformation required to sort MMF PIMs falls into this category [33].In ref. [33] we constrained the inverter design to take advantage of the efficient PIM sorting transform, and established that, in theory, up to 400 modes could be unscrambled in 29 planes with an efficiency of ∼ 50%.This improves the mode-to-plane ratio to ∼14.Experimentally realising such a high-dimensional system is a promising avenue for future work.

Conclusions
In summary, we have demonstrated a passive optical system capable of reversing the strongly spatially-variant aberrations introduced by a MMF -unscrambling tens of optical modes simultaneously.Our approach can be understood as a form of all-optical MIMO equilisation [32].Proposals to optically unscramble light propagation through MMFs were first suggested in the 1970s [68].However, it is only in the last few years that our understanding of the inverse design of multimodal photonic systems has matured to a level that renders such concepts experimentally feasible.In addition to the stepindex MMFs studied here, these approaches apply to gradedindex fibres, fibre bundles and photonic lanterns [69,70].Our work targets micro-endoscopic imaging applications, however these concepts apply more broadly to general scattering media [71], and also have potential applications in the fields of classical and quantum optical communications and photonic computing.

Optical inverter inverse design algorithm
Our aim is to find the phase delay imparted by each pixel on each plane of the optical inverter, such that the resulting optical transformation is close to the desired inverter transmission matrix T inv .For each design strategy, we specify different target sets of input and output modes -essentially selecting the preferred basis in which the inverter design will be conducted: • For the ideal Eigenmode-based inverter design, the input mode set is the PIMs -see, for example, refs [40] or [57] for details of how these modes are defined, and SI §4 for visualisations.The output set is also the PIMs, with the global phase shift of the n th mode given by θ n = −β n L, to compensate for the phase delay picked up during propagation through a fibre of length L.
• For the SVD-based inverter, we express the measured TM as T f-exp = UΣV † , as explained in the main text.
The inverter input modes are the left-hand singular vectors held on the columns of U, and the output modes are the right-hand singular vectors held on the columns of V -appropriately truncated.
• For the speckle mode sorter, the input modes are userselected columns of T f-exp -i.e.experimentally measured speckle patterns emanating from the fibre during the measurement of the TM.The output modes are the corresponding focused points that were focused onto the input of the fibre to probe the fibre TM.
During the design process, we aim to optimise a metric that quantifies the performance of the MPLC to transform all input modes to their corresponding output modes -taking into account both the transform fidelity and efficiency of each mode pair.To achieve this, we use the efficient MPLC design method we recently introduced in ref. [37], and choose the optimisation objective function as follows Here F T is the real-valued number we aim to maximise during optimisation.N is the total number of mode-pairs to transform.The real positive number α n weights the relative importance of transforming mode pair n.
F n is a real-valued number quantifying the performance of the transformation for input-output mode-pair n.The interplay between the two contributions to F n can be understood as follows: The first term on the right-hand-side (RHS) of Eqn. 2 is designed to maximise the correlation between the target output mode ρ n , and the actual output mode v n .Taking the real part of the overlap constrains the global phase of the output to match the global phase of the target (alternatively, taking the absolute square of this term leaves the relative global phase of the output modes unconstrained [37,50]).
The second term on the RHS of Eqn. 2, weighted by positive scalar γ n , enables the efficiency of the transformation to be tuned.A non-zero value of γ n allows some of the transmitted light to be deliberately shepherded into a designated background region outside the image of the input fibre facet.This lowers the overall efficiency, but enables optical inverter designs to be found that yield a higher output fidelity within the image of the fibre facet itself.The background region is defined using vector h bk : the elements of h bk are set to zero inside the image of the fibre core where the unscrambled field will appear, and 1 in the surrounding area, which is designated as the background zone.We incorporate this information into Eqn. 2 via v bk n = v n h bk , where the operation signifies the element-wise Hadamard product.Therefore v † n • v bk n represents the intensity of light directed to the background zone (and is thus always real and positive).Adding this efficiency term in Eqn. 2 acts to increase F n when more light is scattered to the background.We note that the spatial structure of v n in the background zone is free to evolve throughout the iterative design process, so this approach does not enforce any predetermined structure on the light scattered there.
Within Eqn. 2, when the efficiency term increases, the fidelity term simultaneously decreases, since here the calculation of fidelity involves the overlap integral between the target and actual mode across the entire output plane.Thus, this formulation allows the relative importance of fidelity and efficiency to be tuned on a mode-by-mode basis by the adjusting the values of γ n .In addition, the relative importance of each input-output mode-pair can be adjusted by tuning α n .The combination of these two adjustable controls enables the efficiency of certain mode-pair transformations to be boostedthus correcting, to some extent, for the non-uniform singular value distribution of the inverse TM that should be implemented in the SVD-based optical inverter design.
For the eigenmode-based and SVD-based inverter designs we use non-zero values of α n and γ n , that are initialised as α n = 1 and γ n = 2, while γ n is adjusted throughout the design process to compensate for the variation in transformation weights governed by the diagonal elements of Σ.For the speckle mode sorter designs, we use α n = 1 and γ n = 0.In this case, the algorithm optimises the same objective as the well-known wavefront matching method [43,49].If higher resolution phase masks are possible to implement, the crosstalk between the speckle sorter channels can be substantially suppressed by adding an additional term to the objective function, as shown in ref. [37].
Equation 2 is readily differentiable with respect to the phase profile on a particular plane, meaning that the objective function can be efficiently maximised using gradient-based adjoint methods [37].

Optical inverter performance metrics
The performance of a particular optical inverter design can be quantified in several ways, described in detail in the supplementary information of ref. [37], and summarised below: Efficiency: The efficiency e n of the transformation of mode n is given by fraction of input power transmitted into the target zone at the inverter output.For the case of the Eigenmode and SVD-based inverters, this output zone is the disk representing the image of the fibre input facet.For the speckle mode sorter inverter design, the output zone is a small disk located where the output Gaussian should be focused to.The mean efficiency e is given by the average of e n over all N modes.Fidelity: The fidelity f n of the transformation of mode n is given by the absolute square of the normalised overlap integral between the target spatial mode, and the actual spatial mode that is transmitted into the target output zone (i.e.setting any part of the actual field outside the target zone to zero before normalisation takes place).The mean fidelity f is given by the average of f n over all N modes.Channel cross-talk: For the speckle mode sorter-based inverter, if the output channels do not spatially overlap, we can quantify the level of channel cross-talk.This information is stored in a matrix c, where element c i,j is given by the amount of power appearing in output channel j, when input channel i is excited, divided by the total power appearing in all output channels.In the ideal case of no channel cross-talk, c i,i = 1 for all i, and c i,j = 0 for all i = j, meaning that c is equal to the identity matrix.The mean cross-talk is given by c, which is equal to one minus the mean value of the diagonal elements of c (represented as a percentage in the main text) i.e. c = 0 % in the ideal case.

Fibre transmission matrix characterisation
Our experimental set-up for measurement of the TM of the MMF is similar to that described in ref. [54].The MMF used in our experiments is a 1 m long step-index MMF with a nominal core diameter of d = 25 µm, and numerical aperture NA = 0.1 (Thorlabs FG025LJA).A 633 nm laser beam, generated by a 1 mW HeNe laser, (Thorlabs HNLS008L-EC), is expanded to fill a DMD (Vialux-7001), which is used to shape the light incident on the input end of the fibre [51,52].The input facet of the fibre is placed in the Fourier plane of the DMD.The incident light is circularly polarised.Light is focused into, and collected from, the MMF using a pair of 10× objective lenses.The output facet of the fibre is imaged onto a camera that is electronically synchronised with the DMD.A combination of a quarter wave-plate and a polariser filter out one component of circular polarisation.A coherent reference beam (plane wave) is also incident onto the camera, enabling measurement of the optical field via digital holography.
We measure the TM T f-exp of this fibre by scanning a focused spot over a hexagonal grid across the input facet.Each of these inputs results in a unique speckle pattern emerging from the output fibre facet.Each output field is vectorised and the p th output forms column p to the TM T f-exp .We implement phase-drift correction to compensate for any phase drift between the signal and reference arms of the interferometer.This is achieved by interlacing the probe measurements with a standard measurement.The global phase drift of this standard output mode is tracked throughout the TM measurement, and the phase drift function subtracted from the phase of the final TM measurement.SI §1 shows a detailed schematic of the optical set-up.

Experimental implementation of optical inverter
Once designed, we implement the optical inverter using five reflections from a liquid crystal SLM (Hamamatsu X13138-01), of total resolution 1280×1024 pixels and a pixel pitch of 12.5 µm.The SLM is placed opposite a mirror, positioned a distance of 31 mm away from the SLM chip, giving a distance between the phase planes of 62 mm.Each phase plane is first optimised using a 400×400 pixel simulation.The active area of each plane, where the light from each mode mainly stays, is a central 200×200 pixel region.In order to fit the 5 phase planes adjacently on a single SLM, we crop each pre-designed phase plane to a 200×400 pixel area, which are displayed next to one another on the SLM.Initial experimental alignment of this optical system is challenging, as pixel-perfect lateral positioning of the phase planes is required, leading to a large number of degrees of freedom to align simultaneously.We achieved this by implementing an automated genetic algorithm to search for the correct phase plane display positions on the SLM.See ref. [37] for a detailed description.The output of the inverter is recorded with a camera (Basler ace acA640-300gm), positioned in the Fourier plane of the final phase plane.The operation of this camera is electronically synchronised with the DMD.
We note that the SLM used for this work did not have its reflection efficiency optimised specifically for the operating wavelength of 633 nm.Therefore the efficiency of each reflection was relatively low (∼50 %), thus rendering the efficiency of the optical inverter artificially low in our prototype device.This issue could be improved by using an SLM with a dielectric back-plane optimised for the operational wavelength.

Condition number of the intensity transmission matrix
In the main text we analyse the condition number κ of the intensity TM M of just the MMF (M MMF ), and of the MMFinverter system (M MMF-inv ).In general, the intensity TM of a scattering system is given by M = |T| 2 , where T is the field TM when represented in real-space input and output bases, and here we take the element-by-element (i.e.Hadamard) square.Therefore, the n th column of M MMF is given by the vectorised intensity speckle pattern that appears at the output facet of the MMF, when the MMF is excited with the n th input focused spot on the input facet.Similarly, the n th column of M MMF-inv is given by the vectorised intensity pattern that appears at the output of the inverter when the MMF is excited with the n th input focused spot incident onto the input facet.The condition number κ of these matrices is then calculated by finding the singular value decomposition of M, and calculating the ratio of the largest singular value divided by the smallest singular value.
Figure 5 presents a schematic of the optical setup used for implementing the experimental all-optical MMF inverter.A heliumneon laser (Thorlabs HNLS008L-EC) was used as a source of linearly polarised light.After the beam is magnified using a 4-f system of two lenses, a DMD (Vialux V-7001) is used to generate, in its Fourier plane, inputs to the MMF.Camera "Cam 1" is positioned in the image plane of the fibre input facet (i.e. the Fourier plane of the DMD), enabling the intensity profiles of the fields incident on the input of the MMF to be imaged.Prior to entering the fibre, the light passes through a quarter wave-plate to change the polarisation of the incoming light from linear to circular.The optical field generated in the Fourier plane of the DMD is demagnified to the scale of the fibre core using a 4-f system (lens L4 and objective lens OL1).Circularly polarised light on the output of the MMF is converted back to the linear orientation, one component of which is discarded using a polarising beam-splitter.The light emanating from the output facet of the fibre is re-imaged into the plane of the camera "Cam 2", where its intensity can be directly measured.The optical phase of the transmitted fields is retrieved by interfering them with the reference beam and then using off-axis digital holography.The MMF output fields are also re-imaged onto the first plane of the MPLCbased optical inverter.The MPLC is constructed from a liquid crystal SLM (Hamamatsu X13138-01) and a mirror parallel to its screen.After the light is modulated by M = 5 planes of the MPLC, it is Fourier transformed by a lens and any unmodulated light is discarded with a linear polariser.FIG. 5. Schematic of the optical setup used in the experiment.L -lens, M -mirror, BS -beam splitter, PBS -polarising beam splitter, Cam -camera, LP -linear polariser, OL -objective lens, DMD -digital micromirror device, MMF -multimode fibre, LC SLM -liquid crystal spatial light modulator, λ 2 and λ 4 -half-wave and quarter-wave plates respectively.§2: Adaptive correction of the optical inverter: MMF bend configurations Figure 6 shows the MMF configurations before (a) and after (b) an additional bending has been applied to it.The fibre itself in the presented pictures has an orange jacket and is taped to the optical table to ensure the stability of its TM.The bending configuration states of the fibre correspond to the measurements shown in Fig. 4 for the 'aligned' and the 'perturbed' cases respectively.FIG. 6. MMF configuration.Photographs of the experimental configuration of the multimode fibre (orange jacket) before (a) and after (b) additional bending has been applied to it.§3: Comparison of our gradient ascent algorithm to the wavefront matching method for optical inverter design Figure 7 compares the simulated performance of two phase mask optimisation techniques that may be used: our gradient ascent algorithm (GA) and the conventional wavefront matching method (WMM).Both algorithms are tasked with designing a 42-mode eigenmode-based optical inverter using 5 phase planes.The quality of two selected output modes are shown, and visually we see the fidelity of the outputs modes from the inverter designed using the WMM is substantially lower than those generated by our GA algorithm.Quantitatively, the fidelity of the first spatial mode (top row) is f GA n=10 = 98%, versus f WMM n=10 = 58%.For the second example (bottom row), f GA n=14 = 97%, and f WMM n=14 = 40%.The overall fidelity of the transformation averaged over all the modes of a set for GA is f GA = 97% and for WMM is f WMM = 49%, while the simulated average efficiencies (i.e.input light utilisation ratios) are e GA = 13%, e WMM = 30% (See also Table I).Example simulated images using the GA-optimsed inverter and the WMM-optimised inverter are shown on the right hand side of Fig. 7. FIG. 7. WMM vs. GA inverse design.Selected output eigenmodes n = 10 and n = 14 of the visualised alongside the outputs of a system optimised using the wavefront matching method.Examples of the incoherent imaging using the GA-and WMM-optimised inverters are shown as two columns on the right.§4: Eigenmode-based optical inverter: transformation of all eigenmodes Figure 8 presents the set of all N = 42 spatial mode-pairs used to design the eigenmode-based optical inverter matched to an ideal MMF.The MMF eigenmodes accumulate a mode-dependant phase delay β n L as they propagate through the fibre.The multi-plane light conversion system used as the inverter is then designed to act on all N = 42 output modes simultaneously to compensate for these global phase delays with M = 5 planes.The fourth row of each mode block of the presented fields demonstrates the spatial modes generated on the output of such an inverter system optimised using our gradient ascent algorithm (α = 1, γ = 2).The region of the output plane in which light is allowed to be randomly scattered, in order to enhance output fidelity within the central disk area, can be clearly seen in the outputs.The multiplane light conversion system used as the inverter is then designed to act on all N = 30 modes simultaneously, to transform left-hand singular vectors back into the right-hand ones with M = 5 planes.The fourth row of each block of the presented fields demonstrates the spatial modes on the output of such an inverter system optimised using our gradient ascent algorithm (α = 1, γ = 2).Once again, the area of the output plane in which light is allowed to be randomly scattered in order to enhance output fidelity within the central disk area, can be clearly seen in the outputs.Spectral response curves of the simulated optical inverter based on the SVD approach that inverts the transmission matrix of the experimentally measured fibre are shown in Figure 10.These are numerically calculated as follows.First, a set of MPLC M = 5 phase masks corresponding to the needed transformation is optimised using the gradient ascent algorithm with the base values of α = 1, γ = 2 at the original wavelength λ 0 = 633 nm.After this, the wavelength of the input to the MPLC light is detuned (λ det ) and the phase delays introduced by the phase masks are modified accordingly by multiplication by a factor λ 0 /λ det .After this, the performance of such a mode transformer can be quantified by simulating the propagation of the frequency shifted modes through the device, and calculating the average fidelity and the average efficiency parameters defined in the Methods section of the main text.The spectral bandwidth of the inverter can then be calculated as the full width half maximum (FWHM) of the average fidelity curve shown in Fig. 10(a).As the minimum level of the average fidelity corresponding to the satisfactory inversion quality is not strictly defined, the spectral bandwidth of such a system may be estimated as ∆λ = 5 − 10 nm.However note that, according to the main text of the paper, the bandwidth of the whole MMF-inverter system is rather limited by the bandwidth of the MMF itself in this case.
Figure 11 presents the simulated spectral response curves of the experimentally realised MMF inverters using the N = 19 (blue) and N = 30 speckle mode sorters (green).The average cross-talk and the average efficiency as functions of the detuned wavelength are calculated in the same way as described above for the central wavelength of λ 0 = 633 nm.We observe a broader FWHM, if compared to Fig. 10.This is due to the fact that the phase masks of these systems were optimised using the WMM, which is equivalent to the gradient ascent optimisation with α = 1, γ = 0.This objective function produces less intricate phase masks containing fewer phase wraps thus boosting the spectral bandwidth of the device.The phase masks used were also additionally smoothed to be faithfully represented by the LC SLM screen at the expense of the overall performance [37].

FIG. 1 .
FIG. 1. Optical inversion concept.(a) Light emanating from a scene propagates through an MMF, which spatially scrambles the optical field.The light subsequently propagates through an optical inverter, which performs a passive unscrambling operation.Thus, an image of the scene at the fibre input is reconstructed at the inverter output.The optical inverter consists of a cascade of diffractive optical elements that are inverse-designed to match the transmission properties of the MMF.(b) An example of the phase profiles of a 5-plane optical inverter implemented experimentally.

FIG. 2 .
FIG. 2. Simulations of optical inverter performance (a,b) Eigenmode-based inverter coupled to an ideal fibre (unscrambling 42 modes using 5 phase planes of resolution 700×700 pixels).(a) Two examples (simulations) of PIMs imparted a global phase-shift by the inverter.Left column: input PIMs.Middle column: target phase-shifted output PIMs.Right column: simulated output from MPLC inverter.The target output modes are projected into a disk (black hatched circle) with a mean fidelity of f = 97 % and efficiency of e = 12 % (see Methods for definitions) and uncontrolled light is scattered outside this disk.See SI §4 for a visualisation of the transformation of all eigenmodes.(b) Examples (simulations) of incoherent images transmitted through the ideal MMF-inverter system.Upper row: Incoherent fields incident on MMF input facet.Lower row: Corresponding incoherent fields re-imaged at the output of eigenmode-based inverter.(c-e) SVD-based inverter coupled to a realistic fibre (unscrambling 30 modes using 5 planes of resolution 700×700 pixels).The fibre TM was measured experimentally.(c) Two examples (simulations) of left-hand singular vectors un transformed into corresponding right-hand singular vectors vn by the inverter.Left column: input left-hand singular vectors.Middle column: target output right-hand singular vectors.Right column: simulated output from MPLC inverter.See SI §5 for a visualisation of the transformation of all modes.(d) Incoherent fields re-imaged at the output of the SVD-based inverter (simulations).(e) Singular value distribution of the experimentally measured fibre TM (top 100 singular values shown).Vertical line shows the SVD-inverter design cut-off value at N = 30.

FIG. 3 .
FIG. 3. Experimental all-optical MMF inversion.(a) Operation of a 19-channel inverter, formed from 5 phase planes with a resolution 200×200 pixels (examples of optimised phase profiles shown in Fig. 1(b)).Left-hand column: Two examples of focused spots illuminating the input fibre facet, intensity shown.The locations of the 19 input channels within the core are shown with green circles.Second column from left: the resulting speckle patterns generated at the MMF output, experimentally measured optical fields shown.Third column: simulated inverter output, intensity shown.Right-hand column: experimentally measured inverter output, intensity shown.(b) Simulated channel crosstalk matrix for the 19-channel inverter design.Mean cross-talk is c ∼ 24 %, and mean efficiency is e ∼ 27 % (see Methods for definitions).(c) Experimentally measured channel cross-talk matrix for the 19-channel inverter design.Mean cross-talk is c ∼ 34 %.(d) Incoherent images transmitted through the prototype 19-channel fibre-inverter system.In each case, a subset of the input channels are excited as shown in the insets (top right of each panel).Upper row: scrambled intensity pattern at output fibre facet.Lower row: intensity at inverter output.(e) Incoherent images transmitted through a 30-channel fibre-inverter system.

FIG. 4 .
FIG. 4. Adaptive optical inversion.(a) Cross-talk matrices of a 19-channel MMF-inverter system.Left-hand column: initial aligned state.Middle column: after fibre perturbation, with inverter still set to initial state.Right column: inverter adapted to new fibre state.(b) Equivalent plots to (a), but for a 30-channel inverter.The average cross-talk values, from left to right, for (a) are c ∼ 34 %, 86 % and 33 % respectively, and for (b) c ∼ 49 %, 91 % and 48%.

FIG. 8 .
FIG. 8. Visualisation of fields propagating through eigenmode-based optical inverter.Sets of the N = 42 PIMs used to design the eigenmode-based optical inverter.

Figure 9
Figure9presents sets of all N = 30 spatial mode-pairs used to optimse the SVD-based optical inverter, designed to matched to a real MMF.The mode sets are derived from the experimentally measured TM of a MMF.The MMF inputs in the form of N right-hand singular vectors are transformed into N left-hand singular vectors as they propagate through the fibre.The multiplane light conversion system used as the inverter is then designed to act on all N = 30 modes simultaneously, to transform left-hand singular vectors back into the right-hand ones with M = 5 planes.The fourth row of each block of the presented fields demonstrates the spatial modes on the output of such an inverter system optimised using our gradient ascent algorithm (α = 1, γ = 2).Once again, the area of the output plane in which light is allowed to be randomly scattered in order to enhance output fidelity within the central disk area, can be clearly seen in the outputs.

FIG. 9 .
FIG. 9. Visualisation of fields propagating through SVD-based optical inverter.Sets of N = 30 optical fields used to design the SVDbased optical inverter, derived from the experimentally measured TM of a multimode fibre.

FIG. 10 .
FIG. 10.Simulated spectral bandwidth of the 30-mode SVD-based optical inverter.The average fidelity (a) and the average efficiency (b) of such a system are plotted as functions of the detuned wavelength.

FIG. 11 .
FIG. 11.Simulated spectral response of the MPLC system designed to experimentally operate on N = 19 (blue) and N = 30 modes (green) using M = 5 phase planes in order to invert the scrambling introduced by the fibre.The average cross-talk (a) and the average efficiency (b) of such systems are plotted as functions of the detuned wavelength.

TABLE I .
§7: Summary of optical inverter performance metricsInverter designNo. of modes No. of planes Efficiency (%) Fidelity (%) Cross-talk (%) Performance metric summary for all simulated and experimentally implemented optical inverter designs.§8: Description of supplementary movies • Supplementary movie 1: A simulation of the spatial transformation undergone by input speckle fields as they propagate through the phase planes of a speckle mode-sorter inverter design.• Supplementary movie 2: The 19-mode experimentally implemented optical inverter outputs as all input channels are sequentially excited.Left panel: Intensity of field input into MMF.Middle panel: Experimentally measured optical field at output of MMF.RIght panel: Intensity of field at output of optical inverter.• Supplementary movie 3: The 30-mode experimentally implemented optical inverter outputs as all input channels are sequentially excited.Left panel: Intensity of field input into MMF.Middle panel: Experimentally measured optical field at output of MMF.RIght panel: Intensity of field at output of optical inverter.