The effect of functional groups on the sphere-to-wormlike micellar transition in quaternary ammonium surfactant solutions