Sample preparation before analysis