Plastic bag is high compliance but poor measurement. Piston is accurate measurement but high stiffness. Non-linear movements are more complex to counterbalance. Measure flow as pressure drop across a flow resistance. Normal flow rates and hence pressures are well below this.
Resistance is usually a mesh or series of small tubes in a large area to limit turbulence.
Inbuilt microprocessors allow for some correction of non-linearity and for temperature, pressure, water vapour content. See here . Baseline of integration over multiple cycles is difficult. Due to absorption of and release of gases, the inhaled and exhaled volumes can actually be different when the blood gases are not in equilibrium. Sometimes just add a reset volume at the reversal of flow.