Introduction

In conventional techniques used to determine biomolecular structure such as X-ray crystallography, nuclear magnetic resonance (NMR) spectroscopy or free electron laser femtosecond serial crystallography, large numbers of the target molecule are required to obtain sufficient signal. To obtain structural information at the single-molecule level, as close to in situ as possible, one requires a true molecular microscope. In this quest, the tantalising prospect of using quantum spin probes for the detection of nuclear spins in molecules has been a key driver of much of the research in quantum sensing using the nitrogen-vacancy (NV) centre in diamond1,2, with recent experimental demonstrations of internal and external nuclear spin detection under ambient conditions3,4,5,6,7,8,9,10,11,12,13. These breakthroughs have spurred a number of theoretical proposals for molecular level NMR, including methods for molecular detection based on intrinsic nuclear flipping rates14, Rabi driving induced resonant detection15, 1-D NMR spectroscopy16 and amplified long-range sensing of nuclear spins17. Of particular note are proposals heading towards molecular structure determination based on 2-D NMR-related spectroscopy18,19,20, and magnetic tip induced field gradient imaging21. Recently, a technique to use a NV-centre probe together with a Hamiltonian interrogation protocol has been proposed for nuclear localisation of individual spin labels based on the determination of their full hyperfine tensor in the weak field regime22. However, it is not clear whether these techniques can achieve structure determination with angstrom-level resolution for real-world size biomolecules required for biological applications. Highly stable external gradient fields, that are significantly stronger than presentably achievable, are required to sufficiency surpass the 70 G nm−1 threshold where gradient splitting becomes equal to the typical nuclear dipole–dipole coupling. While 2D NMR techniques may suffer from the same limitations of their ensemble counterparts in terms of the maximum molecule size for which the complex frequency spectra inversion can be carried out23,24,25,26,27.

In this paper, we present a method based on a quantum spin probe which acts as a self contained three-dimensional (3D) nanoscale magnetic resonance imaging system enabling microscopy and structure determination at the single molecule level. Rather than rely on large external field gradients for spatio-frequency encoding, which require precise characterisation, we instead use the natural spin-dipole field of the probe spin to provide highly stable spatial encoding of target nuclear frequencies. The protocol interleaves three carefully constructed levels of quantum control: decoupling of nuclear spins in the target molecule, frequency selective driving of target spins in dipole slices formed by the probe’s natural gradient field, and signal accumulation on the probe spin from which nuclear spin density and 3D molecular structure can be determined. To be useful, any single-molecule sensing system must be able to match or exceed the resolution and precision of established ensemble techniques, the state of the art of which are currently at the angstrom level23,24,25,26,27,28,29,30,31. Using the 1kDa rapamycin molecule (National Center for Biotechnology Information, PubChem Compound Database, CID=5284616) as a non-trivial test case, we simulate the nano-MRI protocol—nuclear spin decoupling, frequency space selective addressing, data acquisition and analysis, spin-density image formation and molecular reconstruction. We obtain 3D images of the hydrogen nuclear spin density (an important distinction to conventional X-ray crystallography where it is difficult to obtain signal from 1H nuclei) and with isotopic labelling we show it is possible to image 13C atomic sites. Under currently accessible experimental conditions the average image resolution achieved is at the angstrom level, with the associated reconstruction error at the sub-angstrom level. Further optimization could incorporate higher order detection sequences, adaptive sampling techniques, and/or pre-exploration using fast coarse grained information about a molecule’s structure. Specific information about molecular conformation or similar mapping applications could be obtained relatively quickly using distinct nuclear spin labels32. Importantly, the quantum probe MRI technique does not require complex sample preparation, and is ideally suited to the challenging in situ membrane protein problem. The NV system is an obvious candidate for implementation, particularly for fast coarse structure determination and/or labelled conformation dynamics under ambient conditions. However, it is inevitable that molecular motion will compromise resolution for precise structure determination—for these applications the target molecule will need to be immobilized as far as possible, for example by operating at low temperatures, and snap freezing the target with its associated hydrated environment33,34,35. Such a prospect also opens up the possibility of exploiting the extremely long coherence times of phosphorus donors in silicon (Si:P)36,37, and associated single-atom fabrication techniques38, for high-precision molecular imaging.

Results

System overview

The set-up is shown in Fig. 1a and consists of a single controllable electronic spin defect in a semiconductor lattice, located 2–4 nm below the substrate surface, above which the target molecule is located. For high-resolution imaging we assume the vibrational and rotational degrees of freedom in the molecule are suppressed, by keeping the system and its hydrated environment in a typical temperature range of 77 K and below34. Positioning the molecule above the spin probe can be achieved in several ways. Mechanical placement of the molecule onto a silicon surface can be performed using an STM/AFM tip, or with optional initialisation of covalent bonding via STM current39. Alternatively, a number of molecules can be placed on the surface statistically ensuring probe to target proximity40. The spatial localization of the probe spin allows it to be in close proximity to the molecule and the dipole interaction field between the molecular nuclear spins and the electronic probe spin assumes the role equivalent to the classical gradient field in conventional MRI (Fig. 1a). The direction of the background magnetic field B0 (with magnitude of order 1-2 T), defines the quantization axis of both the probe spin and the nuclear spins of the molecule, thus providing a way of controlling the effective strength and direction of the dipole interaction between the probe and nuclei spins. The nuclear spins in the molecule are subjected to two different regimes of control—a high amplitude constant radio frequency field used for nuclear decoupling, and a considerably weaker NMR field for resonant excitation. We primarily focus on imaging the 1H nuclear density as the most abundant species in organic molecules, however, as we will show the method is also applicable to other spin species (for example, 13C or 14,15N) through isotope enrichment. As a MRI based method, our protocol encodes structural spatial information onto frequency space, however, in contrast to conventional MRI, where the magnetic field gradient forms equipotential planar slices, the nuclei experiencing equal interaction with the probe spin are located on curved, non-uniform slices, corresponding to dipole lobes (Fig. 1a). The exact shape of the interaction slices depends on the probe’s electronic wave function, which for simplicity we assume is highly localized (for example, NV), but in principle can be pre-characterized (for example, Si:P)41 and/or calibrated using known structures. Details of the actual probe electronic wave function would modify the coupling profile, however, the overall imaging methodology itself is independent of any particular shape of the interaction slices.

The NMR spectrum of a stationary molecule is dominated by its intrinsic dipole–dipole iterations (Fig. 1b, top), causing each nucleus to be detuned from the resonant frequency defined by the probe interaction slices. The average extent of such detuning for 1H nuclear spins is comparable to their coupling to the probe spin, leading to a full loss of correlation in mapping from real to frequency space. To overcome this obstacle, the control protocol simultaneously suppresses the coupling between the nuclei themselves, and extracts the information about the number of nuclei present in each of the interacting slices (Fig. 1b, lower). In the first instance, we consider well-established pulse sequences in the solid state NMR and quantum sensing literature as foundations for the control protocol. At a high level, the protocol (shown in Fig. 1c) is composed of a spin-echo sequence (t/2−πt/2) of length t performed on the probe and a decoupling sequence applied on the nuclear spins. In the first time period (0→t/2), controlled rotations of the nuclear spins located at a chosen resonant interaction slice are performed based on the probe spin state. These operations induce a phase in the probe spin state which accumulates information about the nuclear number density present on the probed interaction slice. In the second time period (t/2→t) the nuclear spins are subjected to a decoupling sequence only, inducing no additional phase in the probe spin state. This particular form, where only one half of the probe’s spin-echo sequence receives the information, is chosen in particular for its high quality signal output of a simple sinusoidal form. In principle, multi pulse dynamical decoupling sequences (for example, CPMG, XY8, UDD (ref. 42)) can be used on the probe, containing multiple appropriately implemented control rotation segments. However, a balance is required; as the rate of information transfer from molecular nuclear spins to the probe is set by the coupling strength between the two, high order sequences can have a negative effect on sensitivity as they serve to decouple the probe from the nuclear spins.

Interleaved quantum control and measurement protocol

The multi-tier control sequence is shown in more detail in Fig. 2. The notation for probe-target operations used in writing out the entire sequence is defined in Fig. 2a and b. The R pulses (Fig. 2a) are resonant to a particular slice and transfer target spin information to the probe. The strong 90° non-selective decoupling radio frequency pulses, , of field strength BD (Fig. 2b), suppress the coupling between the nuclei. For definiteness, in this initial proposal we employ the CORY24 decoupling sequence used in conventional NMR (ref. 43), as shown in Fig. 2c (Methods section, homo-nuclear decoupling). A single segment of the overall sequence, interleaving probe-controlled rotations, R, and nuclear decoupling pulses, D, is shown in Fig. 2d. The set of pulses $\left\{{R}_{i}{\left({\omega }_{i},{\mathbf{\Phi }}_{i},{\tau }_{i},{B}_{\text{R}}\right)}_{{\stackrel{\mathbf{^}}{\mathbf{\text{n}}}}_{i}}\right\}$, (Fig. 2a) are applied during the free precession time τi{τ, 2τ} around a carefully designed set of axes, {i}, which are determined by the driving field amplitude BR, frequencies {ωi}, and phases {Φi} (shown in Fig. 2e and f; the construction is described in more detail below). Each Ri pulse induces a perturbation in the states of a selected nuclear population, in a given dipole slice, of magnitude proportional to γnBRτi, where γn is the target nuclear gyromagnetic parameter. Critically, the consecutive R pulses are synchronised to produce a cumulative signal, corresponding to the number of nuclear spins targeted, on the probe spin. This is achieved by setting the parameters ωi and Φi in accordance with both the previous Ri−1 pulse and decoupling pulses, D. The overall nuclear dynamics are characterized by the slow modulation envelope due to R pulses on top of the fast dynamics of the decoupling sequence. Under a relatively long spin-echo sequence (t1/γnBRτ), the probe is only sensitive to the slow dynamics associated with the nuclear spins located at the selected interaction slice forming a final signal corresponding to the number of target spins in that slice.

We now analyse the resonant slice conditions in more detail. Consider a nuclear spin at a given coordinate r (in the lab frame) relative to a well-localized electronic probe, under a magnetic field B0=B0($\mathrm{sin}{\theta }_{{\text{B}}_{\text{0}}}$ $\mathrm{cos}{\varphi }_{{\text{B}}_{\text{0}}}$, $\mathrm{sin}{\theta }_{{\text{B}}_{\text{0}}}$ $\mathrm{sin}{\varphi }_{{\text{B}}_{\text{0}}}$, $\mathrm{cos}{\theta }_{{\text{B}}_{\text{0}}}$) of constant magnitude B0 and variable orientation (${\theta }_{{\text{B}}_{\text{0}}}$,${\varphi }_{{\text{B}}_{\text{0}}}$). The nuclear spin resides in the interaction slice of equi-coupling strength ΓS(${\theta }_{{\text{B}}_{\text{0}}}$, ${\varphi }_{{\text{B}}_{\text{0}}}$;r) as defined by the secular dipole–dipole coupling field:

where the term defines the orientation of dipole interaction slices as function of background magnetic field direction (${\theta }_{{\text{B}}_{\text{0}}}$,${\varphi }_{{\text{B}}_{\text{0}}}$). The decoupling pulses D are timed with respect to the background magnetic field frequency γnB0, however, the nuclear spins precess with frequencies according to the dipole slice resonant coupling, that is, ωS(±)=γnB0±ΓS/2 (for clarity we suppress angular dependencies when not required), where ωS(±) represents the resonant nuclear frequencies associated with each of the probe’s two spin states. Therefore, as observed in the frame of an interaction slice (defined by ΓS), the axis of the decoupling pulses rotates with relative frequency ΓS/2. The plane defined by a normal in which Ri induces a rotation thus transforms into a new plane under the influence of a decoupling pulse, Di. To achieve a cumulative phase signal on the probe, the Ri+1 performs a control rotation in the transformed plane to add to the previous rotation of the nuclear spin state (Fig. 2g). The initial pulse, R0, constitutes a controlled rotation in the direction 0, which can be an equatorial direction of choice. At the end of the CORY24 sequence the net cumulative control rotation of the selected nuclear spins is returned back to this initial direction, leading to a net change in the z-projection of the nuclear spin states which is detected by the probe. Unless explicitly stated otherwise, from here on we assume the interrogation of the spectrum is performed in the positive frequency side , omitting the superscript (as illustrated in Fig. 1b). Relative to the initial axis 0 any subsequent control rotation Ri is formulated by transformation of 0 under the decoupling D pulses as observed in the frame of the particular interaction slice characterized by coupling strength ΓS:

where Dj is the jth decoupling pulse occurring at time ${t}_{{\text{D}}_{j}}$. Once the unique sequence of driving directions is determined for a given target interaction slice (Fig. 2h), it follows that the pulse Ri resonant with the interaction slice of coupling strength ΓS, is constructed by applying the magnetic field of frequency ωi and initial phase Φi as defined by :

The frequency shift δωi defines the polar tilt of the rotation axis while the phase Φi defines the azimuthal direction. The frequency and phase control are depicted in Fig. 2e,f. We note that from the perspective of practical implementation, the phase of the driving field of each pulse Ri is more crucial than the frequency shift δωi. In the case of high background magnetic fields (B01T) and relatively low driving fields (BR1 μT) the frequency shifts are relatively small. Furthermore, the average δωi is equal to zero. Thus, keeping the driving frequency constant (unlike the phase) ωiωS across all R pulses produces the resonant behaviour comparable, to within several percent, to the full variable frequency control. The fully integrated control protocol is depicted in Fig. 2i.

When the power broadening due to the fine driving field BR is smaller than the probe coupling ΓS, and the probe spin is held in an equal superposition state, the signal Sα (Fig. 2j) generated by the αth nuclear spin under the sequence is well approximated by the following form:

where rα is the coordinate of the of the αth nuclear spin, (${\theta }_{{\text{B}}_{\text{0}}}$,${\varphi }_{{\text{B}}_{\text{0}}}$) is the direction of the background magnetic field, T2n is the effective transverse coherence time of nuclear spins, and is detuning of the scanning frequency ω from the resonance frequencies, . The typical temporal dependence of the signal (Fig. 2j) has a sinusoidal shape, analogous to Rabi oscillations, reflecting the cumulative effect induced by fine driving R pulses on the nuclear spin state. In addition to providing a high quality signal, the presence of selective, slow nuclear evolution in only one half of the probe spin-echo sequence results in a characteristic detuning behaviour. As increases, the frequency of the signal decreases, while the maximum amplitude remains unchanged, as illustrated by Fig. 2j. This is particularly useful for the generation of a clean signal trace as a function of sweep frequency, ω, at a fixed time t, providing an effective Lorentzian signal peak. For well decoupled nuclear spins (T2n>t) in an equally mixed spin state, the total signal from a slice resonantly addressed by frequency ω can be expressed as a product of signals originating from each individual nucleus:

where NS is the total number of spins in the slice of the species, and T2p is the transverse coherence time of the probe spin. We emphasise that the outlined methodology can be generalized with respect to variations in the nuclear decoupling and probe detection sequences. In the case of decoupling sequences that have less or no free procession periods, the control rotation, R, pulses can be applied simultaneously with any decoupling pulse, provided the two commute. An additional feature of the control sequence is the positive effect on the probe’s coherence time T2p. By suppressing the dipole coupling between the nuclei, the protocol simultaneously modifies the intrinsic magnetic fluctuation spectra of the molecule, and thus its frequency spread is reduced to a narrow band around a single high frequency (1/τ) that is outside the detection range of the probe sensing protocol. This property opens up a noise-free window in low-frequency spectrum, which is particularly suitable for high-resolution detection of remote nuclear spins.

To illustrate the behaviour of the integrated detection protocol (Fig. 2i), we perform a fully quantum simulation of a cluster of 1H nuclei at realistic distances from the probe which couple through their mutual dipole–dipole interactions (Fig. 3a). In the spectrum obtained by sweeping the frequency, ω, the peak heights contain information on the number of nuclei located in the same interaction slice (Fig. 3b, front plane). Figure 3b depicts the spatio-frequency encoding behaviour of the MRI spectrum as a function of the detection protocol’s decoupling parameters. The upper pane (Fig. 3b) corresponds to the strong decoupling regime. Moving down towards the lower pane corresponds to weaker decoupling where the spatial encoding of the MRI spectrum is distorted due to emerging dipole–dipole interactions between the nuclei, reflected in progressive splitting of initial MRI peaks. The results indicate that decoupling fields BD with amplitudes of order 20–40 mT are required. This estimate is appropriate in the case of more complex nuclear systems, as the local environment of nuclear spins dominates the coupling magnitudes. Figure 3c depicts the degree of power broadening behaviour of the detection sequence as the fine driving field strength BR increases, indicating minimum quantum probe coherence times T2p requirements in the range of 30–50 ms for sufficient resolution of molecular features at the angstrom level. This is well within reach of coherence times for P donors in purified silicon at a typical operational temperature of order 100 mK (refs 36, 37). The coherence times of the NV centre in diamond are at present insufficient for full-structure determination, although the required regime may, in principle, be reached by further diamond surface engineering and isotropic purification related to nitrogen and carbon(13) baths44,45. Current experimental coherence times for near-surface NV centres may allow conformation detection based on imaging the locations of a small set of spin-labels.

MRI measurement and structure determination

We now illustrate the entire protocol using a non-trivial example—the rapamycin molecule (C51H79NO13). This particular molecule, in the mass range 1 kDa, is around three orders of magnitude larger than that considered in proposals for 1D and 2D NMR spectroscopic approaches18,19,22. In our approach, once a sufficient level of decoupling is assumed, it is possible to simulate the entire structure determination protocol. We apply the sequence to acquire 1H and 13C nuclear density data and obtain the molecular coordinates for the two atomic species. The spectral data was sampled at multiple orientations of the background magnetic field as depicted in Fig. 4a (Methods section, 3D imaging protocol), and contains the nuclear density of the target molecule in dipolar-slice space—numerical inversion into cartesian space (Fig. 4b,c) yields the molecular nuclear 3D densities shown in Fig. 5b,c. The 1H and 13C atomic positions in the rapamycin molecule are readily observable by inspection of contours of 50 and 75% contrast around 3D density peaks having distinct spherical shapes. The atomic coordinates are reconstructed by thresholding local maxima in the nuclear densities above 90% (crosses, Fig. 5b,c), and estimating the uncertainty in the atomic positions by average of the full width at half maximum (FWHM) in three axial cross-sections of the 3D density peaks. Figure 5d shows the atomic site coordinates with the colour scale conveying the spatial uncertainties (corresponding to the widths of the density peaks) in atomic positions ranging from 0.4 Å to 1.4 Å. We note that these coordinates are derived directly from the density image, without potential energy minimization or other post-processing. Comparison of the reconstructed atomic coordinates to the true molecular coordinates, gives an average statistical variation of 0.5 Å, represented as the radius of the spheres in Fig. 5d. Using this simple data collection strategy, the total acquisition time amounts to 175 h under realistic experimental conditions to image the 1H structure of rapamycin (and twice as long for the 13C structure). These calculations assumed probe and nuclear target coherence parameters T2p=50 ms, T2n=50 ms and a detection sequence of total length t=8 ms, with shot noise limit given by MS=2000 single shot measurements per slice over 150 slices for each of the 264 B0 orientations (for details see Methods section, parameters for the molecule example). With the outlined parameters, the protocol provides a hemispherical imaging volume of 8 nm in radial extent above the probe–sufficient for imaging proteins across cell membranes (4 nm thickness). Where larger imaging volumes are required, it may be possible to augment the protocol with additional external (classical) gradient fields21, however, with increasing probe-target distance detection is more limited. The variation in 3D density resolution along the z axis is consistent with the simple constant sampling methodology used in this example, where the frequency sweep steps are constant yet the dipole strength gradient is not. Thus, the results from this rudimentary sampling procedure should serve as an indicator of the upper limit on the total acquisition time and resolution achievable.

The rapamycin example illustrates the potential of full atomic scale imaging of single molecules based on naturally abundant nuclei, such as highly dense 1H atoms that detail the structure of organic molecules. However, for applications where only limited information is required (for example, conformation and/or ligand state/position), targeting characteristic nuclear spin labels (that is, 14,15N, 13C, 31P) 1–2 nm apart, can be achieved up to two orders of magnitude faster compared with full atomic scale imaging. This is a consequence of order of magnitude reductions in both the required number of interaction slices and the measurement sequence length t. In this case, the requirements on the probe’s coherence times decrease to the 3–5 ms range, with further 2–3 orders of magnitude reduction in field strength needed for nuclear decoupling pulses. This opens up experimental applications in room temperature individual molecule conformational mapping based on NV centre in diamond, particularly for conformation detection based on electron spin labels46 for which there is an additional three orders of magnitude speed up due to the stronger magnetic moment. In this case the probe’s transverse coherence time is required to be in the microsecond range or greater which is commensurate with current values for near-surface NV centres11,40,47.

Methods

Homo-nuclear decoupling

Suppression of coupling between nuclear spins is routinely performed in solid state NMR, by physical or Hilbert-space rotations52. Physical rotations around the dipole–dipole magic-angle axis have proved useful in practice, however, nanometer scale rotations of a single molecule relative to a single spin probe are outside the reach of immediate technology, thus we propose Hilbert-space techniques to achieve the same result. Out of multiple families of Hilbert-space approaches, the two dominate branches in the group of on-resonance pulses are the solid-echo and magic-echo27,52,53 based sequences. The former utilise multi-axis 90° pulses to perform effective spin rotation about the magic-angle axis, and the latter are based on 360° pulses. Without loss of generality, we consider the solid-echo type sequences and show how they can be integrated with control rotations on the nuclear spins. These decoupling sequences are made up of unit blocks of the following form: where are 90° square pulses around positive/negative x or y axis, and τ is the free evolution time of appropriate duration53.

Hilbert space decoupling approaches are designed for conventional NMR techniques under uniform background magnetic fields, therefore their application in a gradient field regime requires detailed consideration. A dipole–dipole NMR spectrum of a molecule in a uniform magnetic field B0 is symmetric around the frequency set by the background field γnB0, where γn is the nuclear gyromagnetic ratio. The square decoupling pulses are also centred around the same frequency, but have a spectral spread wider than the dipolar molecular NMR spectrum. This ensures appropriate narrowing of the spectrum towards the background frequency γnB0. In contrast to classical gradient fields, we can choose to maintain this symmetry of the NMR spectrum by keeping the probe spin in an equal superposition throughout application of the decoupling pulses, while keeping the free precession time equal to the full number of background field periods τ=nd2π/γnB0, nd. The probe itself does not participate in the effective magic-angle spinning as its electronic spin has different resonant frequency. In turn the probe coupling terms to each of the nuclei, ΓS(${\theta }_{{\text{B}}_{\text{0}}}$, ${\varphi }_{{\text{B}}_{\text{0}}}$;r), remain unaffected and define the interaction slices characterized by polar direction (${\theta }_{{\text{B}}_{\text{0}}}$, ${\varphi }_{{\text{B}}_{\text{0}}}$) of the background magnetic field B0. This feature allows the spin-echo sequence on the probe to refocus the phase offsets encountered by nuclear spins on different interaction slices, thus maintaining their coherence under the gradient coupling regime.

3D imaging protocol

This section details the general steps leading to the generation of the 3D spatial image of the molecular nuclear density. The primary sampling is done by sweeping the fine driving frequency ω in discrete steps of from ωmin to ωmax. The upper frequency limit ωmax is set by the value of the interaction at the substrate surface, immediately below the molecule. The lower frequency bound ωmin must be no greater than the minimal coupling experienced in the molecule, spatially associated with the uppermost part of the molecule.

Relative to the probe, the physical shape of a resonant interaction slice is defined by a equipotential of the coupling field between the probe and the nuclei having value equal to ω. In frequency space, the spectral broadening of the signal generated by the power of the driving field BR is set equal to the sampling step , ensuring sufficient spectral coverage. In real space, the dipole slice corresponds to a spatial region of non-uniform width, depending on the strength of the driving field BR and the gradient of the coupling field.

The signal values generated by the frequency sweep contain relative information about the number of nuclear spins located on each of the interaction slices. The orientations of the interaction slices depends on the direction of the quantisation axis (Fig. 4). The frequency sampling is performed for multiple orientation of the quantization axis by reorienting the background magnetic field B0, in discrete latitude steps of $d{\theta }_{{\text{B}}_{\text{0}}}$ from ${\theta }_{{\text{B}}_{\text{0}}}^{\text{min}}$ to ${\theta }_{{\text{B}}_{\text{0}}}^{\text{max}}$ and azimuthal steps of $d{\varphi }_{{\text{B}}_{\text{0}}}$ from 0 to 2π.

We note that the signal for each resonant slice is a product of individual nuclear spin signals. This characteristic has to be considered both from sampling and from data processing perspectives. As a function of time, the signal approaches zero as the number of spins on a resonant slice increases. An appropriate choice of the fine driving strength BR and the sequence length t has to be made. To yield optimal results this calibration can be optimised dynamically for a particular molecule of interest as part of the initial frequency sweep. Alternatively the sampling can be performed for several sequence lengths.

Given the signal exhibits a product structure, we devise a self-scaled derivative (SSD) approach to linearisation. We define the SSD, Si*(x) of a single signal function, Si*(x), with respect to a given parameter x as:

As the total signal is a product of signals of all N nuclei in the molecule, it follows that the SSD of the total signal with respect to a variable x transforms from product to linear structure:

The data is linearized by computing the SSD for each frequency sweep with respect to the fine driving frequency ω. To obtain the MRI spectrum we perform a one-dimensional deconvolution to the frequency sweep data. The natural choice for the point spread function is the single nuclei spin response SSD function, Si*, symmetrically centred in the sweep range. The deconvolution step removes signal contributions of the spins on the neighbouring interaction slices, ensuring that the data linearly reflects the number of spins present at their corresponding slice.

To form the nuclear density image, the volume containing the molecule is discretized into n × m × q segments separated by a dl[Å] step. We construct a transform such that where ρ is a vectorized 3D nuclear density, and S is the equivalent form of the measured signal for all slice orientations. Each row of the matrix represents a discretised 3D map corresponding to a single interaction slice. The nuclear spin density is obtained by numerical inversion. This general approach is unconstrained by the shape of the resonate slices. From the 3D density image, atomic coordinates are extracted by observing the positions of the local maxima.

Parameters for the the molecule example

For clarity, the method is demonstrated for a probe with a well-localized electronic spin, thus the interaction slices correspond to equipotential slices of the secular dipole–dipole coupling field:

where r is a given nuclear coordinate vector relative to the probe in the lab frame and B0 is the constant magnitude background magnetic field controlled by polar direction parameters (${\theta }_{{\text{B}}_{\text{0}}}$, ${\varphi }_{{\text{B}}_{\text{0}}}$).

The parameters chosen for the simulation are as follows: the fine frequency sweeping range was ωmin=100 rad s−1, ωmax=15 krad s−1 with the sampling step of =100 rad s−1 (ω=ωS is a resonance condition for probing nuclei in the slice ωS). The frequency sweeps were conducted for a range of orientations as given by latitude parameters , , and and longitude steps $d{\varphi }_{{\text{B}}_{\text{0}}}$=π/12. Each point was sampled at a fixed protocol length of tH=8 ms for 1H nuclei and tC=16 ms for 13C nuclei, with MS=2000 measurements per slice. The transverse coherence time of the probe and the effective coherence time of the nuclear spins were set to be respectively T2p=50 ms and T2n=50 ms. Such coherence times are already established for the Si:P system, and with suitable cooling and material improvements may be possible for the NV centre.

To obtain nuclear density images in 3D, the region around the molecule, (−1,1) nm, (−1,1) nm and (3.5,5) nm was discretized in cubic voxel of side length dl=0.5 Å, the inversion of the map was performed by numerical least-square based approach54,55,56.

Quantum simulations

Features of the numerical simulations (Fig. 3) performed to investigate the behaviour of the detection protocol (Fig. 2i) are characterized by the full quantum Hamiltonian, containing nuclear dipole–dipole interactions between individual nuclei and probe spins as well as between all nuclei themselves. This is a crucial requirement for accurate investigation of intricate dynamics between the homo-nuclear decoupling part of the detection sequence and the fine driving that transfers the relative spatio-frequency coded information about the nuclear spin density to the phase of the probe spin. The second requirement is for both the strong decoupling pulses as well as the fine driving pulses to be introduced, on the Hamiltonian level, as physical fields of appropriate amplitude shape and length. We model both of these pulse types as square in shape reflecting readily used experimental approaches as well as lowering computational requirements needed compared with Gaussian or Sinc shaped pulses that would in principle give better permanence to the total detection protocol. In contrast, unitary matrix operations are sufficient to capture the control of the electronic probe spin, since the required pulses are relatively fast with frequencies are well outside the nuclear spin range. The initial state of the nuclear target spins is dominated by high temperature regime due to strong dipole–dipole interactions, and can be well captured by mixed state density matrix representation. The coherence of the target nuclei depends strongly on their quantum interactions with one another, while the probe spin can be sufficiently well modelled through an additional explicit Lindblad term designed to model its decoherence properties unrelated to the presence of the molecular nuclei (such as a 29Si bath for Si:P probe, or 13C bath for NV-centre). Note, the nuclei-probe dipole–dipole interaction in conjunction with decoupling properties of the detection protocol automatically affects the coherence of the probe spin beyond the explicit Lindblad term.

Data availability

All relevant data are available from the authors on request.