Computers and Electronics in Agriculture Recording the heart beat of cattle using a gradiometer system of optically pumped magnetometers

Monitoring of heart rate has the potential to provide excellent data for the remote monitoring of animals, and heart rate has been associated with stress, pyrexia, pain and illness in animals. However monitoring of heart rate in domesticated animals is di ﬃ cult as it entails the restraint of the animal (which may in turn a ﬀ ect heart rate), and the application of complex monitoring equipment that is either invasive or not practical to implement under commercial farm conditions. Therefore accurate non-invasive automated remote monitoring of heart rate has not been possible in domesticated animals. Biomagnetism associated with muscle and nerve action provides a promising emerging ﬁ eld in medical sensing, but it is currently con ﬁ ned to magnetically-shielded clinical en- vironments. In this study, we use biomagnetic sensing on commercial dairy cattle under farm conditions as a model system to show proof-of-principle for non-contact magnetocardiography (MCG) outside a controlled la- boratory environment. By arranging magnetometers in a di ﬀ erential set-up and using purpose-built low-noise electronics, we are able to suppress common mode noise and successfully record the heart rate, the heart beat intervals and the heart beat amplitude. Comparing the MCG signal with simultaneous data recorded using a conventional electrocardiogram (ECG) allowed alignment of the two signals, and was able to match features of the ECG including the P-wave, the QRS complex and the T-wave. This study has shown the potential for MCG to be developed as a non-contact method for the assessment of heart rate and other cardiac attributes in adult dairy cattle. Whilst this study using an animal model showed the capabilities of un-shielded MCG, these techniques also suggest potentially exciting opportunities in human cardiac medicine outside hospital environments.


Introduction
During the course of the 21st century, the use of animals for laboratory experimentation has come under increasing scrutiny from outside the research community (Cyranoski, 2006), but also in an increasing debate inside it (Abbott, 2018). This trend is mirrored by increasing awareness of ethical treatment of animals used in food production (Eisler et al., 2014;LeBlanc, 2014). While there remains in the public perception of farming a concept of a rural idyll involving a close relation between the farmer and the animals, we have come to understand that close human contact to animals is not necessarily a beneficial factor (Rossi et al., 2017). These findings put considerable pressure on producers to invest in remote-monitoring of farm animals to provide evidence of good treatment (Grandin, 2014). Automated remote monitoring of cows has therefore become widespread on commercial dairy units, with the use of accelerometer-based technologies to enhance oestrus detection available since the 1990s. Automated systems have also been developed for the monitoring of rumen pH, rumen temperature, body temperature, and behavioural monitoring for the early detection of disease.
Seeking physiological parameters that allow a close assessment of animal wellbeing have identified the animals' heart beat as a parameter to monitor and analyse through automated systems (Kezer et al., 2017;von Borell et al., 2007). Heart rate has been associated with stress, pyrexia, pain and illness in animals. In addition, measurement of heart rate variability has been used as an indicator of stress, and a proxy measure of welfare in cattle. However monitoring of heart rate in domesticated animals is difficult as it entails the restraint of the animal which may in turn affect heart rate (Stucke et al., 2015), and the application of monitoring equipment that is either invasive or not practical to implement under commercial farm conditions. Therefore as far as the authors are aware, accurate non-invasive automated remote monitoring of heart rate has not been possible in domesticated animals.
There is a clear need for simple, robust non-contact sensing technology to obtain a welfare score for any given animal (Grandin, 2014). Sensors to read these data could be mounted at voluntary animal interaction points such as milking robots, to ensure recording free from human intervention.
The electric signal of the heart muscle excitation and relaxation also generates a magnetic field. Measuring the magnetic field to obtain heart beat information avoids the need for contact electrodes like those used in electrocardiograms (ECG). Non-contact recording of the heart beat characteristics will open opportunities for comfortable long-term heart monitoring or swift and easy emergency heart signal reading. To show proof-of-concept, we use an animal model system. Rather than using laboratory animals, we develop a system that could also be used in a commercial farming environment. In farm animals, non-contact heart sensing would prove also very beneficial. Recording an ECG on animals comes with challenges in applying the electrodes to the animal's skin. Shaving is often required to obtain good contact. Furthermore, in large animals, tissue between the electrode and the heart muscle leads to considerable animal to animal variations (Cedeño-Quevedo et al., 2016) and to signal distortions (DeRoth, 1980). Nevertheless good diagnostics might still be achieved (Konold et al., 2011) and while the ECG amplitude might have no physiological meaning, the heart rate obtained can still provide a reference to the MCG readings. Recording an MCG circumvents the challenges encountered by ECG measurement by not relying on charge collection by contact electrodes, which opens opportunities for remote monitoring techniques not requiring human operators.
Among the most sensitive methods for reading magnetic field strength and orientation are instruments using the interaction of resonant light with atomic vapour: optically pumped magnetometers (OPMs) (Budker and Romalis, 2007). Recent work on the identification of optimum sensor positioning has shown that a wide range of heart beat characteristics, such as the spatial and temporal magnetic signature of the heart action, are becoming measurable with OPMs (Lau et al., 2016). While initial devices required the heating of sensor components to temperatures well beyond human or animal body temperatures, it is now possible to work with vapour cells at or close to body temperature (Morales et al., 2017). Improvements in the design of OPMs have reached a stage where the recording the magnetic component of single animal nerve impulses is possible in vitro (Jensen et al., 2016) and most recently could be shown in vivo (Broser et al., 2018).
Using sensors in gradiometric arrays to compensate ambient noise sources provides an excellent tool to record small, dynamic magnetic fields and it has been widely used to record and map magnetic field changes. Magnetocardiography has been successfully shown with gradiometric configurations (Morales et al., 2017) and can provide information inaccessible to electrocardiographic recordings (Ikefuji et al., 2007). MCGs have been shown to provide rich diagnostic information when using arrays of sensors (Kimura et al., 2017). Optically pumped magnetometers have been successfully applied to the recording of small-animal magnetoencephalograms (MEG) (Nishi et al., 2018), demonstrating the potential of magnetometry in the veterinary field.
The aim of this study was to assess the feasibility of obtaining accurate unshielded heart measurements with total field magnetometers in animal monitoring, using commercial dairy cattle. By demonstrating the possibilities of this technique for non-contact heart monitoring, it also opens up potential applications for human health outside of controlled clinical environments.

Materials and methods
Research animals: All animal work was approved by the Royal (Dick) School of Veterinary Studies Veterinary Ethical Review Committee (Ref 42.18). Adult non-lactating Holstein dairy cows were positioned in a metal restraining crate. Cows' heart beats were recorded in the teaching barn of the University of Edinburgh's Royal (Dick) School of Veterinary Sciences' dairy campus at Langhill Farm (Roslin, UK) (Fig. 1). The two sensors of the magnetic gradiometer axis were positioned in line with the main electrical dipole of the animal's heart.
Magnetometers: The QuSpin QTFM® (QuSpin, Colorado, USA) sensors used in this measurement are based on an optically pumped Mz magnetometer configuration, which allows high-sensitivity measurements of magnetic field magnitude to be carried out in the presence of the geophysical field. The manufacturer's specification for the QTFM sensor advertises a white noise floor of~1pT.Hz-1/2 with a bandwidth of 200 Hz and a maximum sampling rate of 407 Hz. The sensitivity of this magnetometer is highly dependent on the orientation of the ambient magnetic field. For this reason, a calibrated set of Helmholtz coils was incorporated into each sensor module, to ensure that the sensor is operated in its highest sensitivity field orientation. The bias field coils were designed for the smallest fit around the sensor and wound on 3D printed housing with 0.5 mm copper cable. The operating electronics were designed with a particular focus on low noise recording and timing stability (Ingleby et al., 2017).
Field Control: The static background field is aligned to the sensitive axis of the magnetometers using fitting algorithms (Ingleby et al., 2017). Four cycles of parabolic fits to minimize orthogonal field components ensured good conversion of the current values required to align the ambient field.
ECG: The electrocardiograms were recorded using a Televet-100 (Kruuse, Langeskov, Denmark) recording at 500 Hz in an Einthoven configuration (Hannibal, 2011) using standard sticky gel electrode attached to shaved skin areas.
MCG: The sensors were used in a gradiometric set-up. The position of both sensors was mechanically adjusted so that their sensitive axis are aligned and so that they are within~20°in line with the magnetic background. Then a fitting algorithm was used to adjust the current to the Helmholtz coils to precisely line up the ambient field to the sensitive axis of both sensors. The cow's heart signal acts as a perturbation of the ambient field and can be picked up in the difference trace between the two sensors. Measurements were done in intervals of either 10 or 20 s in consecutive recordings. Longer recordings of 60 s proved undesirable since the movement of the animal could be compensated for Fig. 1. Non-contact heart recording: Two magnetometers were placed either side of the animal so that an imaginary axis passed through the heart muscle. Simultaneously an ECG was recorded. One magnetic sensor can be seen in front of the animal placed slightly back of the fore leg and below the heart. in data post processing more easily in shorter intervals.
Motion Compensation: Movement of the animal during the recording leads to baseline fluctuations in the magnetic recording. These fluctuations were compensated for through spline fitting in data postprocessing to obtain a flat base line for further data analysis.
Temporal alignment of ECG & MCG: Time stamping of the ECG and the MCG recordings allowed temporal alignment of the two traces to within the same heart beat interval. Then the spike of the QRS complex within the heart actions was used for fine alignment.
Heart rate correlation search: The key characteristic to obtain is the heart rate for physiological assessment. To be able to detect variations in the heart rate, it is necessary to determine the heart rate from measurement intervals of short duration. In post-processing, we filtered differential data traces of 10 s duration with pass band 0.11 Hz to 45 Hz. On each filtered trace, we conducted an automated correlation search for recurring signal features between 1 and 2 Hz corresponding to heart rates between 60 and 120 beats per minute. The heart rate was detected as a distinctive peak in the frequency spectrum of the correlation search (Appendix Figure A1). The example shows a heart rate of 79 beats per minute showing as a distinctive peak in the frequency spectrum of the correlation search. The retrieved heart beats were assessed against independent recordings by measuring the tail pulse, taking a stethoscope reading of the heart rate or against ECG recordings (Kruuse Televet 100, Kruuse, Langeskov, Denmark).
We found good correlation between the MCG data and the true heart rate. Using short measurement intervals of 10 s enables a string of several independent recordings to be taken per animal. This allows discarding of recordings spoiled by vigorous animal movement while still retrieving and subsequently verifying the correct heart rate from several short independent readings.
Sensor arrangement and Active Field Control: The QTFM is an optically pumped magnetometer (OPM) operating in Mz configuration (Bloom, 1962) and relies on measuring of Larmor spin precession frequency of 87Rb atoms. The value of the ambient magnetic field is derived from the fixed relationship between Larmor frequency and magnetic field.
The QTFM magnetometer has four main components: (i) a laser which generates 795 nm light resonant with the D1 optical transition of 87Rb, (ii) a glass vapor cell containing 87Rb atoms, (iii) a photodetector to monitor light transmitted through the vapor cell, (iv) and an RF coil to excite Larmor precession in rubidium atoms. The circularly polarized laser light passes through the vapor cell and spin-polarizes the rubidium atoms inside. When the atoms are spin-polarized, the amount of laser light transmitted through the vapor cell increases. After spin polarization, the frequency of the oscillating field created by the RF coil is swept from 20 kHz to 600 kHz using a direct digital frequency synthesizer (DDS). When the RF frequency matches the Larmor frequency, the amount of light transmitted through the vapor cell drops, this drop in light transmittance is used to identify the Larmor frequency. Once identified, the scanning stops, and the DDS frequency is electronically locked over the Mz resonance using a lock-in detection technique. The digitally locked frequency of the DDS is then digitally transmitted as the output of the magnetometer. A front-end user interface converts the DDS frequency to magnetic field units.

Results
The geomagnetic background in the teaching barn was measured using a Bartington Mag13-MS100 Fluxgate magnetometer (Bartington, Witney, UK) and found to be around 42 µT at an angle of about 70°to the surface. The orientation of the teaching shed and the placement of the cow holding pens within resulted in an angle of the horizontal component of the Earth's field to the length axis of the holding pen of about 80°. The background field showed strong interference from 50 Hz mains power lines and various electrical appliances. The sensitive axes of the two sensors were carefully aligned to ensure gradiometric configuration. Furthermore the sensors were placed roughly in line with the geomagnetic background field with one sensor low on the left forequarter of the animal and the second sensor opposite above the animal creating a virtual line through the heart muscle. The correlation search for the heart rate yields the duration of a single heart action (Appendix Figure A1). Using this interval we obtained the magnetic amplitude trace of the heart action by averaging over the heart beats within a data sequence. This allows the identification of characteristic elements as the P-wave, the QRS complex and the T-wave (Fig. 2).
Physiological Relevance: To assess our recordings for their physiological relevance, we compared the heart action durations with proven recordings. The action of the heart muscle is determined by electrical conduction along specialized tissue thus generating a characteristic sequence of heart actions. While the electrical amplitude of a cow's heart action can be considerably distorted by surrounding tissue that the signal has to pass before reaching the pickup electrode, the time intervals of the cow's heart action are well conserved over a multitude of animals. On a sample of 32 animals using a 12-lead ECG system to ensure good data quality, DeRoth showed that the heart action timing is highly conserved between different animals (DeRoth, 1980).
A magnetic recording of a cow's heart beat reproduces the characteristic time intervals as shown in these ECG references (Table Fig. 3(a)). We find the length of the P-wave indicating atrial action can be measured to a very similar length with an ECG recording yielding 100 +/-11 ms compared to 125 ms for the MCG. Similarly the total PR segment is a relatively good match at 100 +/-18 ms for the ECG and 125 ms for the MCG. At current the QRS complex tends to be stretched on the time axis due to the averaging process employed in the MCG.
We recorded ECG data using three channels in the Einthoven configuration (Hannibal, 2011) and matched the signal to the MCG (Fig. 3b). Aligning the signals from the ECG traces with the MCG signal shows matching features in the P-wave, the QRS complex and the Twave. The amplitudes of the ECGs and the MCG are in good agreement with theoretical calculations (Alday et al., 2016) suggesting that an electrical signal of 0.5 mV in the ECG should generate a magnetic signal around 100 pT in the MCG. We find a spike in the QRS complex of 4.2 mV matching a spike in the MCG of 700 pT. It must be noted that the amplitude of the spike in the ECG depends heavily on the placement The QTFM sensor shows an anisotropic sensitivity under varying static field orientations. The sensitivity will exhibit cosine squared dependence with the declination of the static field relative to the QTFM's sensitive axis. Fig. 4(a) shows the calculated variation of sensitivity with the field orientation. To adjust the ambient field to the sensor's sensitive axis, a set of field control coils was designed. These were integrated into a 3D-printed sensor housing (Fig. 4b). The coils allowed the orientation of the static field at the sensor location to be locked to the sensor's sensitive axis during operation. Software controlled current drivers and an automatic calibration routine for these coils were used (Ingleby et al., 2017). The calculated design parameters for the Helmholtz field control coils are given in the table in Fig. 4(c).
Sensor operation: Using the sensors in a gradiometric setup allows suppression of periodic noise sources. This is reliant on effective synchronisation of the two independent sensors. The effect of applying the 50 Hz noise minimisation synchronisation routine described below is shown in the noise spectral data in Fig. 4(a). The common mode noise in the frequency band between 1 Hz and 50 Hz is reduced significantly dropping from 100 pT.Hz-1/2 to around 20 pT.Hz-1/2 at 1 Hz and from 10 pT.Hz-1/2 to about 7 pT.Hz-1/2 at 40 Hz.
The strong suppression of common-mode noise in the 1-50 Hz band shown in Fig. 5 demonstrates the requirement for effective synchronisation between the two sensor modules. The residual 50 Hz noise provided a useful signal for further temporal alignment in post- Fig. 3. a) Comparing the time intervals in the heart beat action between values obtained by averaging over ECG recordings gained from a herd of 32 Holstein dairy cows (DeRoth, 1980) (first row with standard deviations) and the values obtained from our MCG readings (red values). b) Overlay of three ECG traces (purple, blue, grey) that we recorded in Einthoven configurations simultaneously with an MCG trace (red). All four heart beat traces have been recorded using the same recovery software using 10 s data traces. (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.) Fig. 4. Measurement geometry: a) Expected variation of QTFM sensitivity with the orientation of the static field. The sensor's sensitive axis is oriented at (0, −90) on the plot axes. b) 3D printed sensor housing with the positioning of 3 sets of Helmholtz coils arranged around the sensitive centre to allow for precise static field control. The light grey QTFM sensor can be seen in its sheath with the sensitive centre in the active centre of the control coils. The black housing allows for the secure insertion of the sensor into protective tubing. c) Table of designed and calculated field control coil parameters.
processing without being large enough to diminish the data quality after filtering (Appendix Figure A2). The QTFM sensors record at a sampling rate of 407 Hz. To use two QTFM in a gradiometric set-up, a high degree of synchronisation was required. In order to quantify synchronisation between two sensors and to assess the value of postprocessing in achieving common-mode noise rejection, testing was carried out in noisy indoor environments in which the time series data was post processed with varying timing resolution. Data post-processing consisted of the application of a time delay t to the time-series data collected on one sensor channel and the calculation of interpolated data points shifted against the original data by Δt.
The difference trace was obtained by subtraction of one unmodified and one shifted channel. Post-processing software optimised commonmode 50 Hz noise rejection by finding the value of t yielding the lowest RMS noise pickup in the gradiometer data. Fig. 6 shows the variation of optimised noise RMS with granularity of variation in t. For time delay granularity Δt below the sensor sampling time, time-series interpolation was used to match sample timestamping in gradiometric measurements. It can be seen that decreasing Δt to one-tenth of the sampling time improves common-mode noise rejection, with diminishing returns for lower Δt. Given a sample time of 2.5 ms, synchronisation at the 0.25 ms level was used to achieve optimised common-mode noise rejection.

Discussion
The introduction of biosensors to modern farming is bringing great benefits for the health and welfare of farm animals. Biosensors will contribute to the 4th revolution in agriculture by incorporating innovative technologies into cost-effective diagnostic methods that can mitigate the potentially catastrophic effects of infectious outbreaks in farmed animals (Neethirajan et al., 2017). Human views on animal interaction are still largely generated from human-pet relations. Research has shown that especially for herd animals, human interaction is a disturbance rather than comfort (Kezer et al., 2017). Such disturbance has a negative influence of the wellbeing and subsequently on the productivity of a herd (Hedlund and Lovlie, 2015). Aside from the wellbeing of the cattle, it has also been shown that human-cattle interaction provides a risk to human handlers (Lindahl et al., 2016) Non-contact sensing of physiological parameters at strategic passing and dwelling points in the farming area avoids the mass-distribution and maintenance of wearable sensors, opening opportunities for the monitoring of animal wellbeing in farming and providing an earlywarning system for the health of the animal. While a potential strength of an ECG lies in its versatility in picking up different electrical aspects of the heart action, it is also prone to interference from other tissue leading to considerable animal to animal variation (DeRoth, 1980). Therefore compared to other techniques like ECG or echocardiography, MCG offersfor comparable effort-potentially better standardisation of measurements as well as diagnostic capabilities (Li et al., 2015). Currently only optically pumped atomic magnetometers can reach the sensitivity required to construct mobile units capable of operating in unshielded conditions. Other magnetic sensors, namely fluxgates are on the verge of the sensitivity required (Murzin et al. 2020). Multi-sensor arrays might open novel possibilities in their use.
The data quality in our proof of concept study is promising. Magnetocardiography in unshielded environments is still in the developmental stages (Guedes et al., 2018;Sorbo et al., 2018). Magnetocardiography in animals has so far been done in anesthetised animals using small animals like rats (Brisinda et al., 2006) or guinea pigs (Brisinda et al., 2007) where close placement of the sensors to the heart is possible. A recent study recording the cardiomagnetic signal of an isolated guinea pig heart is an important step towards providing an optimum benchmark for a magnetic signal from an animal heart (Jensen et al., 2018), albeit one obtained within a highly controlled lab environment. Although working with conscious large animals does considerably reduce data quality through movement, we recover the key parameters of the heart action: the heart rate, the timing of intervals within the heart action and the amplitude of the heart signal. These are in good agreement with published results and with our own ECG controls. The heart rate can be measured in 60% of 20-second recordings. The interaction of a cow over a few minutes with a stationary device like a sensor mounted at a milking parlour or at a cow brush should yield sufficient recordings for a secure heart rate reading.
A range of algorithms have been developed for the retrieval of heart signals from noisy magnetic data (Escalona-Vargas et al., 2018) giving options for further development. However in this study, the post-processing of the data was kept as simple as possible and as sophisticated as necessary to develop towards an instrument requiring no human input for analysis.
Comparing the intervals within the heart action; the length of the P wave (excitation of the artia), the duration of the QRS complex (main heart chamber action) and the repolarization of the heart in the T wave as well as the intervals between these key features shows good agreement with ECG data averaged over a dairy herd (DeRoth, 1980) as well as with our own ECG recordings yielding a convincing overlay of the ECG and the MCG signal.
The amplitude of the magnetic heart signal can be related to studies on human magnetocardiography (Alday et al., 2016) providing a theoretical foundation to estimate the relation of the electrical and the magnetic heart signal. This work suggests a 0.5 mV ECG signal to correspond to about 100pT in an MCG. This value can of course only provide rough guidance. The ECG signal of a cow has to travel through much more substantial tissue layers than that in a human. Studies on human MCG also show a very strong dependence of the signal amplitude on small spatial changes in the sensor positioning and in the precise orientation of the sensitive sensor axis in picking up radial or tangential magnetic signal components (Lau et al., 2016;Tsukada et al., 2000). In the configuration we used two sensors at either end of a virtual axis through the heart muscle the sensors to pick up a radial signal. The sensor placed low behind the left foreleg is positioned well to pick up a strong magnetic signal from the heart. The sensor opposite is situated further from the heart recording a smaller signal component. The suppression of common mode noise worked well in picking out the cardio magnetic signal.

Conclusions
We have developed a proof-of-concept instrument for magnetocardiography in large animals that is capable of recording key physiological parameters: the heart rate, the heart beat timing and the heart beat amplitude. Utilizing atomic magnetometers overcomes the cryogenic requirements of superconducting quantum interference device (SQUID) sensors and allows for compact and portable devises. Differential measurements in a gradiometric set-up enable the unshielded measurement of physiological signals in the pT range against a background of the Earth's magnetic field of tens of µT and magnetic noise from electrical installations.
While the signal of the heart muscle will on first approximation scale with size and subsequently the human heart show smaller signals in the range of tens of pT, sensors could also be placed much closer to a human heart. This opens exciting opportunities for cardio-monitoring of humans outside magnetically controlled and shielded clinical environments. Driven by more and more practical applications for optically pumped magnetometers, the range of commercial magnetometers on the market is increasing, introducing improved capabilities of temporal alignment, cell heating requirements or reduced dead zone geometries. As commercial magnetometers grow more versatile and more affordable, it will become possible to construct commercial magnetometer arrays for much improved common mode noise suppression and for heart monitoring techniques that surpass the capabilities of ECG technology (Zheng et al., 2020). In particular, multi-lead ECGs as required to track the movement of the electro-magnetic heart vector are impractical in veterinary science or agricultural monitoring. Recording MCG through multi-sensor magnetometer arrays will enable novel diagnostic methods and improve animal welfare monitoring.