How can I improve my pulse oximetry measurements?

In summary, the conversation is about a program that uses a computer camera to monitor pulse oximetry and get heart rate. The program has a timer interval set to 0.0226757 ms and displays heart rate on a graph. However, there is a lot of noise in the graph and the user has implemented a filter by taking the average of 5 samples. The type of filter used is unclear, but the user is trying to determine the best number for the average measurement and how to calculate it. The conversation also discusses the irregular heartbeat of the user and how it may affect the results. The conversation ends with the user questioning the accuracy of the filter graph and seeking to learn more about the program.
  • #1
btb4198
572
10
TL;DR Summary
Pulse Oximetry equations
I wrote a program that uses your computer camera to monitor your Pulse Oximetry and get your heart rate.
I got the program to work. I can see the heart beat in my graph.
Anyhow, I set my timer interval to 0.0226757 ms which is 44100 hz.

so I have a few questions,
I was seeing a lot of noise at 1st, so I started taking the average of every five samples and plotting that.

Not filter:
Not Filter.PNG

Filter graph:
Filter grapth.PNG
Now you can see the heart beat.

Why was there so much noise? Where is this noise even coming from ? Is there a better number for average measurement, I should be using ? if so How do I determine the best number for average measurement ?

What kind of filter is average number measurement? How does it work ?

From this graph how do you determine the heart rate?
 

Attachments

  • Not Filter.PNG
    Not Filter.PNG
    5.3 KB · Views: 93
Biology news on Phys.org
  • #2
Something's screwy here. No way can a commercial camera provide 44k frames per second. And if that's supposed to be 44k pixels per second then that's a really low rate, given that a three colour 640×480 pixel camera has nearly a million pixels.

There is no way that second graph is a five sample average of the first. An average smooths a line and blurs its features. It doesn't pull that second graph out of the first. And the pulse rate is about one per ten dots in the second graph, which would imply one per fifty original samples or about one per millisecond. With that kind of pulse rate I'd suggest consulting a doctor sometime in the next few seconds.

Something's going on here that you either don't understand or are reporting inaccurately. If the second graph were a five thousand sample average of the first I'd believe the relationship between the graphs. But I still don't understand what you are sampling. At 44k it looks like either one pixel waaaay too fast or the entire image way too slowly. Or maybe you're taking the bit stream from the camera (~20M bytes per second for a 640×480 24 bit camera) every 0.02ms, in which case you are just sampling different single pixels each time. Any of those would cause noise for different reasons.
 
  • #3
Ibix said:
Something's screwy here. No way can a commercial camera provide 44k frames per second. And if that's supposed to be 44k pixels per second then that's a really low rate, given that a three colour 640×480 pixel camera has nearly a million pixels.

There is no way that second graph is a five sample average of the first. An average smooths a line and blurs its features. It doesn't pull that second graph out of the first. And the pulse rate is about one per ten dots in the second graph, which would imply one per fifty original samples or about one per millisecond. With that kind of pulse rate I'd suggest consulting a doctor sometime in the next few seconds.

Something's going on here that you either don't understand or are reporting inaccurately. If the second graph were a five thousand sample average of the first I'd believe the relationship between the graphs. But I still don't understand what you are sampling. At 44k it looks like either one pixel waaaay too fast or the entire image way too slowly. Or maybe you're taking the bit stream from the camera (~20M bytes per second for a 640×480 24 bit camera) every 0.02ms, in which case you are just sampling different single pixels each time. Any of those would cause noise for different reasons.
So I do have an irregular heartbeat and I have had open heart surgery.
So that could be why...

But that aside, I draw a box around the red area from my thump and take the average value of pixels in that area. I do this ever 0.0226757 milliseconds. That is how the non Filter graph works.

For the Filter graph, I do the same thing but I add up 5 samples and take the average.

So for the filter graph the sample time is really 0.0226757 * 5 = 0.1133785 ms. Because I do not display the new point until after I got 5 sample and took the average.

So yeah I code that today and that is how it is working.
 
  • #4
btb4198 said:
So I do have an irregular heartbeat and I have had open heart surgery.
So that could be why...

But that aside, I draw a box around the red area from my thump and take the average value of pixels in that area. I do this ever 0.0226757 milliseconds. That is how the non Filter graph works.

For the Filter graph, I do the same thing but I add up 5 samples and take the average.

So for the filter graph the sample time is really 0.0226757 * 5 = 0.1133785 ms. Because I do not display the new point until after I got 5 sample and took the average.

So yeah I code that today and that is how it is working.
So I am new to this. And I could be doing something wrong. I am trying to learn. but the filter graph looks how normal heart monitor graph look.
right ?
 

Attachments

  • heart beat  3.PNG
    heart beat 3.PNG
    23.7 KB · Views: 100
  • #5
Ibix said:
Something's screwy here. No way can a commercial camera provide 44k frames per second. And if that's supposed to be 44k pixels per second then that's a really low rate, given that a three colour 640×480 pixel camera has nearly a million pixels.

There is no way that second graph is a five sample average of the first. An average smooths a line and blurs its features. It doesn't pull that second graph out of the first. And the pulse rate is about one per ten dots in the second graph, which would imply one per fifty original samples or about one per millisecond. With that kind of pulse rate I'd suggest consulting a doctor sometime in the next few seconds.

Something's going on here that you either don't understand or are reporting inaccurately. If the second graph were a five thousand sample average of the first I'd believe the relationship between the graphs. But I still don't understand what you are sampling. At 44k it looks like either one pixel waaaay too fast or the entire image way too slowly. Or maybe you're taking the bit stream from the camera (~20M bytes per second for a 640×480 24 bit camera) every 0.02ms, in which case you are just sampling different single pixels each time. Any of those would cause noise for different reasons.
I use the light on my cell phone to illuminate my thumb. It looks like it is working right ?
oh my web cam is an 1280 X 720
Video Quality
is
720p 16:9 30fps
 

Attachments

  • New grapth.PNG
    New grapth.PNG
    28.5 KB · Views: 95
  • #6
Ibix said:
Something's screwy here. No way can a commercial camera provide 44k frames per second. And if that's supposed to be 44k pixels per second then that's a really low rate, given that a three colour 640×480 pixel camera has nearly a million pixels.

There is no way that second graph is a five sample average of the first. An average smooths a line and blurs its features. It doesn't pull that second graph out of the first. And the pulse rate is about one per ten dots in the second graph, which would imply one per fifty original samples or about one per millisecond. With that kind of pulse rate I'd suggest consulting a doctor sometime in the next few seconds.

Something's going on here that you either don't understand or are reporting inaccurately. If the second graph were a five thousand sample average of the first I'd believe the relationship between the graphs. But I still don't understand what you are sampling. At 44k it looks like either one pixel waaaay too fast or the entire image way too slowly. Or maybe you're taking the bit stream from the camera (~20M bytes per second for a 640×480 24 bit camera) every 0.02ms, in which case you are just sampling different single pixels each time. Any of those would cause noise for different reasons.
Oh sorry my timer is set to go off every 1/44100 ms . So I am sampling the video at that speed. Oh! so that is why I have to do an average measurement of 5. I am sampling too fast and the picture is not updating. So I should change my timer to 33.33 ms?
 
  • #7
btb4198 said:
Oh sorry my timer is set to go off every 1/44100 ms . So I am sampling the video at that speed. Oh! so that is why I have to do an average measurement of 5. I am sampling too fast and the picture is not updating. So I should change my timer to 33.33 ms?
So that did not work. I changed the timer interval to 33.33 milsec and removed the average number of measurement of 5.

but I got this:

New not Filter  gapth.PNG


and it looks bad...
 

Attachments

  • New not Filter  gapth.PNG
    New not Filter gapth.PNG
    8.3 KB · Views: 93
  • #9
Baluncore said:
What are you trying to measure? Pulse rate, O2, or perfusion ?
How have you mounted the light source and detector?
https://en.wikipedia.org/wiki/Pulse_oximetry#Mode_of_operation
The detector is my computer Dell integrated camera. The light source is my Iphone and I had it in behind my thumb. I cover the camera with my thumb. I am measuring the oxidation level in the blood cause be a heart beat.

do anyone know why I have to do an average measurement of 5 for my graph to look right ?
 
  • #11
btb4198 said:
So that did not work. I changed the timer interval to 33.33 milsec and removed the average number of measurement of 5.

but I got this:

View attachment 284688


and it looks bad...
If I get this correctly, you have programmed your phone to send a flash of light through your thumb once every 33.33 ms; the computer camera picks up the transmitted signal. Have you investigated your system's overall response by seeing what it does when there is a thumb-equivalent without a pulse? I recommend that you go to the store and buy a nice steak. Slice a 1/4-inch thick piece with no fat. Use it as a thumb surrogate, pulse your phone and see what kind of graph you get. Take it from there but be sure to save the rest of the steak for tomorrow to grill for Father's day. :oldsmile:
 
  • Like
Likes jim mcnamara
  • #12
kuruman said:
If I get this correctly, you have programmed your phone to send a flash of light through your thumb once every 33.33 ms; the computer camera picks up the transmitted signal. Have you investigated your system's overall response by seeing what it does when there is a thumb-equivalent without a pulse? I recommend that you go to the store and buy a nice steak. Slice a 1/4-inch thick piece with no fat. Use it as a thumb surrogate, pulse your phone and see what kind of graph you get. Take it from there but be sure to save the rest of the steak for tomorrow to grill for Father's day. :oldsmile:
wait what? I do not understand.

Also the Iphone is not programmed. I just turn the flashlight on and point it at my thumb. The software is on my computer.
 
  • #13
btb4198 said:
wait what? I do not understand.

Also the Iphone is not programmed. I just turn the flashlight on and point it at my thumb. The software is on my computer.
Sorry, I thought you also pulsed your phone. OK, you still need to ascertain how intrinsically noisy your system is. That is why I suggested the piece of steak. If all work according to plan, your software should return a flat line. Does it?
 
  • #14
kuruman said:
Sorry, I thought you also pulsed your phone. OK, you still need to ascertain how intrinsically noisy your system is. That is why I suggested the piece of steak. If all work according to plan, your software should return a flat line. Does it?
lol I would have to buy one and see... but why steak?
 
  • #15
I think raw red meat, not necessarily steak, would simulate the blood in your thumb better than pork or chicken.
 
  • #16
btb4198 said:
Summary:: Pulse Oximetry equations

I wrote a program that uses your computer camera to monitor your Pulse Oximetry and get your heart rate.
I cannot read the titles of, or the values on the axes on the graphs so it is difficult to guess.
Please post a copy of the program you wrote.
Do you have a link to someone else who has used a similar setup?
 
  • #17
After conducting a lot of troubleshooting, I learned there was an error in my code. I corrected it, but I am still unable to get a good graph. after testing, I am sure the code is working as it should. SO I believe the problem is the DELL PRECISION 7740 camera. So, I know this works on the iPhone. I found out that the iPhone uses a ten bit camera with a high of 60 fps.

I could not find that much information on the DELL PRECISION 7740 camera, but I think it is an 8-bit camera.

I know the human eye cannot pick up the change in skin color from oxidation and that 8 bits (255) it the limit of what humans can see, so I think an 8-bit camera is not going to work. Is that correct?
 
  • #18
Baluncore said:
I cannot read the titles of, or the values on the axes on the graphs so it is difficult to guess.
Please post a copy of the program you wrote.
Do you have a link to someone else who has used a similar setup?
I do not know anyone else that has done this before., beside Apple with the Iphone.
 
  • #19
How are you generating and detecting the two wavelengths needed.
The finger clip is needed for pulse oximetry to prevent movement artifacts.
 
  • #20
Baluncore said:
How are you generating and detecting the two wavelengths needed.
The finger clip is needed for pulse oximetry to prevent movement artifacts.
 
  • #21
Apple does it with just a camera:

https://apps.apple.com/us/app/instant-heart-rate-hr-monitor/id409625068

What do you mean by " have I generating and detecting the two wavelengths needed?"Do you mean have I synthesize the waveform in a simulator and run that through my code to see if I can detect the Heart rate ?

no, but that is a really good idea.

thanks
 
  • #22
Baluncore said:
How are you generating and detecting the two wavelengths needed.
The finger clip is needed for pulse oximetry to prevent movement artifacts.
I think you are thinking of the two wavelengths at which oxyhemoglobin and deoxyhemoglobin have absorption peaks. These are needed for the "oximeter" function of the instrument to determine the ratio of oxygenated blood cells to blood cells without oxygen. OP is interested in the "pulse" function of the instrument.

@btb4198: How does your program decide that it is looking at a frame of your thumb when the pulse is on as opposed to off?
 
  • #23
kuruman said:
OP is interested in the "pulse" function of the instrument.
Then this is not "Pulse Oximetry" as it said in the title.
Simply blocking the entire camera with your thumb, out of focus, will be sufficient to read the light transmission. But remember that there is no pulse in the finger tip surface so the light must pass through the nail bed.
 
  • #24
Baluncore said:
Then this is not "Pulse Oximetry" as it said in the title.
Simply blocking the entire camera with your thumb, out of focus, will be sufficient to read the light transmission. But remember that there is no pulse in the finger tip surface so the light must pass through the nail bed.
I bought a commercial pulse oximeter when it became de riguer to own one 14 months ago. It gives readings of both my pulse and my O2 level. I assumed that when I clamp the instrument to my finger, the oxygen saturation level is measured by looking at the ratio of absorbance of two wavelengths while the pulse measurement is performed by some type of transducer, probably piezoelectric. OP proposes is using light to measure pulse which is an admixture of the pulse oximeter's functions. That is why I suggested a blank measurement and then at a later posting asked OP to explain what detectable change occurs in the photograph that is interpreted by the analyzing program as a pulse.
 
  • #25
The OP apparently does PPG Photoplethysmography, its essentially the same type of sensor as used in oximetriy, in that it measures variations in optical variations due to pulsations of blood. The diffence is that a full blown oximeter usually has a couple of wavelenghts and is calibrated to get te SpO2 from the PPG signal but cheaper devices, just gets you a simple uncalibrated "PPG signal", from which you can infer pulserate. An even simlper method is to use a regular camera and white light (like a mobile phone and the pulse-app).

In labs, typicaly PPG signal is LP filtered at 3-10Hz, and HP filtered at 0.05-0.5Hz is used to get rid of any baselinedrift. Its usually done in the amplifier. But motion artifacts are usually not easy to filter out.

Motion artifacts is likely even more of a problem if using a regular camera with white light.

But the general method for deciding best artifact or filtering method, means first oversample the full signal and inspect it. If you have spiky noise, a moving median filter can be nice, to prevent energy from spikes affecting the smoothed signal. You can even apply median filtering to the HR signal, to filter out ectopic beats. Then the median windows would be at least 3 heartbeats, assuming you do not several ectopics in a row. Motion artifacts are not always easy to get rid of, the solution is to control the measurement better.

/Fredrik
 
  • Like
Likes Tom.G and berkeman

1. How can I ensure accurate placement of the pulse oximeter probe?

To ensure accurate placement of the pulse oximeter probe, it is important to follow the manufacturer's instructions and place the probe on a well-perfused area, such as the finger, earlobe, or toe. Make sure the probe is secured tightly and not obstructed by any clothing or movement.

2. What factors can affect the accuracy of pulse oximetry measurements?

Factors such as poor circulation, nail polish, dark skin pigmentation, and movement can affect the accuracy of pulse oximetry measurements. It is important to take these factors into consideration and try to minimize their impact when using a pulse oximeter.

3. Can using a pulse oximeter in high altitudes affect the accuracy of the readings?

Yes, using a pulse oximeter in high altitudes can affect the accuracy of the readings. The lower oxygen levels at high altitudes can result in lower oxygen saturation readings. It is important to consult with a healthcare professional for proper interpretation of pulse oximetry measurements in high altitude settings.

4. How can I improve the accuracy of pulse oximetry measurements in patients with low perfusion?

In patients with low perfusion, it can be challenging to obtain accurate pulse oximetry measurements. To improve accuracy, try using a different site for the probe placement, such as the earlobe or forehead. It may also be helpful to warm the patient's hands or feet to improve circulation.

5. What should I do if the pulse oximeter readings do not match the patient's clinical condition?

If the pulse oximeter readings do not match the patient's clinical condition, it is important to assess the patient's overall condition and vital signs. If there is a discrepancy between the pulse oximeter readings and the patient's clinical status, it is recommended to confirm with another method of oxygenation measurement, such as arterial blood gas analysis.

Similar threads

Replies
7
Views
3K
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
1K
  • Electrical Engineering
Replies
9
Views
1K
Replies
1
Views
527
  • Nuclear Engineering
Replies
25
Views
3K
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
19
Views
3K
Back
Top