Remove negative slopes from signal I'm very new to signal processing, and have been struggling this far. I've a rather messy signal measuring respiration using some chest bands and would like to focus solely on the inspiratory half of the data - ie. set the beginning of each inspiration to zero while maintaining the inspiratory amplitude of each breath.

I've attached an example (upslope is inspiration, downslope is expiraion), and have tried various ways of detecting the change in slope indicating the beginning and end of inspiration but keep getting tripped up by small deviations/noise in the signal. Any help would be appreciated.

Edit: https://docs.google.com/open?id=0B84oZTKp4RZ3LS1mdTBCLTJRdEU 

Edit: pictures, hopefully better description:

When everything's going smoothly the it should be recording roughly 10-20breaths per minute.



But when the patient coughs/moves it looks something like:



Since I'm mostly interested in the magnitude of each breath, my thinking is that resetting each the start of each breath to zero is an easy (so to speak) way to rid of that upward drift after a cough.

In the worst cases I lose the respiratory signal all together. This I'd like to discard and pick up any redeemable signal as soon as possible.



Please let me know if there's anything else I can provide for an answer!

Thanks muchly.
I would not do slope detection, I have spend a lot of time solving a similar problem and slope detection didn't work for me. 

I have a few suggestions:


Do a moving average, this would act as a filter and smooth the signal. Especially, your signal is slow, so you can oversample and easily do a moving average. Realize, this will shift your peaks.
If you must get the peaks in precision, do a BPF, this would take out all HF noise and DC. 
Assuming you are measuring lung capacity, seek out the peak and dip points and subtract 
them to find out the magnitude, don't assume a bias and try to calculate from there. It sounds like you have a virtual zero point and your try to see how much the amplitude of the signal. You can divide the result by two to get what you want. 


You can do BPF and last together and you can get a clean measurement out of it.