Microsoft × Break Through Tech AI Studio Project

Blood pressure monitors are widely available. But if I am sitting at my laptop and want to check my blood pressure, I still need to go get one.

Well, I can get an apple watch but too broke for that.

But, I already have a camera right in front of me. Could we use that?

So we built Pulse2BP to see how far we could get with a camera and a pulse signal.

We are really grateful to Wee Hyong, our Microsoft challenge advisor, and Anshul Rehpade, our mentor for guiding us through this project.

I’m really grateful for the team that made this project possible. Our team members were Clarisse Iradukunda, Hir Bhatt, Mashrafee Aryan, Sofial Alvazzi, Sushmita Musunuri, Vanesa Aguay Guerra, Zaina Qadan, and Omar Soltan.

About the dataset

Before we got to the camera, we divided the project into questions. First question was: If we already had someone’s pulse, could we estimate their blood pressure?

We started with recordings that had both. A fingertip sensor recorded the pulse while blood pressure was measured at the same time. We used the UCI Cuff-Less Blood Pressure Estimation dataset.

The pulse signal is called PPG. Every time our heart beats, the amount of blood in our fingertip changes a little. The sensor uses light to pick up that change.

Here is an example of what dataset looks like. (this is after cleaning it a little bit)

TimeFingertip pulse (PPG)Arterial pressure (mmHg)
0 ms1.759567.06
8 ms1.718569.36
16 ms1.684375.37

Three readings look like a few decimals. Plot a few seconds of them and you start to see little hills.

Each hill is a heartbeat. An example of that would be the plot here:

Pulse waveform example

Preparing the dataset

First we cut the pulse and blood pressure recordings at the same spots. We called each 30-second piece a window. We chose this window because it seemed to work best when we varied the window size.

Each window gave us 3,750 readings from each signal. (USUALLY) We used the same length each time so the model always had the same amount of pulse to work with.

This is an example waveform of whole recoding and the 30seconds is just a window of that recording as you can see

Full recording and 30-second window

Second question we had to address: Does that look like a pulse?

Thinking about the waveform

This is me thinking what this waveform means

Some windows had missing numbers. Other windows pulse signals were almost in a straight line. So, we skipped those.

First, we checked if the line moved at all. A pulse usually looks like a row of little hills. If the line stayed almost at the same height for 30 seconds, we skipped that part. We used a number called standard deviation to check how much the height changed. If standard deviation was 0.001, it means the line was almost flat.

An example of a waveform with standard deviation <0.001:

Nearly flat waveform

Now what if the waveform was too noisy?

Noise is like an extra movement in the recording. A clean pulse recording should look like row of little hills. These are two real 30-second windows from our dataset. Look around 16 seconds in the bottom graph. The line drops suddenly that’s why it is noisy data

Clean and noisy pulse windows

To determine what pulse signal is noisy we had to do a few things. First we looked at speed. It means how often a hill repeats. If you see two hills in one second, that’s 2 hertz (Hz). One hertz means one full up-and-down cycle per second.

We started with 30 seconds of pulse readings. The sensor took 125 readings per second, so we looked at 256 readings at a time. That’s about two seconds. We call each little two-second piece a chunk.

For each chunk, the computer made simple waves to compare with the recording. One wave went up and down once in those two seconds. That’s about 0.5 Hz. Another went up and down four times in those two seconds. Four divided by two gives us about 2 Hz. The computer tried a whole set of speeds this way.

When a wave’s ups and downs lined up well with the recording, that speed got a high score. We did this for every chunk, then averaged the scores for each speed across the full 30 seconds. That’s Welch’s method.

Finally, we added up the scores from 0.5 to 8 Hz, the range we chose to capture the beat and the faster changes that give each hill its shape. Then we compared that sum with the total across all speeds.

If the scores added up to 10 and 7 came from our range, that’s 70%, so we kept the window. If less than 60% came from our range, we skipped the whole 30 seconds.

What about the windows we kept? They could still have a little slow drift or fast shaking. So we cleaned them up before measuring the pulse.

We used a filter. Think of it like a volume knob for the line. We turned down movements that were slower than 0.5 Hz or faster than 8 Hz, using the same range we just checked.

Look near 16 seconds in the top graph. There’s a sharp jump. The bottom graph shows the same recording after filtering. The jump is smaller, and the little hills are still there. Now it’s easier to measure how long each hill takes to rise.

Before and after filtering

The same six seconds before and after filtering. Both lines are centered so their shapes are easier to compare.

What does one training example look like?

Okay, we cleaned up the line. What do we actually give the model?

We measure the hills. Rise time is how long one takes to go from bottom to top. Pulse width is how long it stays above the halfway mark.

Here’s one real example from the 30-second window in the chart.

What the model sees. An estimated pulse rate of 92.5 beats per minute, a rise time of about 0.18 seconds, and a pulse width of about 0.21 seconds. The last two are averages across beats.

What it learns to predict. 140.2 over 60.7 mmHg. The first number is the top blood pressure number. The second is the bottom number.

Where did those answers come from? We used the pressure line recorded during those same 30 seconds. We took the middle value of its high points for the top number and the middle value of its low points for the bottom number. That way one unusual beat had less say.

Training the model

We gave Random Forest, Extra Trees, XGBoost, and a small neural network called an MLP measurements from the pulse. That includes things like how quickly the pulse rose and how far apart the beats were.

We also tried 1D CNNs. They look for patterns in the waveform itself. One used the waveform along with our pulse measurements. Another looked for patterns of different lengths.

We read a few blog posts about using large language models (LLMs) to change a model’s weights. Weights are numbers inside a model that shape its guesses. So we tried it. With help from an LLM, we lowered the weights our pulse model used to guess the gap between the top and bottom blood pressure numbers by 10%. We ran the same test again. The average error changed by less than 0.01 mmHg, so we kept XGBoost as our final model.

Testing the model

We kept each recording together. Some recordings taught the models, some helped us choose settings, and the rest gave us a final test.

Why bother? Two pieces from the same recording can look alike. Keeping them together makes the test more like seeing a new recording.

The table shows how far off the estimates were on average, in mmHg. If the answer was 120 and we guessed 130, that’s a miss of 10.

The final notebook compares the simple guess, Extra Trees, and XGBoost on 12,523 test windows. The table also shows results from our earlier 30-second experiments.

ModelSystolic errorDiastolic error
Simple baseline18.298.59
Random Forest14.097.23
Small neural network (MLP)13.416.79
1D CNN with pulse measurements12.846.40
1D CNN with multiple pattern lengths12.406.30
Extra Trees12.496.62
XGBoost11.606.04

XGBoost had the lowest error in the final comparison. So that’s what we used in the demo. Final notebook

What did XGBoost look at?

A measurement we give the model is called a feature. How long the pulse takes to rise is one example.

We looked at which features helped XGBoost make better guesses during training. The chart shows a few that stood out.

XGBoost feature importance

Five pulse measurements from the final notebook’s importance chart. Longer bars mean the measurement helped the model more during training.

The top number’s model got a lot of help from how much of the time the pulse was rising. For the bottom number, the area under a typical beat stood out. Picture shading in the space under one little hill.

Getting a pulse from the camera

Now, back to the camera.

When your heart beats, the color of your face changes a tiny bit. FacePhys looks at those changes from one video frame to the next and turns them into a pulse line.

That line gives us a heart rate. If you click Estimate blood pressure, we measure the shape and timing of the pulse and give those numbers to XGBoost.

Out come two estimates. One for the top number and one for the bottom.

Our model is still under development and not at all medical grade yet. However, we hope to develop towards it!

An example of what it looks like:

Pulse2BP demo

Try the Pulse2BP demo