Improved pattern recognition with magnetic field