Optimal design of patient specific templates for pedicle spine screw placement