I would have a separate section of code to measure the resistance when the subject is not breathing in. You could have a button for the subject to press, which would call that procedure.
If the sensor resistance increases when breathing in, another approach would be to calculate the minimum/maximum values for the first few breaths, and set the threshold to the minimum.