A method and apparatus for detecting and removing air from a syringe containing a volume of liquid and a volume of gas is described. The method includes moving a piston in the syringe to expel gas through an orifice of the syringe, sensing a movement of the piston in the syringe, and determining when the volume of gas is expelled from the syringe based on a change in the sensed movement. Moving the piston may include applying oscillating force to the piston using an electromagnetic actuator, and displacement and speed of the piston during each oscillation may be sensed. Determining when the volume of gas is expelled may be based on a change in the sensed movement of the piston during one or more oscillations of the piston or based on a comparison to a given reference value.