I have a script to program stg1 to do a stimulation pattern:
e.g. durations = [200,200, 1000000, 200, 200, 2000000, 200, 200, 1500000,, etc] and
eg. amplitudes = [-20000, +20000, 0, -20000, +20000, 0, -20000, +20000, 0,,etc] zero being interstimulus intervals
Now I want to create a timestamp for my recording (in matlab) on each stimulation (200, 200) based on the time the actual stimulation was given by the CStg. Is it possible read from the device wheter or not a stimulation was given. or do I have to assume that the stimulation actual will be given (or derive from the stimulus artifact)?
kind regards,
Gerco
My Matlab program to program the Cstg:
function stimulate_electrode_repeatedly( devicelist, electrode, channelorder, stimtype, amplitude, duration)
electrode=find(channelorder==electrode)-1;% MCS=0:59, matlab=1:60
if devicelist.Count == 0
Msgbox('No MEA USB Device connected!', 'Error Connecting To Device', 'error');
end
%for electrode = 0 : 60
%electrode =1
cStgDevice=Mcs.Usb.CStg200xDownloadNet();
% Connect to the stimulator of the device. The lock mask allows multiple connections to the same device
status = cStgDevice.Connect(devicelist.GetUsbListEntry(0),1); % ,1) is the lockmask
if status == 0
% Make sure that the stimulation is stopped
cStgDevice.SendStop(uint32(1));
% ElectrodeMode: emManual: electrode is permanently selected
% for stimulation or emAutomatic for automatic
cStgDevice.SetElectrodeMode(electrode, Mcs.Usb.ElectrodeModeEnumNet.emManual);
% ElectrodeDacMux: DAC to use for stimulation
% cStgDevice.SetElectrodeDacMux(electrode,0,0);% required to reset the dacmux in between stimulations
%cStgDevice.SetElectrodeDacMux(electrode-5,0, Mcs.Usb.ElectrodeDacMuxEnumNet.Stg1);% (electrode, index=0, dac)
cStgDevice.SetElectrodeDacMux(electrode,0, Mcs.Usb.ElectrodeDacMuxEnumNet.Stg1)
% 0 = Ground
% 1 = Stg1
% 2 = Stg2
% 3 = Stg3
% ElectrodeEnable: enable electrode for stimulation
cStgDevice.SetElectrodeEnable(electrode, 0, true);
% BlankingEnable: false: do not blank the ADC signal while stimulation is running
cStgDevice.SetBlankingEnable(electrode, true);
% AmplifierProtectionSwitch: false: Keep ADC connected to electrode even while stimulation is running
cStgDevice.SetEnableAmplifierProtectionSwitch(electrode, true);
if stimtype=='nA'
% use current stimulation
cStgDevice.SetCurrentMode();
else
% use voltage stimulation
cStgDevice.SetVoltageMode();
disp('uV');
end
% send stimulus data to device
% Prepare and send data to a given channel on the STG. Previous data sent to that channel is erased first.
% Each datapoint is represented by an signed 32bit integer value. When using voltage stimulation, the values are in multiple of 1 uV, thus the possible range is += 2000 V. When using current stimulation, the values are in multiple of 1 nA, this the possible range is += 2000 mA.
% The duration is given as a list of 64 bit integers. Durations are given in units of µs. The STG has a resolution of 20 µs.
% Blocks of data which should repeat can be defined by prepending such a block with an entry in the arrays where both amplitude and duration is zero. The end of such an block is marked by an entry where the duration is set to zero and the amplitude beeing set to the number of times the block should run. Blocks can be nested.
%
% Parameters:
% channel The channel number to send data to.
% amplitude A list of amplitudes in units of µV and nA in voltage and current mode, respectively.
% duration A list of durations in units of µs.
% destType specifies wheather the data is for syncout, current or voltage stimulation.
if stimtype =='nA'
cStgDevice.PrepareAndSendData(0, NET.convertArray(amplitude', 'System.Int32'), NET.convertArray(duration, 'System.UInt64'), Mcs.Usb.STG_DestinationEnumNet.channeldata_current);
else
cStgDevice.PrepareAndSendData(0, NET.convertArray(amplitude', 'System.Int32'), NET.convertArray(duration, 'System.UInt64'), Mcs.Usb.STG_DestinationEnumNet.channeldata_voltage);
end
% connect all stimulation channels to the first trigger and repeat the
% pulse 1 times
cStgDevice.SetupTrigger(0, NET.convertArray(255, 'System.UInt32'), NET.convertArray(255, 'System.UInt32'), NET.convertArray(2, 'System.UInt32'));
% very important to use the Net.convertArray functiosn, since Matlab Uint32 itself does not translate correctly apparantly
% start the first trigger
cStgDevice.SendStart(uint32(2));
cStgDevice.Disconnect(); % ,1)
disp(['electrode ' num2str(electrode+1) ' (' num2str(channelorder(electrode+1)) ') will be stimulated!']);
else
disp ('connection failed');
disp (dec2hex(status));
disp (Mcs.Usb.CMcsUsbNet.GetErrorText(status));
end
I have a script to program stg1 to do a stimulation pattern: e.g. durations = [200,200, 1000000, 200, 200, 2000000, 200, 200, 1500000,, etc] and eg. amplitudes = [-20000, +20000, 0, -20000, +20000, 0, -20000, +20000, 0,,etc] zero being interstimulus intervals
Now I want to create a timestamp for my recording (in matlab) on each stimulation (200, 200) based on the time the actual stimulation was given by the CStg. Is it possible read from the device wheter or not a stimulation was given. or do I have to assume that the stimulation actual will be given (or derive from the stimulus artifact)?
kind regards,
Gerco
My Matlab program to program the Cstg: