MAGIC: a MATLAB Toolbox for External Control of Transcranial Magnetic Stimulation Devices
The capacity to externally control transcranial magnetic stimulation (TMS) devices is becoming increasingly important in brain stimulation research. Here we introduce MAGIC (MAGnetic stimulator Interface Controller), an open-source MATLAB toolbox for controlling Magstim and MagVenture stimulators. MAGIC includes a series of MATLAB functions which allow the user to arm/disarm the stimulator, send triggers, change stimulator settings such as amplitude, interpulse intervals, and frequency, and receive stimulator setting information via a serial port connection between a computer and the stimulator. By providing external control capability, MAGIC enables greater flexibility in designing research protocols which require trial-by-trial changes of device settings to realize a priori trial randomization or interactive ad hoc adjustment of parameters during an ongoing experiment. MAGIC thus helps to prevent experimental confounds related to the block-wise variation of parameters and facilitates the integration of TMS with cognitive/sensory tasks, and the development of more adaptive brain state-dependent brain stimulation protocols.