Despite the recent proliferation of Internet of Things (IoT) sensors and wearable technologies, heart monitoring at non-clinical, remote settings (e.g., at home) over prolonged period is challenging and not accurate compared to the baseline ElectroCardioGraphy (ECG) method. As a non-invasive alternative to the widely available ECG, MagentoCardioGraphy (MCG)  appeared as a promising technique, which measures the magnetic field produced by electrical activity in the human heart. Although MCG measurement possesses clinically useful information for a more accurate and advanced cardiac diagnosis , it is not without shortcomings. The multi-channel MCG equipment usually comprise more than 50 detectors called Superconducting Quantum Interference Devices (SQUIDs), which requires expensive liquid helium cooling . Furthermore, due to the expense and need for magnetic shielding for SQUID based MCG , its diagnostic usefulness compared to ECG devices is questioned in .
In this paper, we present a novel spintronic sensor based on the Tunneling MagnetoResistance (TMR) effect in Magnetic Tunnel Junction (MTJ) devices developed by the physicists of our research group that has great potential for sensing human heart and brain signals . The sensor is small and it can be fused on-chip with silicon logic circuits to construct portable lab/logic-in-sensor diagnostics devices as depicted in Fig. 1. Due to this logic-in-sensor architecture, it improves the Quality of Service (QoS) issues such as communication delay, overhead, and energy expenditure, and therefore, can be used for long-term, accurate monitoring of cardiac cycle of the patient without interfering with the subject’s day-to-day activities.
One of the major challenges for biomagnetic detection and sensors is the sensor noise at low frequencies, usually represented as noise, where is the spectral frequency . This creates a unique problem for measuring MCG signals using the spintronic sensor simply because the heart also oscillates at low frequency, producing signals in the same frequency band as the noise. To tackle this problem, in this paper, we propose a deep learning based approach (an Artificial Intelligence (AI) methodology) to perform noise processing on MCG traces, which are synthesized from an actual ECG dataset to replicate the properties of our spintronic MTJ sensors. The proposed deep learning method takes advantage of a uniquely constructed structure combining a Convolutional Neural Network (CNN) and Gated Recurrent Unit (GRU). The performance of our proposed deep learning method is validated by conducting computer-based validations. The trained model can be easily incorporated into the sensor node incorporating our developed spintronic IoT sensor for MCG signal monitoring.
The remainder of this paper is organized as follows. Section II presents the relevant research work. Section III describes the considered model of our proposed spintronic sensor. It also delineates how it is able to measure MCG signal. Section IV presents a formal problem formulation. The section explains why traditional filtering method (i.e., moving average technique) to process the MCG signal sensed by our spintronic sensor is inadequate. In Section V, we present a novel deep learning model to distinguish the noise from the actual MCG signal. The performance of our proposal is validated in Section VI. Finally, the paper is concluded in Section VII.
Ii Related Work
Liu et al.  surveyed extensive sensing capabilities of various spintronic sensor types for various applications ranging from the smart grid to smart healthcare. Spintronic sensors were identified to be a potential enabler to build effective Point-of-Care (POC) platform, combining smart and portable bio-sensors, computing, networking, and ICT technologies, for pervasive healthcare devices to reduce healthcare costs and improve diagnostic and monitoring efficiency, particularly in countries with large populations or rural areas. Handheld, battery-powered POC devices comprising spintronic bio-detection sensors were developed that can be exploited for detecting bio-molecules. On the other hand, in the research work conducted by Fujiwara et al. 
, an ultra-high sensitive TMR sensor was developed to measure both heart’s MagnetoCardioGraphy and brain’s MagnetoEncephaloGraphy (MEG) signals at the room temperature. The MCG R wave was detected without averaging, and the QRS complex was observed with a good signal to noise ratio (SNR) by averaging signals for several tens of seconds. The MCG mapping was demonstrated with high spatial resolution. Real-time MCG measurements with high spatial resolution at the room temperature may lead to significant improvements in the diagnosis of heart disease. In addition, the world-first detection by room-temperature sensors of the human brain MEG was demonstrated. The MEG alpha wave at approximately 10 Hz was observed. This demonstration of MEG measurements at room temperature is a very significant advance in biomagnetometry. The present findings are expected to lead to various room temperature biomedical applications using TMR sensors.
Iii Overview of Proposed Spintronic IoT Sensor
Among the various types of sensors, the magnetic field sensors contribute only to 9% of sensor shipments by Japanese companies . Among those magnetic sensors, the sensors based on Hall and anisotropic mangetoresistance effects are predominant, and TMR-based ones are the least available . However, a shifting landscape of application demands in automotive, smart healthcare, infrastructure, and power-grid sectors will require specifications found only in TMR technology. Furthermore, magnetic sensing can be expanded to other sensing domains, such as temperature, position, pressure, acceleration, and so forth. Therefore, there is a strong potential for TMR sensors to take from the market share of other sensors, and expand into applications not possible before.
For example, by developing ultra-sensitive TMR sensors, non-invasive measurements of human body biomagnetic signals were demonstrated. The biomagnetic fields are on an order of 1 femtotesla to 10 picotesla. Therefore, while keeping very high sensitivity of our developed IoT sensor, the noise at low frequency is crucial. Multiple approaches at the physical layer were used: integrating large arrays of MTJs ( elements) , optimization of sensing layer materials and fabrication process [5, 12], decrease of MTJs resistance-area product, and signal filtering and conditioning. Recently, a significantly small detectivity of at 3 Hz was achieved by an industrial collaborator, which was demonstrated for MCG and MEG acquisition .
At low frequency, the noise in our MTJ based sensor is dominated by character, which is a general phenomenon in various types of systems and sensors . The problem is exacerbated at the high sensitivity region . The power spectral density (PSD) of low-frequency noise can be represented as :
where , , , , and denote the sensor susceptibility which is proportional to sensitivity, the sensor saturation magnetization, sensor volume, spectral frequency, and the exponent of noise spectrum, respectively. Mitigating the noise in the MTJ sensor will open the way to exploit its high sensitivity and low total ownership cost compared to other magnetic/non-magnetic sensors.
Iv Problem Formulation
Remote/home monitoring of cardiac conditions using IoT sensors and wearable devices for prolonged periods has recently emerged as a hot research topic. This is because of its ability to capture the variability of the cardiac signals for a long duration to indicate irregularities of heart conditions and other related disorders for medical analytics. Conventional ECG at the care-giving facility cannot be used for home monitoring due to technical challenges such as placing the electrodes on the patient body and managing the ECG equipment at home. On the other hand, Holter monitors for collecting ECG data  can be used for home monitoring. However, Holter monitors are expensive, have to be worn (i.e., interferes with the daily activity of the user), and are usually rented to the patient for limited time of use (typically for a day). Also, the care-givers need to download and analyze the collected ECG data from the Holter monitor which involves typically a few days. The high cost of these devices prevents long term monitoring use like athletic performance of sportsmen, elderly patients aging at home, patients taking medications causing side-effects, and so forth . Therefore, we explore the potential of our affordable spintronic sensor to capture MCG information in a non-invasive manner and aim to solve the cardiac source imaging problem efficiently by mapping the obtained MCG trace to find the corresponding ECG signal.
Solving the inverse problem of MCG and ECG, i.e., the cardiac source imaging was identified to be an important research topic in  since the spatial properties of MCG and ECG mapping are not well known. While ECG provides adequate information regarding normally-oriented and posterior sources, MCG is able to provide a higher resolution of information by characterizing tangential anterior sources of the human heart. However, employing spintronic sensors to detect the magnetic field of the heart with high sensitivity requires noise filtering. In order to filter the intrinsic noise of the considered spintronic IoT sensor, using the moving average technique (the most widely adopted noise filtering algorithm) may not yield reasonable results. The moving average is a form of a convolution that could be used in the MCG time-series analysis to smooth out noise in the MCG dataset by replacing a data point with the average of neighboring values in a moving window. Thus, the moving average essentially acts a low-pass filter since it removes short-term fluctuations to highlight a deeper underlying trend of the MCG signal. However, the main disadvantage of moving average is that noise is in the low-pass band, and it cannot be removed without removing the heart MCG features. As a solution to this problem, in this paper, we investigate how deep learning can be used to effectively train on the noisy MCG signals and corresponding ECG signals as examples or labels, and then execute the trained model (i.e., at our spintronic IoT sensor) to obtain the ECG trace for an unknown MCG input.
V Deep Learning Based Proposed Method
In this section, the generation of synthetic MCG signals from an ECG dataset and the training procedure for noise processing in MCG signal using a unique deep learning architecture are delineated. We prepared the labeled training MCG data from a public ECG dataset, as outlined in Fig. 2. Then, we constructed the deep learning model to be consisting of an input layer, a one-dimensional (1-D) convolutional layer, a GRU layer, a dense layer, and an output layer as shown in Fig. 2(a). Our deep learning architecture to identify the underlying ECG signal from the noisy MCG signal contains 1D CNN to extract the features, and GRU to learn the features in order to build models. After the data collection and preprocessing, the MCG and original ECG trace segments are used to train the deep learning model depicted in Fig. 3. In the remainder of this section, we describe the details of input labeling, the CNN, and GRU layers of our proposed model (Fig. 2(a)), respectively.
V-a Labeled Input Preparation
We synthesized MCG traces from ECG traces available in the open PTB Diagnostic Database [1, 7]. It is worth noting that we define the term “segment” as one heartbeat cycle. Fig. 2 demonstrates the synthesis procedure for MCG traces. We used the traces from lead II of the healthy individuals provided by Kachueeet al. , which were segmented into single heartbeat rhythm cycles starting from wave to the next complex, with the following sequence (
). The segments were originally sampled at 125 Hz with varying sample lengths and padded zeros. We removed the padded zeros and re-sampled each segment to a fixed length of 3008, which is approximately 16 times of the original length at a sampling frequency () of 2000 Hz. This resampling was required to accommodate the full spectral features of the MCG noise, without padded zeros to a Convolutional Neural Network (CNN) input. The preconditioned ECG segment is added to randomly-generated low-frequency noise. The noise in MCG traces was described based on the expected characters known from real measurements using MTJ sensors 
. We generated the low-frequency noise from a Gaussian white noise with a constant PSD, we applied a transfer function of character, then converted the result back into time domain by inverse Fourier transform . The transfer function was defined as follows:
where the transition between and white noises is set at . As a training set, for each ECG segment, we synthesized 100 MCG segments with different noise sequences. After the data collection and preprocessing, the MCG and original ECG trace segments are used to train the deep learning model depicted in Fig. 3.
V-B CNN Layer
The input to the CNN structure is the noisy MCG signal synthesized as discussed in Sec. V-A. The CNN extracts noisy MCG information using various filter sizes. We first applied a 1D-convolution over an input shape consisting of several input matrices. The convolutional layer uses a sliding window which is moved in stride across the input as depicted in Fig. 2(b). This transforms the input signal into representative values. The convolution operation preserves the spatial relationship of the MCG data by learning useful features using small squares of input data. Each MCG data from a patient is treated as a separate sample and input to the neural network. For an input size (, , L), the output of the CNN layer (, ,
) can be estimated as follows:
where , , , , and denote the valid cross-correlation operator, batch size, number of channels, the length of the signal sequence, and the weights of the connections, respectively. The learnable weights and bias variables are set. The pooling layer is inserted between the convolutional layers to carry out down sampling by reducing the size of matrix calculations for the next colvolutional layer. Kernel size of 20 is used in the CNN after multiple tries to obtain the best performance. In other words, it removes certain values to achieve less computational operations and overfitting control while preserving the most relevant representative features. The pooling layer uses a sliding window or certain region, which is moved in stride across the input matrix that transforms the values into representative values as shown in Fig. 2(b). At each sliding step , the MCG segment window with length
For the backpropagation method used in the fully connected layer of the CNN layer to adjust the weights of the connections, interested readers are referred to our earlier paper in.
V-C GRU Layer
The generated feature sets by the 1D-CNN layer are passed as input to a GRU layer 
. GRU is an improved variant of the Recurrent Neural Network (RNN). The GRU layer is considered in conjunction with the CNN layer to deal with the problem of ”vanishing gradient” and efficiently learn long-term dependencies information of the noise and MCG signal. The GRU layer consists of an update gate and a reset gate. For each element in the input sequence of the GRU layer, the update gate helps the model to estimate how much of the previous information from earlier time steps needs to be passed along to the future. The update gatefor time step can be estimated as follows:
where denotes the input at time , indicate the hidden state of the previous layer at time () or the initial hidden state at time 0,
is the sigmoid function,refers to the weight, and is the bias.
On the other hand, the reset gate of the GRU layer decides how much of the past information can be ignored as follows:
The current memory content of the GRU layer utilizes the reset get to store the relevant information from the past using the following expression:
V-D Output layer
In the output layer, we used a linear transformation to the incoming input coming from the output of the preceding dense layer. As mentioned earlier, during each sliding step, the MCG segment window with length is fed to the joint CNN and GRU model. The output is set to the corresponding point in the ECG segment.
Vi Performance Evaluation
In order to evaluate the performance of our proposal, we conducted simulations using Python 3 with Numpy, Matplotlib and Sklearn packages for data processing and visualization. The model is implemented in Tensorflow v1.13 with the Keras library for Python. In order to guarantee the unbiased comparison, we considered a test dataset. It is worth noting that there is no overlap between the training MCG data and the test data. We conducted training on our proposed deep learning model using 2353 samples and validated the model on 589 test samples.
Fig. 4 demonstrates one of the randomly picked visualization results among many validations of our proposed model. The original ECG sample (without noise) is shown at the bottom which is obtained from the original dataset [1, 7]. The simulated MCG signal (with noise from spintronic sensor reading) is generated using the data preparation step discussed in Sec. V-A. The third curve is showing the MCG segment obtained after applying the moving average filter with the same window size as the one used for CNN. The fourth curve shows the outcome of our proposed deep learning model, i.e., the predicted ECG trace (without noise) based on the noisy MCG input signal. Comparing both the predicted and average-filtered segments with the original ECG segment in Fig. 4, we notice that both moving average and deep learning techniques are able to construct the underlying ECG trace from the noisy input signal. But at times, the deep learning model distinguishes the low-frequency noise features from intrinsic ECG features, e.g. in the samples interval 1000–2000, without degrading the features that have higher frequency components.
In order to investigate the performance of the deep learning model, we compare the spectral features of the remaining noise after applying each method of moving average and CNN prediction. We plot the PSD dependence on spectral frequency normalized by the sampling frequency () in Fig. 4(a), using the prediction and averaging results of 2,000 segments. Both of filtering methods decreased noise and lowered the knee frequency from its original value at . However, at lower frequencies, the noise power of deep learning based prediction model remains lower than the noise power of the sliding average filter. The effect of this is highlighted further in Fig. 4(b), which plots the noise ratio reduction factor for the prediction noise and sliding average noise. The deep learning model outperforms the sliding average at frequencies ranging –, by an order of magnitude. This frequency band has major MCG spectral components, resulting from complex. As an expectation, the spectral resolution of the CNN striding window is the inverse of window size at . This means that the CNN model is best at discerning noise that lasts between half and the full window size. Further adjustments to the CNN sliding window length or shape can be used to tune out the low-frequency noise without affecting the MCG features.
Since ECG cannot be applied effectively for remote/home monitoring of cardiac condition of patients, new applications with new values in the IoT industry for cardiovascular monitoring need to be considered. In this regard, spintronic sensors using Magentic Tunnel Junction (MTJ) devices offer a strong advantage in terms of high sensitivity and portability as well as its ability to facilitate logic-in-sensor architecture. The paper also addressed the key challenge of dealing with the intrinsic noise at the sensor that the conventional filtering methods are unable to effectively process due to its characteristics similar to the low-frequency character of the heart signal. A deep learning model combining the advantages of CNN and GRU is used to process this noise. The model was trained with MCG data synthesized from a real ECG dataset and validated with a test data. The results indicate encouraging performance of our proposed method compared with the conventional moving average technique. The noise power in the model predictions showed a large reduction at low frequencies compared to the moving average technique. Therefore, by more optimization of the deep learning model, the smart removal of low-frequency noise can unlock the potential for MCG monitoring applications using the MTJ IoT sensors. Furthermore, this noise processing can be done on-node within the logic-in-sensor architecture.
This work was partially supported by the Center for Science and Innovation in Spintronics (Core Research Cluster) Organization for Advanced Studies, Center for Spintronics Research Network, Tohoku University, the S-Innovation program, Japan Science and Technology Agency (JST), and by JSPS KAKENHI Grant Number JP19K15429. The authors would like to thank Dr. Kenji Mizuguchi for his support. The statements made herein are solely the responsibility of the authors.
-  (2009-07) Nutzung der ekg-signaldatenbank cardiodat der ptb über das internet. Biomedizinische Technik/Biomedical Engineering, pp. 317–318. External Links: Cited by: §V-A, §VI.
-  (2018-06) On delay-sensitive healthcare data analytics at the network edge based on deep learning. In 2018 14th International Wireless Communications Mobile Computing Conference (IWCMC), Vol. , pp. 388–393. External Links: Cited by: §V-B.
-  (2018-01) Magnetocardiography and magnetoencephalography measurements at room temperature using tunnel magneto-resistance sensors. Applied Physics Express 11 (2), pp. 023001. External Links: Cited by: §I, §II, §V-A.
-  (2013-04) Detection of Sub-Nano-Tesla Magnetic Field by Integrated Magnetic Tunnel Junctions with Bottom Synthetic Antiferro-Coupled Free Layer. Japanese Journal of Applied Physics 52 (4S), pp. 04CM07. External Links: Cited by: §III.
-  (2012-03) Fabrication of magnetic tunnel junctions with a bottom synthetic antiferro-coupled free layers for high sensitive magnetic field sensor devices. Journal of Applied Physics 111 (7), pp. 07C710. External Links: Cited by: §III.
-  (2008) Science and History of Magnetocardiography. Note: http://genetesis.com/mcg-science-history/[Online; accessed 19-July-2008] Cited by: §I.
-  (2000-06) PhysioBank, physiotoolkit, and physionet: components of a new research resource for complex physiologic signals. Circulation 101 (23), pp. E215–220. External Links: Cited by: §V-A, §VI.
-  (2006) Pseudo current density maps of electrophysiological heart, nerve or brain function and their physical basis. Biomagnetic Research and Technology 4, pp. 5 – 5. Cited by: §I.
-  (1981) Experimental studies on 1/f noise. Reports on Progress in Physics 44 (5), pp. 479. External Links: Cited by: §III.
-  (2018) JEITA sensors global status survey: presentation of sensors global shipments (years 2016–2017), title translated from Japanese. Japan Electronics and Information Technology Industries Association. External Links: Cited by: §III.
-  (2018) ECG heartbeat classification: A deep transferable representation. CoRR abs/1805.00794. External Links: Cited by: §V-A.
-  (2013-09) Fabrication of Magnetic Tunnel Junctions with Amorphous CoFeSiB Ferromagnetic Electrode for Magnetic Field Sensor Devices. Applied Physics Express 6 (10), pp. 103004. External Links: Cited by: §III.
-  (2012) Multi-channel magnetocardiogardiography system based on low-tc squids in an unshielded environment. Physics Procedia 36, pp. 286 – 292. Note: Superconductivity Centennial Conference’11 External Links: Cited by: §I.
-  (2019-03) Super-high sensitivity of magnetic field detection technology using tmr effect. In The 66th JSAP Spring Meeting, Cited by: §III.
-  (2019) ET-GRU: using multi-layer gated recurrent units to identify electron transport proteins. BMC Bioinformatics 20 (1), pp. 377. External Links: Cited by: §V-C.
-  (2011-03) Review of Noise Sources in Magnetic Tunnel Junction Sensors. IEEE Transactions on Magnetics 47 (3), pp. 602–612. External Links: Cited by: §I, §III.
-  (2016) Overview of spintronic sensors, internet of things, and smart living. CoRR abs/1611.00317. External Links: Cited by: §II.
-  (2018) Magnetic Sensor Market — Global Industry Analysis 2013–2017 and Forecast 2018–2028. Future Market Insights. Note: Report Code: REP-GB-5217 External Links: Cited by: §III.
-  (2014-11) Investigations of sensitivity and resolution of ECG and MCG in a realistically shaped thorax model. Physics in Medicine and Biology 59 (23), pp. 7141–7158. External Links: Cited by: §IV.
-  (2012) The dc-squid-based magnetocardiographic systems for clinical use. Physics Procedia 36, pp. 88 – 93. Note: Superconductivity Centennial Conference’11 External Links: Cited by: §I.
-  (2006-07) Comparison of magnetocardiography and electrocardiography: a study of automatic measurement of dispersion of ventricular repolarization. EP Europace 8 (10), pp. 887–893. External Links: Cited by: §I.
-  (2016-Sep.) Customizable holter monitor using off-the-shelf components. In 2016 International Conference on Advances in Computing, Communications and Informatics (ICACCI), Vol. , pp. 2302–2306. External Links: Cited by: §IV.
-  (2008-11) 1/f Magnetic Noise Dependence on Free Layer Thickness in Hysteresis Free MgO Magnetic Tunnel Junctions. IEEE Transactions on Magnetics 44 (11), pp. 2551–2553. External Links: Cited by: §III.