What is the primary purpose of intraoperative neurophysiological monitoring (IONM) during neurosurgery?