-
Notifications
You must be signed in to change notification settings - Fork 9
6. DuoMag Class
The duomag.m class is used for communicating with various DuoMag stimulators. Different built-in methods in this class will empower you to have master control over your device.
To start working with the DuoMag class, you need to first create an object of the class. This object will then be passed to each method as the primary input. The object will be constructed by defining the serial port using which you are intending to connect to your device.
duomagObject = duomag('PortID');
This line of code will check your computer to find the intended port and hold it as the main object of the class. Next, to start working with the toolbox, you need to connect to the desired port already defined in your duomagObject.
Using the next line of script, you will be connecting to the serial port and maintaining your connection unless an error occurs or until you manually disconnect it yourself.
duomag.connect(duomagObject); or simply duomagObject.connect();
As previously mentioned, you can easily disconnect the device from your computer using the following command line:
duomag.disconnect(duomagObject); or simply duomagObject.disconnect();
In all the following commands, you can retrieve two outputs, one indicating the success or failure of the process (errorOrSuccess) and the other would be the device response (deviceResponse) which is a cell struct giving you details on the current parameters of the stimulator.
You can choose to retrieve the device response by setting the getresponse variable, which is the last input in all functions, to 1. The default value for this input is set to 0 in all the functions.
After establishing your communication with the stimulator, you can now easily utilize all the available commands depending on the version and model of your device. In the following, you will find separate introductions for each of the commands.
To get the stimulator's current status and parameters, there are two built-in methods in this class. Each will provide specific information about the device based on the released MagPro data transmisson.
duomagObject.getStatus();
To set the desired amplitude for coil A and/or coil B (in dual or twin mode) you can use the following function by defining your desired amplitudes in percentage. In dual or twin mode, the variable desiredAmplitudes would be a vector of length two.
duomagObject.setAmplitude(desiredAmplitudes);
To send a single trigger to the stimulator, you can call:
duomagObject.fire();
This function allows you to set a delay in recharging timing of your device.
duomagObject.setChargeDelay(chargeDelay);
chargeDelay {int}: defines the time in milliseconds to make the device wait, before recharging. The chargeDelay must be a factor of 00.05 ,00.10, 00.20, 00.50, 01.00, 02.00, 05.00 or 10.00 ms otherwise the process is unsuccessful or partially correct.
This function allows you to set a delay in TTL OUT of your Duo Mag device.
duomagObject.set_TriggerOutDelay(triggerOutDelay);
triggerOutDelay {int}: defines the time in milliseconds to make the device wait, before recharging. The triggerOutDelay must be a factor of 00.05 ,00.10, 00.20, 00.50, 01.00, 02.00, 05.00 or 10.00 ms otherwise the process is unsuccessful or partially correct.