This function is for using with a linear respiratory signal, usually meaning data produced with transducer breath belts. The function is optimised for speech breathing in particular. For example, we have found from comparison with the acoustic speech spectrogram that speech-related inhalations often end before local maxima in the respiratory signal. breathTimes therefore performs slope grade analysis, among other steps, to search for abrupt reductions in the steepness of the positive-going signal, as opposed to absolute peaks. Similarly, inhalation onsets are not determined via the absolute minima or valleys in the respiratory signal, but rather based on contextual slope thresholds.
breathTimes returns two time series: the first is for the initiations of inhalations, and the second is for the ending of inhalations. You can also optionally plot the results, to make sure the parameters are appropriate for your data. See comments for documentation.
I strongly recommend you combine this approach with speech analysis (i.e., using my other function Acoustic Landmarks) so that you can cross-corroborate and be sure your respiratory signal is doing what you think it is (for example, some peaks are in reality associated with exhalation during vocalisation, and not inhalation). Example Usage: [onsets,offsets] = ...
breathTimes(vector,Fs,'WinSz',20,'MinDur',100,'MinHeight',0.1,'Plot',1)