Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Axon hillock currents enable single-neuron-resolved 3D reconstruction using diamond nitrogen-vacancy magnetometry

## Abstract

Sensing neuronal action potential associated magnetic fields (APMFs) is an emerging viable alternative of functional brain mapping. Measurement of APMFs of large axons of worms have been possible due to their size. In the mammalian brain, axon sizes, their numbers and routes, restricts using such functional imaging methods. With a segmented model of mammalian pyramidal neurons, we show that the APMF of intra-axonal currents in the axon hillock are two orders of magnitude larger than other neuronal locations. Expected 2D magnetic field maps of naturalistic spiking activity of a volume of neurons via widefield diamond-nitrogen-vacancy-center-magnetometry were simulated. A dictionary-based matching pursuit type algorithm applied to the data using the axon-hillock’s APMF signature allowed spatiotemporal reconstruction of action potentials in the volume of brain tissue at single cell resolution. Enhancement of APMF signals coupled with magnetometry advances thus can potentially replace current functional brain mapping techniques.

## Introduction

The development of in vivo two-photon calcium imaging1 and subsequent development of fast voltage/calcium sensors2,3 of neuronal membrane potential has allowed probing of local neuronal circuits4,5,6,7,8 in the mammalian brain at single-cell and millisecond spatiotemporal resolution. The advent of this technique actively triggered the study of excitatory–inhibitory populations of neurons and their functional connectivity9,10,11 in the passive sensory and active behavioral state of an organism. Multiphoton functional neuronal imaging is limited to depths of a maximum of 1 mm from the brain surface due to limits of optical penetration of deep tissue and scattering1,5,12,13. Therefore, local neuronal populations from deep areas of the brain, like the hippocampus, many regions of the frontal cortex, amygdala can not be probed at the local circuitry level, unless largely invasive and potentially damaging optical fibers are used.

Methods for ultrasensitive microscale magnetic field sensing14,15,16,17,18,19,20,21 or single-cell resolution functional magnetic resonance imaging22,23 are being progressively developed to address this challenge. Diamond–nitrogen-vacancy centers (NVC) have emerged as a class of ultrasensitive nanoscale magnetic field detectors that function at ambient temperature24,25,26. Additionally, the NVC’s inert chemical nature allows it to be placed very close to the biological tissue27 allowing sensitive probing of biological magnetic fields21. In this context, Barry et al.28 experimentally demonstrated the measurement of worm axon action potential (AP)-associated magnetic field (APMF), which was found to be ~600 pT peak-to-peak in magnitude, using an ensemble of 2D NVC layer in the diamond. Notably, high-sensitivity microscale magnetic field mapping has been made possible by the preparation of high-density NVC diamond samples with high intrinsic coherence14. Further, the directional orientation of different NVC along the tetrahedral axes is used to obtain the vector direction of magnetic field28,29. APMF signal bandwidth falls in direct current (DC) to a few kilohertz bandwidths. DC-field sensitivity in NVC experiments is rapidly improving toward quantum projection noise limit28, at ~100 $${\mathrm{fTHz}}^{ - \frac{1}{2}}$$, with the best DC sensitivity record to be measurement at 50 pT Hz $$^{ - \frac{1}{2}}$$. for ensemble vector magnetometry measurements30. With constantly improving DC-field sensitivity, the community is expected to capture mammalian neuronal spike signals using diamond NVCs.

However, a challenge in probing a network of mammalian neurons in vitro or in vivo will be to reconstruct AP timing and location of single neurons from diamond NVC magnetometry. Previous work in the reconstruction of simulated APMF recordings via diamond NVC magnetometry has been restricted to simple models of passive conducting axons via filtering of noise in spatial frequency domain28 and a Wiener filter-based reconstruction of axonal firing31. Also, theoretical work has been carried out to develop inverse filters32,33,34 for the reconstruction of two cylindrical axonal currents, where analytical expression for current density was known. To the best of our knowledge, no method has been developed that takes into account the complex geometry and physiology of cortical neurons, where analytical expression for intra-axonal currents can not be derived. Further, single-AP-event detection from a time series of measurements must also be combined with spatial reconstruction, a necessary feature that is absent in previous studies.

In this work, we address the reconstruction of spike location and timing for realistic mammalian cortical pyramidal neurons, comprising of soma, axon-hillock region, axon initial segment, and other regions, specifically with respect to the case of measuring 2D vector magnetic field map (referred as diamond–nitrogen-vacancy magnetometric maps (NVMM) further in this text) via widefield diamond NVC magnetometry. We simulated voltage propagation in a realistic cortical pyramidal neuron model35 and obtained intra-axonal current profiles during an AP. These spatiotemporal current profiles were used to estimate the vector magnetic field during an AP. We found a 36 pT peak-to-peak mammalian APMF magnitude, which is close to the current limits of diamond NVC-based DC magnetometers. Notably, we found that axon hillock contributes almost two orders more, as compared to other axonal regions, to the measured APMF estimate. This naturally occurring advantage simplifies the inverse problem from being equivalent to solving randomly oriented current-carrying wires, where the location of ultra-small current keeps changing in 3D space as the AP propagates over hundreds of microns, to primarily a set of ~10-μm-sized axon-hillock region, fixed in space and exhibiting localized current flow only when an AP occurs in the corresponding cell soma. We propose an adaptation of dictionary-based matching pursuit algorithm36,37,38,39, to be applied on measurements from widefield diamond NVC magnetometry, for solving individual spike timings and locations in a 3D volume of randomly oriented pyramidal neurons. We show that the reconstruction of randomly oriented neurons in 3D can be achieved with accuracy ~70% and also for neurons arranged in a 2D plane parallel to the NVC layer. We find that our matching pursuit-based algorithm allows high noise resilience to the reconstruction. Further, we analyze the closest distance between a pair of cells that can be resolved by the algorithm. We find that nearby single neurons spiking near simultaneously with time difference 1 ms or more can be reliably resolved. Based on reconstruction errors, we infer that strongly correlated columns of the dictionary, due to the similarity of magnetic field patterns formed by two closely located neurons, are the main constraints to achieving perfect reconstruction.

## Results

### High magnetic field contribution of axon-hillock currents

APMF of worm (marine fanworm Myxicola infundibulum and the North Atlantic longfin inshore squid Loligo pealeii) single axons were estimated to be ~600 pT in magnitude measured with ensemble diamond NVC imaging setup28. However, mammalian neurons have a significantly smaller cross-sectional diameter (~1 μm at nodes) and carry orders of magnitude less axonal currents than the worm axon. APMF estimates of mammalian neurons reported from computational studies are inconsistent and vary in the range ~1 pT–1 nT28,40,41. Further, the contribution of currents in the different types of axonal segments, like axon hillock, nodes of Ranvier, and others, to the final APMF has not been investigated. In an intact mammalian brain, detecting activity based on APMFs from axonal currents requires localization of the source at single-neuron resolution. Only 2D measurements of the magnetic field via widefield ensemble NVC magnetometry would not be usable, as the 3D source reconstruction would be nonunique. We first address the question—are there specific signatures in the APMF of a neuron that can allow spatiotemporal reconstruction of the source? For this purpose, we consider a realistic cortical pyramidal neuron APMF and investigate the differential contribution of neuronal regions to the APMF magnitude.

The voltage propagation through the structures in a realistic cortical pyramidal neuron model35 was simulated to study the contribution of the distinct types of sodium channels in the initiation of the AP. The model incorporated realistic geometry, physiological parameters, and experimentally determined ion-channel densities. The pyramidal neuron comprised of different segments namely, cell soma, dendrites, axon hillock, action initial segment, unmyelinated axon, myelinated axon, and nodes of Ranvier. The neuron was divided into isopotential compartments, and membrane potential dynamics across these compartments was governed by the cable theory42,43,44 equation (Eq. (3), “Methods”), and solved using the NEURON solver45 (see “Methods”). A step current injection was added at “central” soma segments to make the neuron fire APs, and the membrane potential for one AP was recorded. Voltage propagation across each segment in time for a single AP was imported from NEURON41,45, and all further analyses were done in MATLAB46. AP initiation was observed in the most distal segment of the axon initial segment (AIS) (Fig. 1a, AIS region). This result is consistent with previous studies, which show that AP originates in the AIS, due to the presence of high density of sodium channels and high resistance of segments35. After AP initiation, a bidirectional propagation of AP, one in the direction of cell soma and the other in the direction of axon, is observed (Fig. 1a–c). The bi-directionality is in agreement with observations from experiments35. In order to estimate the mammalian neuron’s APMF, intra-axonal currents across segments at each time instant were calculated. Only the intra-axonal currents were considered in calculating the APMF based on previous theoretical work33,47,48 showing that the net magnetic field due to spiking in neurons is primarily determined by the intra-axonal currents. This assumption has also been experimentally demonstrated in superconducting quantum interference device (SQUID)-based magnetic field measurements of frog sciatic nerve49,50. The intra-axonal current profiles in each segment (Fig. 1d) were calculated (Eq. (4), “Methods”) based on the discrete version of the basic cable equation. We observe high intra-axonal current flow in the axon-hillock region (Fig. 1d). Further, we analyzed intra-axonal current flow in all regions of the neuron, as a fraction of the current flow in the second node of Ranvier (Fig. 1d). The discontinuities observed in the curves of Fig. 1d are inherent to numerical solutions of the pyramidal neuron model, occurring specifically at compartments where radius, physiological type, or other properties of any segment changes (see Supplementary Note 1 for detailed description). We found two orders of magnitude higher current flow in the most proximal segment of the axon hillock as compared to the second node of Ranvier. This result implies that pixels on the NVC sensor that are on the perpendicular axis of the axon hillock will sense significantly higher magnitudes of APMF signatures. Also, the presence of ion channels in segments of neurons leads to current injection in segments. Higher currents will be found in segments with relatively high sodium ion-channel density and large surface area. While both Axon hillock and AIS have high sodium channel density, axon hillock has a much larger surface area, especially toward the proximal end connecting to the soma. This provides a physiological explanation to higher axonal currents in axon hillock.

Comparisons of APMF magnitude and waveforms (calculated by Eq. (5), “Methods”) between a point located vertically below the axon hillock to a point located vertically below the soma or axon terminal clearly implicate the axon hillock as the dominant contributor to the APMF (Fig. 1e). We quantify the mammalian APMF magnitude as the peak-to-peak magnetic field (Y component) measured at a point vertically below the axon hillock, which is 36 pT at a distance of 20.50 μm from the longitudinal axis passing through the centre of the axon. However, no experimental verification of the mammalian neuron APMF magnitude has been made yet to the best of our knowledge.

We have excluded the magnetic field contribution of soma and dendrites from the analysis. It has been shown analytically that the magnetic field contribution due to spherical soma will be zero51. Pyramidal soma shape might generate an effective magnetic field due to distortion from the spherical shape. We assume it to be small due to the relatively smaller sodium ion-channel density of the soma. Therefore, we have excluded somatic contribution in magnetic field calculations. Also, magnetic field contribution from dendritic compartments, due to small diameters and relatively low sodium ion-channel densities, have also been excluded.

### 2D NVMM comprises of specific signatures of APMF

We generated 2D time-varying magnetic field maps by spatially summing magnetic field contributions from current flow in different segments of the neuron, at each time instance (Eq. (5), “Methods”). We explain the features in these maps with respect to the following: bidirectional propagation of AP, the activity in nodes of Ranvier, and the overall spatial size of APMF signatures. These 2D NVMMs are simulated realizations of magnetic field measurements on a 2D plane, as it would be in an experimental case of a thin top layer of NVC defects in a cube of the diamond (see “Methods”). Henceforth, we refer to the above 2D NVMMs simply as maps, unless mentioned otherwise. The simulated maps at different timepoints (Fig. 1a, horizontal lines) acquired during the firing of an AP show a number of variations of features (Fig. 2). Here, we show noiseless 2D maps at different timepoints, namely, 2.5, 3, 3.5, 4, 4.5, and 6.5 ms in Fig. 2a–f, respectively, to understand fundamental features of NVMMs and correlate it with AP propagation in neurons. The first prominent feature in the maps is the dominance of the axon hillock, as we observed that APMF signatures are significantly visible in only maps of Fig. 2b–e, which corresponds to AP propagating through or near the axon-hillock region of the neuron. Since the axon-hillock activity’s contribution to the APMF was approximately two orders larger than those of other regions APMF, signatures of other regions were unidentifiable in these maps. Therefore, to understand the APMF signatures of other regions in these maps, we saturate the color axis at lower magnetic fields and separately analyze the By (Fig. 2g–l) and Bz (Fig. 2m–r)) component of the magnetic field. Each map (Fig. 2a–r) corresponds to AP propagating through specific segments (Fig. 2s–u) and at specific timepoints (dashed vertical lines, Fig. 2s–u). The membrane potential of the three example segments (Fig. 2s—axon hillock, 2t—AIS, and 2u—node of Ranvier) show that the AP initiation falls before timepoint 3 ms. After initiation of the AP, we observed bidirectional propagation of AP along the cell soma and axon terminals (Figs. 1a and 2a–r). Later in time (4–6 ms, after the start of current injection), we observed repetitive patterns of activity that correspond to AP propagation through repetitions of myelin node in the neuron (Fig. 2j–l, p–r). Another important feature was the appearance of quadrant like Bz components of the field (Fig. 2m–r), which indicates that intra-axonal currents can be approximated as current dipoles.

### Reconstruction as a dictionary-based linear inverse problem

The inverse problem comprises detecting the time and location of neurons that fired an AP from NVC maps. The magnetic field, as measured by ensemble diamond magnetometry, due to current flow across segments of spiking neurons is given by Eq. (1)

$${\mathbf{B}}_{{\mathrm{nv}}}\left( {\alpha ,\beta ,t} \right) = \mathop {\sum}\limits_n {k\,I\left( {x,y,z,t} \right)} \frac{{\overrightarrow {{\mathbf{dl}}} \,{\mathbf{X}}\,\overrightarrow {{\mathbf{dr}}} }}{{\left| {{\vec{\mathbf{r}}}} \right|^2}}.$$
(1)

In the above equation, Bnv(α, β, t) is the field experience by an NVC or a small ensemble of NVCs located in the pixel at position (α, β) at time t, n denotes all isopotential segments (of all neurons), k is a constant (“Methods”). The inverse problem is to detect a fraction of I(x, y, z, t) waveform that guarantees an AP in neuronal soma at location x, y, z, and time t, by operating on the vector magnetic field Bnv(α, β, t) from different diamond NVC pixels obtained from diamond NVC vector magnetometry. It is to be noted that, since an AP is an all or none event, we do not need to reconstruct the full spatiotemporal variation of current I.

The above inverse problem can be formulated in terms of a dictionary-based linear inverse problem, where the dictionary elements contain prior information about NVMMs from AP firing of single neurons located at different spatial locations in different orientations. Since the axon-hillock currents provide the dominant signature in a neuron’s APMF, the individual dictionary elements are created by considering mainly the axon-hillock NVMMs (Fig. 2c–e). The above linear representation allows the application of a matching pursuit algorithm for spatiotemporal AP reconstruction37,38,52,36. A dictionary-based matching pursuit approach is motivated by sparse spatiotemporal distribution of spikes in mammalian cortices52,53,54 and previous application of matching pursuit algorithms to magnetoencephalography (MEG)/electroencephalography (EEG) data55 for the reconstruction of active current dipoles formed during APs. However, reconstruction of MEG/EEG has been demonstrated only at the coarse spatial resolution, in the range of hundreds of microns, not near the single-cell spiking resolution.

The final experimental map is expressed as a linear combination of individual NVMMs. For the dictionary matrix A, X a vector of length equal to the number of neurons and B a vector of experimental multidimensional NVMM data points, we can write the problem as in Eq. (2), in which X, a binary vector, needs to be estimated.

$$AX = B + {\it{\epsilon }}.$$
(2)

The dictionary A is of mxn dimensions, where m is the number of dimensions in the experimental data, $${\it{\epsilon }}$$ is the noise in NVMM experimental maps, and n is the total number of neurons in the tissue volume of interest. We aim to solve for X, whose elements can only be zero or one, depending on whether the corresponding neuron fired or not. However, the above linear equation is overdetermined, with the number of neurons being less than the number of dimensions in an NVMM. Performing a full least-square search for 2n, where n is in thousand range, is computationally impractical, and hence the following dictionary-based matching pursuit algorithm is used after modification for NVMM time series data.

### Proposed matching pursuit algorithm

The proposed reconstruction algorithm (details in “Methods”) works by considering a multidimensional time series Bt considering each pixel in maps of Bx, By, and Bz at each of three successive timepoints (t − 2, t −1, t for $$n_{{\mathrm{t}}_{\mathrm{p}}}$$ = 3 in “Methods”, Fig. 3a) as a dimension. Each of the Bx, By, and Bz 2D maps (image data representing each timepoint) in the time series are represented in Fig. 3a separated by white dashed lines. At each time instant, the signal acquired along with the signal in the previous two time frames can be projected onto individual normalized columns $$\widehat {{\mathbf{A}}_i}$$, of the dictionary A (Fig. 3b). The maximum projection, and hence, the most probable single neuron that fired an AP at that instant is denoted by the best-matched neuron index in schematic Fig. 3. We impose the condition of detecting the spikes of a particular neuron as occurrences of the same neuron as the best-matched neuron at multiple time instances, greater than a specified parameter p1 within a stretch of successive p2 timepoints. On detecting a spike, we ascertain the exact spike timing of the neuron by matching the neuron’s spike signal to different regions of the experimental signal with a local shift of +/−τ timepoints (1.5 ms total) near the timepoint where we detected neuronal spike. The time instant that gave maximum dot product/alignment with the neuron’s signal was chosen at the exact spike timing of the particular neuron. Since axon-hillock activity is the dominant signature on NVMMs, each element in the dictionary is constructed from additions of three timepoints 3.5, 4.0, and 4.5 ms, which mainly correspond to high axon hillock activity (Fig. 3b). The main control parameters of the reconstruction algorithm are threshold T, p1, and p2. The threshold needs to be set greater than the smallest energy column of the dictionary. p2 parameter depends on the total number of timepoints considered in the formation of the dictionary. p1 controls the minimum number of consecutive timepoints that a neuron should be best matched to the signal to be considered a spiking event. For later demonstrations of reconstructions, we considered p2 equal to 3, which is equivalent to considering 3.5, 4, and 4.5 ms time-point NVMMs being incorporated into the dictionary. p1 has been taken to be 2, equivalent to a millisecond length signal in real time.

We developed this algorithm as a modification of the original matching pursuit algorithm. Our choice of maximum dot product (DP) criteria (“Methods”) was based on the use of these criteria in previous matching pursuit algorithms. These algorithms are based on the assumption that the experimental data can be expanded as linear combinations of basis vectors, which are individual dictionary elements. Hence, dot products with basis vectors are commonly used to extract coefficients. Another similar criterion to evaluate the resemblance between experimental time series and dictionary elements is Pearson’s correlation coefficient (CC). By changing the best-matched index selection criteria from DP to CC (“Methods”), we found identical performance in 2D case and minor differences in 3D case (see Supplementary Table 3).

### Population performance in cortical tissue simulations

The feasibility of spatiotemporal localization of occurrence of spikes based on the APMF of the axon-hillock current with our algorithm was tested in the case of a 2D array of neurons and a 3D volume of neurons (Fig. 4a, b). We quantify the performance of the algorithm in reconstructing spike location and time in each case. In both cases, spikes in neurons at each time step, of 500 μs, were generated as a binomial process with a probability f (see “Methods” for details). In the 2D case, neurons are placed in the plane parallel to the diamond NVC layer, at a spacing of near-cell soma size separation of 10 μm, and spikes are assigned as described in “Methods”. Experimental NVMMs are generated by the summing of individual NVMMs and adding noise (Gaussian or shot noise). Figure 4c illustrates an example of reconstruction where we observed that most of the spikes are detected and marked correctly in space and time (Fig. 4c).

The performance of the algorithm for proper detection of spikes in space and time can be obtained with $$d^{\prime} = z\left( {{\mathrm{hit}}\,{\mathrm{rate}}} \right) - z({\mathrm{false}}\,{\mathrm{alarm}})$$56. The algorithm is very robust in the sense that it correctly rejects the absence of spikes even in large noise, thus leading to a very high correct rejection rate or very low false alarm. Given the extremely low percentage of false alarms (<<1%) with the naturalistic sparse firing rates considered, the d′ value is very large in most cases even with noise. Hence, to be conservative, we quantify the accuracy of reconstruction based on the fraction of correctly marked spikes by total spike instances marked by the algorithm. This would mimic a real situation when actual imaging is performed in the absence of knowledge of all possible spikes that could occur. In the no noise case, the performance was 83.61 +/− 2.17% (Fig. 4c), and in the case of added Gaussian noise corresponding to a signal-to-noise ratio (SNR) of −11.8736 dB (see “Methods” for SNR calculations), the performance was 83.82 +/− 2.09% (Fig. 4d). Here, we conclude that the matching pursuit algorithm can have inherent errors in reconstruction, even without noise, but the reconstruction shows high resilience to Gaussian noise.

The 3D setup is a more complex case, as NVMM of a single neuron closely resembles not only neurons in the same lateral plane but also nearby neurons in multiple directions. Further, due to varying distance from the diamond NVC layer, neurons in the different axial planes have varying magnitudes of NVMMs. We show that such an ensemble of neurons can be reliably reconstructed (Fig. 4e, f). We found performances of 68.77% (+/−1.41) without noise (Fig. 4e) and 71.7281% (+/−1.1886) with Gaussian noise (Fig. 4f). Similar to the 2D case, 3D reconstruction is resilient to Gaussian noise at SNR −9.46 dB. However, a higher SNR ratio is needed to perform reconstruction in a 3D setup due to a more complex correlation structure in the columns of the dictionary. The overall detailed results of performance for the 2D and 3D cases, with and without noise, are provided in Supplementary Table 1.

To compare noise resilience in another method, we performed Moore–Penrose pseudoinverse57-based reconstruction of the same linear inverse problem in 3D setup (Supplementary Fig. 1). In pseudoinverse-based reconstruction, without noise reconstruction is 96.19%, but it shows high sensitivity to noise, as the performance drops to 20% and a very low fraction of detected spike instances. Due to high correlations in pairs of columns of the dictionary representing closely spaced neurons, the dictionary is an ill-conditioned matrix, and hence pseudoinverse solutions are highly sensitive to noise.

Based on the magnitude of the actual magnetic field, ideally, timepoint 3.0, 3.5, and 4.0 ms NVMMs should be used as the dictionary elements. The above frames contain the highest magnetic field signatures and are closest to the axon-hillock activity. Hence, initially, we performed 2D and 3D reconstruction simulations with these timepoints. Supplementary Table 2 contains the details of performance with the above timepoints (3, 3.5, and 4 ms) constituting the dictionary elements. While the 2D reconstruction was decent, the 3D reconstruction was not satisfactory. A critical difference in these set of time frames is the opposite directions of magnetic field signatures between NVMMs at 3 and 3.5 ms (Fig. 2). We believe that the algorithm, primarily in the 3D case, is sensitive to this directionality of the magnetic field (see Supplementary Note 2 for further discussion).

### Resolvability of spatially and temporally close distinct APs

The most important issue in reconstruction is the resolvability of spikes in nearby neurons (space) and time. The limits of resolvability or resolution of reconstruction would determine if single-cell resolution imaging can be performed with the proposed technique and algorithm. We analyze whether only two nearby neurons, separated by distances comparable to single soma size, ~10–20 μm, can be reconstructed by the algorithm. In the entire population of the 2D or 3D cases, only two nearby neurons are assigned one spike, each with a fixed time difference of Δt. Experimental time series for these two spike events are formed, and the algorithm is applied to reconstruct the spike times and location. Initially, no noise is added to the experimental time series. Also, the neurons are in the same geometric arrangement as shown for performance reconstruction (Fig. 4a, b).

Single best-reconstruction cases are shown for the 2D (Fig. 5a) and the 3D (Fig. 5b) cases. In the 2D case, cells separated by 20 μm and with spike-time differences of Δt = 1 ms are correctly reconstructed. Similarly, in a 3D case, an axial pair of neurons separated by 7 μm and with the spike time difference of Δt = 0.5 ms are accurately reconstructed.

To better understand the resolvability of nearby cells by the algorithm, we successively vary the lateral separation, the distance between two parallel neurons in the same plane (2D case), from 200 μm to 10 μm in steps of 10 μm with fixed Δt. These individual 20 experimental time series, with no noise added, form 20 different cases of reconstruction. Two different spike-time differences of Δt = 0.5 ms and Δt = 1 ms have been studied and represented in Fig. 5c, d, respectively. For each separation case, the locations of spiking neurons are marked by black vertical ticks. Cases of reconstruction where the spike timings of spike instances marked by the algorithm exactly match the spike timings of the actual case are shown by green ticks below the corresponding black ticks. Cases of reconstruction, where the algorithm marked an incorrect spike are shown with red ticks. Cases of reconstruction where the algorithm did not mark any spike instance are empty.

For Δt = 0.5 ms (Fig. 5c), we observe neurons separated by more than 130 μm are correctly reconstructed. However, when spiking neurons are brought closer in space, mostly spike instances are not marked by the algorithm or incorrectly marked by the algorithm. Nearby neurons have highly correlated dictionary elements, and experimental timepoint maps where activity from both neurons are present can resemble some other nearby neurons. Therefore, continuous stretches of p1 indices are not formed (see “Methods”—Algorithm), and hence, no spike instance or incorrect spike instances are marked by the algorithm. However, for one millisecond time difference cases (Fig. 5d), we observe correct reconstruction till the minimum separation of 20 μm. The lateral resolution in one millisecond case improves due to a lesser temporal overlap of NVMM signals of nearby neurons.

Further, we test the extent to which Gaussian noise can affect the above reconstruction cases of nearby neurons. The above reconstruction of two nearby neurons becomes stochastic by the addition of Gaussian noise to the experimental time series. Therefore, a minimum SNR is required for the algorithm to perform correct reconstructions, and a lower minimum SNR is an indicator of high resilience of reconstruction to Gaussian noise.

To estimate minimum SNR for the 2D (lateral separation) and 3D (axial separation) case, we perform multiple repetitions of reconstruction of two nearby neurons, as above (Fig. 5) but with added Gaussian noise to the experimental NVMM. To consider the worst-case scenario, the accuracy of reconstruction has been studied in the 2D case, for one spike each from two nearby neurons which are laterally separated by 10 μms and Δt = 0.5 ms. For the 3D case, one spike each from two nearby neurons which are axially separated by 7 μm and Δt = 0.5 ms. By varying levels of Gaussian noise factor, we vary SNR and simulate reconstruction (run algorithm) for 50 independent repetitions of the two-neuron case for both 2D and 3D. The minimum SNR is considered as a point where the standard deviation of reconstruction drops to zero (for these 50 repetitions). For each repetition, a correct reconstruction, where algorithm marks correctly the neuron and its spike time both, is given value 1 and 0 is given otherwise.

We observe decreasing standard error and increasing mean of correct classification percentage (average of individual 0/1 values) to 1 as the Gaussian noise factor decreases for 2D case (Fig. 6a). Similar trends are observed for the 3D case as well (Fig. 6b). The point of minimum SNR is marked as a dashed vertical line for both the 2D and 3D cases in Fig. 6a, b. Since the Gaussian noise factor is not linearly related to SNR (see the section “SNR calculations”), the actual mapping between them is shown in Fig. 6c for 2D case and Fig. 6d for the 3D case. We find −13.9 dB minimum SNR for the 2D case (at Gaussian noise factor = 0.0061) and −10.2 dB minimum SNR (at Gaussian noise factor = 0.0046) for the 3D case. A higher minimum SNR required for the axial case is due to more complex correlations of any single neuronal NVMM to other neuronal NVMMs in nearby volume as compared to a lesser number of nearby correlated neuronal NVMMs in a plane in the lateral case. We observed a clear certainty in individual events of reconstruction (for 50 repetitions) when the SNR is higher than the minimum SNR for both the lateral (Fig. 6e) and axial case (Fig. 6f).

A negative minimum SNR shows the high resilience of the proposed algorithm to Gaussian noise. Further, it implies that reconstruction might be possible in diamond NVC experiments with lower magnetic field sensitivity, where the noisy magnetic field data can be compensated with prior information based on the axon-hillock’s APMF signature in the dictionary.

While the experimental maps are expected to carry Gaussian noise, we also evaluate the above minimum SNR for shot noise dominated experimental maps. All analysis remains the same, but instead of Gaussian noise, shot noise is added to the experimental maps (see “Methods”). Supplementary Fig. 2 shows the results of the same analyses, but with added shot noise, as in Fig. 6, for reconstruction in shot noise-based experimental maps. Similar trends are observed for shot noise analysis. However, the minimum SNR required for shot noise maps is found to be significantly higher as compared to Gaussian noise maps. We find 14.08 dB minimum SNR for 2D case (at shot noise factor = 0.2001) and 20.18 dB minimum SNR (at shot noise factor = 0.1001) for the 3D case. The shot noise maps contain noise proportional to signal magnitude, having more jitter at high magnetic field values. Therefore, shot noise affects the overall features in the NVMMs and hence, requires more SNR to be able to reconstruct accurately. Further, the residual noise, if any, in shot noise maps are highly correlated to, in terms of features, to the neuron NVMM that was subtracted from the experimental time series. Therefore, it does not lead to the complete removal of a neuron’s signature from the experimental time series, even when a spike for that neuron has been assigned. This effect further imposes high SNR requirements for shot noise map reconstruction.

## Discussion

In this work, we first show that APMF of the axon hillock in mammalian neurons can serve as a specific signature for detecting spiking activity in single neurons in a 3D volume of brain tissue. Previously reported imaging APMF of entire worm axon or reconstructing current-carrying wires28,31,40,58 suggests the usage of entire axonal APMFs, which would render 3D magnetometry-based imaging near impossible because of routes and long lengths of axons in brain tissue. We have estimated the magnitude of mammalian pyramidal neuron APMF for the axon-hillock segment to be 36 pT, which is two orders of magnitude larger than other locations of a neuron. Such specific APMF signatures thus allow reconstruction of single-neuron activity in a 3D tissue. Based on recent experiments and theoretical advancements, we believe that sensitivities of widefield magnetic diamond NVC imager will be within reach to image APMF signals. We have developed and presented an algorithm to find neuronal spike timing and location from 2D NVMMs. We show it is possible to perform spike activity reconstruction of hundreds to thousands of neurons located in a 2D layer or 3D volume. We also show the spatiotemporal limits of correct reconstruction to be in line with near-simultaneous firing of spikes at single-cell spatial resolution, provided sufficient sensitivity in the experiment.

We highlight the Gaussian noise resilience of the algorithm proposed. In cases of Gaussian noise, where the minimum SNR required is low in the range of −10 dB to −20 dB, an experimental setup with sensitivity nearly equal to peak magnitude of APMF will be sufficient to reconstruct neuronal spiking activity. Therefore, in widefield diamond NVC experiments, where spatial resolution, temporal resolution, and sensitivity per pixel are tightly coupled, application of the proposed algorithm on larger pixels might allow same reconstruction accuracy but an increase in temporal resolution or higher sensitivity experiments.

The approximation that the pyramidal neuron which has complex 3D current-carrying wire-like geometry can be simplified to a small localized current-carrying region like axon hillock, has certain limitations. Under certain neuronal arrangements, the higher intra-axonal current advantage of axon hillock segments maybe lost due to their relatively far off distance as compared to axonal segments from the NVC sensor plane (further discussed in Supplementary Note 3).

Apart from the requirement that the axon hillock be located close to the NVC sensor plane, there are two other limitations to be considered, and be further developed in future work. The proposed algorithm performance has been demonstrated with only important axon-hillock timepoints (see “Results”, population performance) in the dictionary and experimental maps are based on only important axon hillock timepoints. Implementation of the proposed algorithm for all timepoints would require improvements to handle large NVMM time series. The proposed algorithm works for ~0.5–1 spikes per second per neuron, in the range of sparse spiking in the cortices. However, under stimulus-evoked conditions, the cortical neurons can exhibit a large range of firing 10–90 spikes per second per neuron. Such high number of simultaneous spikes in experimental time series would pose a limitation and arises primarily due to inherently high correlations in the columns of the dictionary corresponding to nearby location neurons (within ~100 μms). We suggest that global residual minimizers like convex optimization of l1 norm can be used to improve the current algorithm.

However, in a shot noise dominated regime, the information in signal patterns is significantly lost due to the addition of noise correlated to signal magnitude. In this regime, signal-to-noise amplitude ratio should be nearly 10, to achieve a decent reconstruction. This SNR requirement would demand a sub-picotesla DC diamond NVC magnetometry, which has not been demonstrated yet. However, new techniques, with genetic manipulations for specific enhancement of the axon-hillock-associated APMF or converting the axon hillock associated current to an AC magnetic field, which can be detected with AC magnetometry where much lower levels of detection is possible59,60,61,62, would allow single-cell resolution mapping of APMFs with currently available magnetometry techniques.

The AP magnetic field signal is ~2 ms in timescale, which will fall in DC signal range as compared to diamond NVC measurement protocol, which can span ~10–2000 μs in time depending upon the coherence time T2 on the sensor63,64. As demonstrated in the former sections on the reconstruction of spiking activity, we suggest that DC vector magnetometry at, at least ~1 $$pT\,\mu m^{ - \frac{3}{2}}\,{\mathrm{Hz}}^{ - \frac{1}{2}}$$ will be required to reach close to single-cell resolution spike detection, with our developed algorithm. In Barry et al.28, the authors demonstrated 34 $$nT\,\mu m^{ - \frac{3}{2}}\,{\mathrm{Hz}}^{ - \frac{1}{2}}$$ DC-field sensitivity and they expect a 100-fold improvement with engineered diamond, Ramsey protocol, and optimized collection methods. Additionally, NVC metrology related work58,60,65,66 suggests the use of advanced quantum manipulation methods to reach closer to the quantum projection noise limited DC magnetometry. For example, Liu et al.67 demonstrated Ancilla assisted sensing to increase DC-field sensitivity and also performed a rejection of 1/f low-frequency noise in DC magnetic field measurements. Sub-picotesla magnetometry has already been demonstrated for AC field sensing59. Various expected DC-field magnetometry64-related research expect the ensemble diamond NVC sensitivity to reach volume normalized picotesla levels, where we expect to see at least, blurred single neuronal APMF signatures.

Considering other magnetometers for widefield APMF measurement, optically pumped magnetometers and SQUID magnetometers are two regularly used magnetometers that are much more sensitive than NVC magnetometers. However, both these techniques are usually single-point magnetometers and are difficult to extend to widefield microscale magnetic field imaging.

## Methods

### Simulations of axonal currents in the pyramidal neuron model

A realistic neuronal model35 was implemented in NEURON and used to simulate the membrane potential. Here, we briefly describe the simulation of membrane potentials. The cable equation that governs membrane potential is:

$$\frac{1}{{2\pi a(r_i + r_o)}}\frac{{\partial ^2V_{\mathrm{m}}(z,t)}}{{\partial z^2}} = C_{\mathrm{m}}\frac{{\partial V_{\mathrm{m}}(z,t)}}{{\partial t}} + J_{{\mathrm{ion}}} - J_{\mathrm{m}}.$$
(3)

The discretized version of the equation was solved by implicit PDE solvers in NEURON. The temporal resolution of the voltage and current values available after the NEURON simulations was 10 μs. These data were imported and analyzed further in MATLAB (Mathworks) with custom written routines.

The pyramidal neuron used in the model has the following types of compartments: cell soma, axon hillock, action initial segment, unmyelinated region, and repeated regions of myelinated axon and node of Ranvier.

Intra-axonal current flowing across each segment of the neuron at a given time instant was calculated from the following equation:

$$i_{{\mathrm{compartment}},i}(t) = \frac{{V_{\mathrm{m}}\left( {i,t} \right) - V_{\mathrm{m}}(i - 1,t)}}{{r_i\frac{{dl}}{{\pi a^2}}}},$$
(4)

where i, i − 1 denote the adjacent segments of the neuron. ri, dl, and a are resistivity, length, and radius of the segment, respectively.

### Simulations of APMF magnitude and experimental 2D NVMMs

By application of Biot–Savart’s law, we calculated the magnetic field $${\vec{\mathbf{B}}}$$ at a measurement point $${\vec{\mathbf{r}}}$$ by summing over different segments n of the pyramidal neuron.

$${\vec{\mathbf{B}}}\left( {{\vec{\mathbf{r}}},t} \right) = \mathop {\sum}\limits_j^N {k\,i_j} \left( {\overrightarrow {{\mathbf{r}}_j} ,t} \right)\frac{{\overrightarrow {{\mathbf{dl}}_j} \,{\mathrm{X}}\,(\overrightarrow {{\mathbf{r}}_j} - {\vec{\mathbf{r}}})}}{{\left| {\overrightarrow {{\mathbf{r}}_j} - {\vec{\mathbf{r}}}} \right|^3}},\,{\mathrm{where}}\,{\vec{\mathbf{B}}}=\,[{\mathbf{B}}_{\mathbf{x}}\,{\mathbf{B}}_{\mathbf{y}}\,{\mathbf{B}}_{\mathbf{z}}]^{\mathrm{T}},$$
(5)

where $$\overrightarrow {{\mathbf{dl}}_j}$$ is a length vector along the segment, $$\overrightarrow {{\mathbf{r}}_j}$$ is the position vector of the segment j, $${\vec{\mathbf{r}}}$$ is the measurement point, $$i_j\left( {\overrightarrow {{\mathbf{r}}_j} ,t} \right)$$ is the current in the segment, $$k = \mu _o/4\pi$$, and the summation is over all segments $$j = 1,2,3 \ldots N$$ of the pyramidal neuron.

In order to estimate the magnitude of the mammalian APMF, a measurement point was selected perpendicularly below different segments of the pyramidal neuron at a standoff distance d from the centre of the compartment. The magnetic field at the measurement point was calculated by Eq. (5), above. APMF magnitudes at four different measurement points shown in Fig. 1e were selected as follows: perpendicularly below cell soma, below axon hillock, below longitudinal midpoint of the pyramidal neuron, and below the axon terminal end.

NVMMs are comprised of magnetic field values at multiple 2D spatial points calculated by varying the $${\vec{\mathbf{r}}}$$ vector (Eq. (5), above) at different points in the diamond NVC plane. NVMMs are 50 pixels × 100 pixels in size, with each pixel size equal to 20 μm × 20 μm. A time series of NVMMs are obtained by simulating the NVMM at different timepoints during AP propagation in the pyramidal neuron.

### Details of the proposed reconstruction algorithm

We solve for the inverse problem in Eq. (2), where B is the experimentally acquired 2D NVMM frames (with Gaussian noise or shot noise, see below in the section on Generation of spikes and time series of maps). For stating the linear inverse problem $$AX = B$$, we are treating A, B as scalar matrices. However, later while describing dot products of columns of A with any time instant of experimental map B, we refer to the notation Ai and Bt describing the vector nature of the magnetic field.

Mathematical symbols used to describe the algorithm are stated below:

1. 1.

$$p_{\mathrm{x}} = 100$$ number of pixels of the NVC sensor in the x direction

2. 2.

$$p_{\mathrm{y}} = 200$$ number of pixels of the NVC sensor in the y direction

3. 3.

$$n$$ number of neurons in 2D plane or 3D volume

4. 4.

$$n_{{\mathrm{tp}}}$$ number of AP timepoints considered in the reconstruction (set to 3)

5. 5.

$$A\,{\mathrm{dictionary}}\,{\mathrm{matrix}},\,{\mathrm{size}}\,3n_{{\mathrm{tp}}}p_{\mathrm{x}}p_{\mathrm{y}}\,X\,n$$ (factor of 3 for Bx, By, and Bz components)

6. 6.

$${\mathbf{A}}_i$$ columns of the dictionary of neuron i with the $$3n_{{\mathrm{tp}}}p_{\mathrm{x}}p_{\mathrm{y}}$$ elements after concatenation of each component of ntp timepoints. $$\widehat {{\mathbf{A}}_i}$$ denotes unit normalized vector form of Ai

7. 7.

$${\mathbf{B}}_t$$ concatenated experimental map at timepoint $$t,t - 1,\,t - 2 \ldots t - n_{tp} + 1$$, vector of length $$3n_{{\mathrm{tp}}}p_{\mathrm{x}}p_{\mathrm{y}}$$

8. 8.

$$T$$ is the threshold of projection value for detection of spiking. Threshold values of $$10^{ - 12}$$ and $$10^{ - 11}$$ were used for 3D and 2D cases, respectively.

9. 9.

$$I_{\mathrm{B}}$$ is a vector indicating the best-matched neuron index in every cycle of the algorithm, with values ranging from $$1$$ to $$n$$ or −1 (no match). IB is updated in different iterations of the algorithm with recursively changing experimental NVMMs.

10. 10.

$$p2$$ total number of successive spike-time event scan length for IB indices, set to 3

11. 11.

$$p1$$ minimum number of occurrences of a neuron required in successive $$p2$$ elements of the IB vector to be considered as a spike, set to 2

12. 12.

p running value of p1

13. 13.

Each column of Ai is set to $$| {\phi _j} \rangle$$, the NVMM of a particular neuron. This vector contains concatenated frames of multiple time instances (mainly corresponding to axon-hillock activity) and multiple directions ($${\mathbf{B}}_{\mathrm{x}}\,{\mathbf{B}}_{\mathrm{y}}\,{\mathbf{B}}_{\mathrm{z}}$$). Let $$t_1\,t_2\,t_3 \ldots \ldots \ldots \ldots \ldots ..\,t_n$$ be time instances of sampling. At each time t, we find resemblance of the experimental map to columns of the dictionary and assign the index of best-matched neuron to that time instant, accessed as $$I_{\mathrm{B}} (t)$$. element of $$I_{\mathrm{B}}$$.

Algorithm description as follows:

1. 1.

p = p2

2. 2.

While pp1

1. 2.1.

While (new spikes are detected in the previous cycle of the loop or initialization)

1. 2.1.1.

For loop (runs across timepoints for all experimental time instances or only specific time instances near last detected spike timepoint)

Comment 1: At each experimental timepoint t, find which neuron $$I_{\mathrm{B}}(t)$$ out of all neurons $$n$$ resembles most to the experiment map $${\mathbf{B}}_t$$

Comment 2: Also, the value of the projection on normalized dictionary elements must be greater than a certain threshold (T) for the neuron to be selected or else we place −1 at $$I_B(t)$$

1. 2.1.1.1.

if $$\max \left( {\widehat {{\mathbf{A}}_i}.{\mathbf{B}}_t} \right) \ge T$$, then $$I_{\mathrm{B}}\left( t \right) = k$$ = $$\begin{array}{*{20}{c}} {argmax} \\ i \end{array}\left( {\widehat {{\mathbf{A}}_i}.{\boldsymbol{B}}_t} \right)$$

else if $$\max \left( {\widehat {{\mathbf{A}}_i}.{\mathbf{B}}_t} \right) < T$$, then $$I_{\mathrm{B}}\left( t \right) = - 1$$

end

end loop

2. 2.1.2.

Find consecutive occurrences of neuron i in the vector IB for p times out of moving scan window of length p2

Comment 3: If we find p occurrences of a matched neuron (k) in a continuous stretch of p2 elements in $$I_{\mathrm{B}}$$, a spike of the neuron k is detected.

Comment 4: Precise timing of the kth neuron’s spike is determined by another search for time instant where subtracting k neuron’s signal leads to the maximum reduction in signal B. After subtracting Ak from the signal Bt for appropriate timepoints, $${\mathbf{B}}_t - {\mathbf{A}}_k$$, the residual is carried over as new signal B for the next iteration. Hence, we detect and subtract signatures of all spiking neurons one by one, at best timing location, until no further detection can be done, and the norm of a signal $$|\left| {\mathbf{B}} \right||$$ at each time instant is less than threshold T. Notably, there are three parameters, namely $${\rm{T}},\,p1\,{\mathrm{and}}\,p2$$ that control the output of the algorithm

3. 2.1.3.

On detection of a spike of neuron k find argument t0 that maximizes ($$\widehat {{\mathbf{A}}_k}.{\mathbf{B}}_{t_0},\,\,where\,t_0\,ranges\,from\,t - n_{tp}\,to\,t + n_{tp} - 1\,\& \,{\mathrm{only}}\,{\mathrm{where}}\,I_{\mathrm{B}}(t_0)\,{\mathrm{equals}}\,k$$). Here, t corresponds to the timepoint where regular occurrences of a particular neuron index were found in the last step.

4. 2.1.4.

Choose the argument of this maximum in 2.1.3 as spike timing tspike of neuron k followed by subtraction of signature of this spike from the experimental map as described in comment 4. Set $${\mathbf{B}}_t = {\mathbf{B}}_t - {\mathbf{A}}_k$$ and record spike of neuron k at tspike time instant.

Comment 5: After subtracting NVMM corresponding to a particular spike of a neuron, when we go to recalculation of IB from the new experimental map, we do not evaluate IB indices over all timepoints of the experiment. We revaluate IB only within the timepoints which have changed due to the subtraction of NVMM of the last spiking neuron.

End of 2.1 While loop.

3. 3.

Decrement p = p−1

End of 2. While loop

### Running algorithm and setup of dictionary

The algorithm was quantified in two different cases—2D case, where the neurons are located in a plane parallel to the diamond NVC layer, and a 3D case, where the neurons were distributed in 3D volume, randomly oriented, mounted over a diamond NVC layer. In the 2D case, the dictionary matrix is comprised of individual NVMMs of 80 neurons laterally shifted by 20 microns. In the 3D case, there are total 6250 different NVMMs from randomly oriented neurons in the 3D volume of 1 mm × 2 mm × 70 μm. The placement of cell somas/axon hillocks was done in a grid-like manner by placing 25 × 25 neurons in each plane parallel to diamond NVC layer, and stacks of ten such planes with varying perpendicular distance, z coordinate, from the diamond NVC layer. The spatial resolution of this grid was 40 μm × 40 μm × 7 μm in X, Y, and Z, respectively. After the placement of cell soma, the direction of the neuron was randomly chosen from ten different orientation angles between 0 to 90°. The corresponding NVMMs were added to the 3D case dictionary.

The experimental map was constructed as a convolution of the spike timing vector and individual NVMMs time series. The timing resolution was kept at 0.5 ms, and the total simulation time was set to 600 ms. Spike timing was assigned by the method specified in the next section.

### Generation of neuronal spikes and time series of maps

The probability of spike of a neuron at a time instance is given by f, a factor that controls the spatial and temporal density of firing. Higher f will lead to more spatially and temporally sparse firing. For each neuron, f is a binomial probability. At each time instant, we generate a uniform random number ri ranging between 0 and 1 for each neuron i. A spike occurs in neuron i, if ri > f. Thus, the spike times of each neuron are independent of each other. After assigning spikes by the above-stated method, for each neuron, to simulate a refractory period44,46, a neuron is not allowed to spike for a period of 5 ms following a spike. The factor f for the 2D case was adjusted to be 0.994 and for the 3D case to be 0.9996 so that sparse firing in the population, as in the cortex is observed68.

For 3D performance, some additional spike times, other than multiple spikes within the refractory period, were removed before applying the algorithm. Spikes of neurons of following two types in the 6250 element 3D Dictionary (see the section “Running algorithm”) were removed, and hence these neurons produce no spikes.

Type 1—A neuron whose RMS value of 1D vector (concatenated 2D NVMM) element in the dictionary is less than the threshold (1 pT for 3D case). If we assign spikes to these neurons, they are always rejected in the threshold step of the first iteration itself while running the proposed algorithm. Hence, spikes of these neurons are pre-removed before running the algorithm.

Type 2—2D NVMMs were generated by summing neuronal intra-axonal currents in Bio–Savart expression for each z plane and a random orientation (see the section “Running algorithm”). However, for each z plane and orientation angle, the XY grid was simulated by translation of the map along x and y axis. In this translation, some neurons can be shifted to the extent that the axon-hillock-related signatures do not fall directly above the diamond NVC layer. Hence, these neurons lack important axon hillock patterns in their NVMMs and are significantly less in their RMS values (in agreement with high axon-hillock contribution). Spikes of these neurons are removed, as they are never detected by the algorithm. In this dataset of 3D dictionary generation, these neurons are ~40% in number.

Type 1 and Type 2 have a large number of common neurons, whose axon-hillock segments are displaced off the NVC layer. Only their long axonal parts fall perpendicularly over the diamond NVC layer.

However, their individual 2DNVMs of both types are always present in the dictionary during the run of the proposed algorithm.

### SNR calculations

We add Gaussian or shot noise to the experimental time series of NVMMs in the following manner:

$${\mathbf{S}} = [{\mathbf{B}}_t\,{\mathbf{B}}_{t + 1}\,{\mathbf{B}}_{t + 2}\, \ldots ]$$ is the concatenated 1D vector of all 1D $${\mathbf{B}}_t$$ experimental maps at different timepoints

Snoise is the 1D vector with noise added to each element of vector S

η is Gaussian or shot noise factor

randn MATLAB function was used to generate a Gaussian random variable with zero mean and standard deviation 1

rms(S) root-mean square of all elements of vector S

For Gaussian noise, each element of Snoise is given by

$${\mathbf{S}}_i^{{\mathrm{noise}}} = {\mathbf{S}}_i + \eta \ast rms({\mathbf{S}}) \ast randn.$$
(6)

For shot noise, each element of Snoise is given by

$${\mathbf{S}}_i^{{\mathrm{noise}}} = {\mathbf{S}}_i + \eta \ast \left| {{\mathbf{S}}_i} \right| \ast randn.$$
(7)

SNR is given by

$$SNR = 20 \ast \log _{10}\frac{{rms({\mathbf{S}})}}{{rms({\mathbf{S}}^{{\mathrm{noise}}} - {\mathbf{S}})}}.$$
(8)

To be noted, shot noise maps are dependent on per pixel magnitude, $$\left| {{\mathbf{S}}_i} \right|$$ and hence, perturb the experimental maps more at pixels where magnetic field is high. However, Gaussian noise maps get the same standard deviation noise added depending on the term rms(S), which remains constant for different elements $${\mathbf{S}}_i^{{\mathrm{noise}}}$$ of vector Snoise. Also, noise factor values for lateral and axial cases in experimental maps can not be directly compared, but their SNR values can be compared.

## Data availability

The datasets generated during and/or analyzed during this study are available from the corresponding author on reasonable request. The pyramidal neuron computational model35 used in this study is available at ModelDB Accession code: 123897.

## Code availability

MATLAB codes for data processing, analysis, and algorithm implementation performed in this study are available from the corresponding author on reasonable request.

## References

1. 1.

Denk, W., Strickler, J. H. & Webb, W. W. Two-photon laser scanning fluorescence microscopy. Science 248, 73–76 (1990).

2. 2.

Grewe, B. F., Langer, D., Kasper, H., Kampa, B. M. & Helmchen, F. High-speed in vivo calcium imaging reveals neuronal network activity with near-millisecond precision. Nat. Methods 7, 399–405 (2010).

3. 3.

Grienberger, C. & Konnerth, A. Imaging calcium in neurons. Neuron 73, 862–885 (2012).

4. 4.

Stosiek, C., Garaschuk, O., Holthoff, K. & Konnerth, A. In vivo two-photon calcium imaging of neuronal networks. Proc. Natl Acad. Sci. USA 100, 7319–7324 (2003).

5. 5.

Nikolenko, V., Poskanzer, K. E. & Yuste, R. Two-photon photostimulation and imaging of neural circuits. Nat. Methods 4, 943–950 (2007).

6. 6.

Keck, T. et al. Massive restructuring of neuronal circuits during functional reorganization of adult visual cortex. Nat. Neurosci. 11, 1162–1167 (2008).

7. 7.

Cocas, L. A. et al. Cell type-specific circuit mapping reveals the presynaptic connectivity of developing cortical circuits. J. Neurosci. 36, 3378–3390 (2016).

8. 8.

Moore, A. K., Weible, A. P., Balmer, T. S., Trussell, L. O. & Wehr, M. Rapid rebalancing of excitation and inhibition by cortical circuitry. Neuron 97, 1341–1355 (2018). e6.

9. 9.

Wimmer, R. D. et al. Thalamic control of sensory selection in divided attention. Nature 526, 705–709 (2015).

10. 10.

Pinto, L. & Dan, Y. Cell-type-specific activity in prefrontal cortex during goal-directed behavior. Neuron 87, 437–450 (2015).

11. 11.

Okun, M. et al. Diverse coupling of neurons to populations in sensory cortex. Nature 521, 511–515 (2015).

12. 12.

Wu, J. et al. Kilohertz two-photon fluorescence microscopy imaging of neural activity in vivo. Nat. Methods 17, 287–290 (2020).

13. 13.

Kazemipour, A. et al. Kilohertz frame-rate two-photon tomography. Nat. Methods 16, 778–786 (2019).

14. 14.

Taylor, J. M. et al. High-sensitivity diamond magnetometer with nanoscale resolution. Nat. Phys. 4, 810–816 (2008).

15. 15.

Jelezko, F. & Wrachtrup, J. Single defect centres in diamond: a review. Phys. Status Solidi Appl. Mater. Sci. 203, 3207–3225 (2006).

16. 16.

Lillie, S. E. et al. Laser modulation of superconductivity in a cryogenic wide-field nitrogen-vacancy microscope. Nano Lett. 20, 1855–1861 (2020).

17. 17.

Tetienne, J. P. et al. Quantum imaging of current flow in graphene. Sci. Adv. https://doi.org/10.1126/sciadv.1602429 (2017).

18. 18.

Lillie, S. E. et al. Imaging graphene field-effect transistors on diamond using nitrogen-vacancy microscopy. Phys. Rev. Appl. https://doi.org/10.1103/PhysRevApplied.12.024018 (2019).

19. 19.

Glenn, D. R. et al. Micrometer-scale magnetic imaging of geological samples using a quantum diamond microscope. Geochem., Geophys. Geosyst. 18, 3254–3267 (2017).

20. 20.

Davis, H. C. et al. Mapping the microscale origins of magnetic resonance image contrast with subcellular diamond magnetometry. Nat. Commun. 9, 1–9 (2018).

21. 21.

Le Sage, D. et al. Optical magnetic imaging of living cells. Nature 496, 486–489 (2013).

22. 22.

Hai, A. & Jasanoff, A. Molecular fMRI. Brain Mapp. Encycl. Ref. 1, 123–129 (2015).

23. 23.

Okada, S. et al. Calcium-dependent molecular fMRI using a magnetic nanosensor. Nat. Nanotechnol. 13, 473–477 (2018).

24. 24.

Balasubramanian, G. et al. Nanoscale imaging magnetometry with diamond spins under ambient conditions. Nature 455, 648–651 (2008).

25. 25.

Barson, M. S. J. et al. Nanomechanical sensing using spins in diamond. Nano Lett. 17, 1496–1503 (2017).

26. 26.

Gaebel, T. et al. Room-temperature coherent coupling of single spins in diamond. Nat. Phys. 2, 408–413 (2006).

27. 27.

Specht, C. G., Williams, O. A., Jackman, R. B. & Schoepfer, R. Ordered growth of neurons on diamond. Biomaterials 25, 4073–4078 (2004).

28. 28.

Barry, J. F. et al. Optical magnetic detection of single-neuron action potentials using quantum defects in diamond. Proc. Natl Acad. Sci. USA 113, 14133–14138 (2016).

29. 29.

Rondin, L. et al. Magnetometry with nitrogen-vacancy defects in diamond. Rep. Prog. Phys. https://doi.org/10.1088/0034-4885/77/5/056503 (2014).

30. 30.

Schloss, J. M., Barry, J. F., Turner, M. J. & Walsworth, R. L. Simultaneous broadband vector magnetometry using solid-state spins. Phys. Rev. Appl. 10, 034044 (2018). .

31. 31.

Karadas, M. et al. Feasibility and resolution limits of opto-magnetic imaging of neural network activity in brain slices using color centers in diamond. Sci. Rep. 8, 1–14 (2018).

32. 32.

Roth, B. J., Sepulveda, N. G. & Wikswo, J. P. Using a magnetometer to image a two-dimensional current distribution. J. Appl. Phys. 65, 361–372 (1989).

33. 33.

Clark, J. & Plonsey, R. A mathematical evaluation of the core conductor model. Biophys. J. 6, 95–112 (1966).

34. 34.

Tan, S., Roth, B. J. & Wikswo, J. P. The magnetic field of cortical current sources: the application of a spatial filtering model to the forward and inverse problems. Electroencephalogr. Clin. Neurophysiol. 76, 73–85 (1990).

35. 35.

Hu, W. et al. Distinct contributions of Nav1.6 and Nav1.2 in action potential initiation and backpropagation. Nat. Neurosci. 12, 996–1002 (2009).

36. 36.

Tropp, J. A. & Wright, S. J. Computational methods for sparse solution of linear inverse problems. Proc. IEEE 98, 948–958 (2010).

37. 37.

Tropp, J. & Gilbert, A. Signal recovery from partial information via orthogonal matching pursuit. IEEE Trans. Inform. Theory 53, 4655–4666 (2007).

38. 38.

Cotter, S. F., Rao, B. D. & Kreutz-Delgado, K. Sparse solutions to linear inverse problems with multiple measurement vectors. IEEE Trans. Signal Process. 53, 2477–2488 (2005).

39. 39.

Mallat, S. G. & Zhang, Z. Matching pursuits with time-frequency dictionaries. IEEE Trans. Signal Process. 41, 3397–3415 (1993).

40. 40.

Hall, L. T. et al. High spatial and temporal resolution wide-field imaging of neuron activity using quantum NV-diamond. Sci. Rep. 2, 1–9 (2012).

41. 41.

Blagoev, K. B. et al. Modelling the magnetic signature of neuronal tissue. Neuroimage 37, 137–148 (2007).

42. 42.

Rall, W. Electrophysiology of a dendritic neuron model. Biophys. J. https://doi.org/10.1016/S0006-3495(62)86953-7 (1962).

43. 43.

Rall, W. Theory of physiological properties of dendrites. Ann. N. Y. Acad. Sci. 96, 1071–1092 (1962).

44. 44.

Dayan, Peter, and L. F. Abbott. Theoretical Neuroscience: Computational and Mathematical Modeling of Neural Systems (Massachusetts Institute of Technology Press, Cambridge, MA, 2001).

45. 45.

Hines, M. L. & Carnevale, N. T. The NEURON simulation environment. Neural Comput. 9, 1179–1209 (1997).

46. 46.

The MathWorks, Inc. MATLAB Release 2016a (The MathWorks, Inc., Natick, MA). https://www.mathworks.com/.

47. 47.

Swinney, K. R. & Wikswo, J. P. A calculation of the magnetic field of a nerve action potential. Biophys. J. 32, 719–731 (1980).

48. 48.

Clark, J. & Plonsey, R. The extracellular potential field of the single active nerve fiber in a volume conductor. Biophys. J. 8, 842–864 (1968).

49. 49.

Wikswo, J. P., Barach, J. P. & Freeman, J. A. Magnetic field of a nerve impulse: first measurements. Science 208, 53–55 (1980).

50. 50.

Barach, J. P., Freeman, J. A. & Wikswo, J. P. Experiments on the magnetic field of nerve action potentials. J. Appl. Phys. 51, 4532–4538 (1980).

51. 51.

Hellerstein, D. Passive membrane potentials: a generalization of the theory of electrotonus. Biophys. J. 8, 358–379 (1968).

52. 52.

Lewicki, M. S. Efficient coding of natural sounds. Nat. Neurosci. 5, 356–363 (2002).

53. 53.

Smith, E. C. & Lewicki, M. S. Efficient auditory coding. Nature 439, 978–982 (2006).

54. 54.

Smith, E. & Lewicki, M. S. Efficient coding of time-relative structure using spikes. Neural Comput. 17, 19–45 (2005).

55. 55.

Wu, S. C. & Swindlehurst, A. L. EEG/MEG source localization using source deflated matching pursuit. Annu. Int. Conf. IEEE Eng. Med. Biol. Soc. 2011, 6572–6575 (2011).

56. 56.

Green, D. G. & Swets, J. A. Signal Detection Theory and Psychophysics (John Wiley and Sons Inc. Wiley & Sons, Inc., New York, NY, 1966).

57. 57.

Barata, J. C. A. & Hussein, M. S. The Moore-Penrose pseudoinverse: a tutorial review of the theory. Braz. J. Phys. 42, 146–165 (2012).

58. 58.

Cooper, A., Magesan, E., Yum, H. N. & Cappellaro, P. Time-resolved magnetic sensing with electronic spins in diamond. Nat. Commun. https://doi.org/10.1038/ncomms4141 (2014).

59. 59.

Wolf, T. et al. Subpicotesla diamond magnetometry. Phys. Rev. X 5, 1–10 (2015).

60. 60.

Degen, C. L., Reinhard, F. & Cappellaro, P. Quantum sensing. Rev. Mod. Phys. 89, 1–39 (2017).

61. 61.

Hirose, M. & Cappellaro, P. Coherent feedback control of a single qubit in diamond. Nature 532, 77–80 (2016).

62. 62.

Boss, J. M., Cujia, K. S., Zopes, J. & Degen, C. L. Quantum sensing with arbitrary frequency resolution. Science 356, 837–840 (2017).

63. 63.

Stanwix, P. L. et al. Coherence of nitrogen-gvacancy electronic spin ensembles in diamond. Phys. Rev. B - Condens. Matter Mater. Phys. 82, 7–10 (2010).

64. 64.

Barry, J. F. et al. Sensitivity optimization for NV-diamond magnetometry. Rev. Mod. Phys. https://doi.org/10.1103/RevModPhys.92.015004 (2020).

65. 65.

Magesan, E., Cooper, A. & Cappellaro, P. Compressing measurements in quantum dynamic parameter estimation. Phys. Rev. A 88, 062109 (2013).

66. 66.

Arai, K. et al. Fourier magnetic imaging with nanoscale resolution and compressed sensing speed-up using electronic spins in diamond. Nat. Nanotechnol. 10, 859–864 (2015).

67. 67.

Liu, Y. X., Ajoy, A. & Cappellaro, P. Nanoscale vector dc magnetometry via ancilla-assisted frequency up-conversion. Phys. Rev. Lett. https://doi.org/10.1103/PhysRevLett.122.100501 (2019).

68. 68.

Barth, A. L. & Poulet, J. F. A. Experimental evidence for sparse firing in the neocortex. Trends Neurosci. 35, 345–355 (2012).

## Acknowledgements

M.P. thanks MHRD for Institute Fellowship and PMRF, K.S. acknowledges support from IITB-IRCC Seed grant number 17IRCCSG009, DST Inspire Faculty Fellowship - DST/INSPIRE/04/2016/002284 and AOARD R&D Grant No. FA2386-19-1-4042. S.B. thanks MHRD and IIT Kharagpur for Challenge Grant Scheme Grant No. SGIGC/2015/DMN and India Alliance for Intermediate Fellowship funding Grant No. IA/I/11/2500270.

## Author information

Authors

### Contributions

M.P., K.S., and S.B. conceived the project, S.B. and K.S. supervised the work, M.P. did all simulations and analyses and M.P. and S.B. wrote the paper in discussion with K.S.

### Corresponding authors

Correspondence to Kasturi Saha or Sharba Bandyopadhyay.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

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

## Rights and permissions

Reprints and Permissions

Parashar, M., Saha, K. & Bandyopadhyay, S. Axon hillock currents enable single-neuron-resolved 3D reconstruction using diamond nitrogen-vacancy magnetometry. Commun Phys 3, 174 (2020). https://doi.org/10.1038/s42005-020-00439-6

• Accepted:

• Published:

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