Monitoring respiratory mechanics during assisted ventilation