Open xxh4088 opened 2 years ago
from argparse import Namespace import time import os import pythonnet from System import Action from System import * import System import clr clr.AddReference(os.getcwd() + './data/McsUsbNet.dll') from Mcs.Usb import CMcsUsbListNet from Mcs.Usb import DeviceEnumNet from Mcs.Usb import CStg200xDownloadNet from Mcs.Usb import McsBusTypeEnumNet from Mcs.Usb import STG_DestinationEnumNet from Mcs.Usb import SendStop
deviceList = CMcsUsbListNet(DeviceEnumNet.MCS_DEVICE_USB) print("found %d devices" % (deviceList.Count)) for i in range(deviceList.Count): listEntry = deviceList.GetUsbListEntry(i) print("Device: %s Serial: %s time:%s" % (listEntry.DeviceName,listEntry.SerialNumber,i))
device = CStg200xDownloadNet() device.Connect(deviceList.GetUsbListEntry(0))
device.SendStop(uint32(1)) electrode=256 device.SetElectrodeMode(electrode, Mcs.Usb.ElectrodeModeEnumNet.emManual); device.SetElectrodeDacMux(electrode,0, Mcs.Usb.ElectrodeDacMuxEnumNet.Stg1); device.SetElectrodeEnable(electrode, 0, true); device.SetBlankingEnable(electrode, false); device.SetEnableAmplifierProtectionSwitch(electrode, false); amplitude_array = int32([50, -50]); duration_array = uint64([1000, 1000]); device.SetVoltageMode(); device.PrepareAndSendData(256, amplitude, duration, STG_DestinationEnumNet.channeldata_voltage); channelmap = new uint[] { 255 } syncoutmap = new uint[] { 255 } repeat = new uint[] {3} device.SetupTrigger(0,channelmap, syncoutmap, repeat); device.SendStart(uint32(1)); device.Disconnect() print("Stimulation finished!")
Please teach me how to modify the code to implement custom stimulation electrodes to stimulate brain organoids。
and how to control the pattern of stimulating electrical signals.
import time import clr
from System import Action from System import *
clr.AddReference('C:\Users\45c\Downloads\McsUsbNet-5.1.6\McsUsbNet-5.1.6\x64\McsUsbNet.dll') from Mcs.Usb import CMcsUsbListNet from Mcs.Usb import DeviceEnumNet
from Mcs.Usb import CStg200xDownloadNet from Mcs.Usb import McsBusTypeEnumNet from Mcs.Usb import STG_DestinationEnumNet from Mcs.Usb import ElectrodeModeEnumNet from Mcs.Usb import ElectrodeDacMuxEnumNet
def PollHandler(status, stgStatusNet, index_list): print('%x %s' % (status, str(stgStatusNet.TiggerStatus[0])))
deviceList = CMcsUsbListNet(DeviceEnumNet.MCS_DEVICE_USB)
print("found %d devices" % (deviceList.Count))
for i in range(deviceList.Count): listEntry = deviceList.GetUsbListEntry(i) print("Device: %s Serial: %s" % (listEntry.DeviceName,listEntry.SerialNumber))
device = CStg200xDownloadNet();
device.Stg200xPollStatusEvent += PollHandler;
device.Connect(deviceList.GetUsbListEntry(0))
voltageRange = device.GetVoltageRangeInMicroVolt(0); voltageResulution = device.GetVoltageResolutionInMicroVolt(0); currentRange = device.GetCurrentRangeInNanoAmp(0); currentResolution = device.GetCurrentResolutionInNanoAmp(0);
print('Voltage Mode: Range: %d mV Resolution: %1.2f mV' % (voltageRange/1000, voltageResulution/1000.0)) print('Current Mode: Range: %d uA Resolution: %1.2f uA' % (currentRange/1000, currentResolution/1000.0))
channelmap = ArrayUInt32 syncoutmap = ArrayUInt32 repeat = ArrayUInt32
amplitude = [ArrayInt32,ArrayInt32,ArrayInt32] duration = [ArrayUInt64,ArrayUInt64,ArrayUInt64]
electrode = [3,1,52] #Some list of electrodes I desire to stimulate
for elec in range(len(electrode)):
device.SetElectrodeMode(UInt32(electrode[elec]), ElectrodeModeEnumNet.emManual)
device.SetElectrodeDacMux(UInt32(electrode[elec]), UInt32(0), ElectrodeDacMuxEnumNet.Stg1)
device.SetElectrodeEnable(UInt32(electrode[elec]), UInt32(0), True);
device.SetBlankingEnable(UInt32(electrode[elec]), False);
# AmplifierProtectionSwitch: false: Keep ADC connected to electrode even while stimulation is running
device.SetEnableAmplifierProtectionSwitch(UInt32(electrode[elec]), False);
device.PrepareAndSendData(0, amplitude[elec], duration[elec], STG_DestinationEnumNet.channeldata_voltage)
device.SetupTrigger(0, channelmap, syncoutmap, repeat) device.SetVoltageMode();
device.SendStart(1) time.sleep(10)
device.Disconnect()
I feel that there may be some problems in my understanding, I hope there are some answers。
now,I still have this problem。 Device Handle Invalid 在 Mcs.Usb.CStg200xBasicNet.SetElectrodeMode(UInt32 electrode, ElectrodeModeEnumNet mode)
in the electrodes that define the DAC device. SetElectrodeDacMux(electrode,0, Mcs.Usb.ElectrodeDacMuxEnumNet.Stg1); Does this 0 mean the index of the list mode? I don't see the creation of list mode in the example. Hope for a detailed explanation
Just ignore the list mode option and always use 0 for the list mode index. We are not going to support list mode.
Also, can tell me more specific input about device.SetupTrigger(0, channelmap, syncoutmap, repeat). For example, in channelmap, the array we input is a one-dimensional array of 0 and 1. Does 1 represent the electrode corresponding to the stimulus? Again entering 255 means connect all stimulation channels to the first trigger and repeat. Then I hope to realize how to use python to control the MEA2100_256 to stimulate only the electrodes I want to stimulate.
Yes 255 means the first 8 stimulation channels are connected to trigger 1 and the same repeat. This example is meant for the MEA2100-Mini that has 2 channels per HS (4) = 8 channels. The MEA2100-256 has 2 stimulation channels. From this 3 as channel map would be enough. However 255 does not hurt.
Please, consider to look into our C# examples, especially into our recent one "MEA2100_Recording_and_Stimulation".
As far as I'm concerned, this number of channels represents different positions in the Multi Channel Experimenter software's 16*16 matrix
How do we control for the location of the stimulus
And just like that I want to stimulate my designated channel
The MEA2100-256 has two stimulation channels STG1 and STG2. Where the channel is connected to is done with the commands: SetElectrodeMode, SetElectrodeDacMux, SetElectrodeEnable, SetBlankingEnable, SetEnableAmplifierProtectionSwitch which define the behaviour of the switches before and during stimulation.
So if you define the pattern, you can maximal define it for two channels 0 (STG1) and 1(STG2) The electrode number are hardware channel numbers, you need to convert a certain location on the MEA to the hardware channel ID by using the channel map of the MEA.
device.SendStop(UInt32(1)) amplitude = ArrayInt32 duration = ArrayUInt64 electrode = [24,25,26,27,28,29,30] for elec in range(len(electrode)): device.SetElectrodeMode(System.UInt32(electrode[elec]), ElectrodeModeEnumNet.emManual) device.SetElectrodeDacMux(UInt32(electrode[elec]),UInt32(0), ElectrodeDacMuxEnumNet.Stg1) device.SetElectrodeEnable(UInt32(electrode[elec]), UInt32(0), True); device.SetBlankingEnable(UInt32(electrode[elec]),False); device.SetEnableAmplifierProtectionSwitch(UInt32(electrode[elec]), False);
Can I use this to stimulate different locations
How should I use MEA channel diagram to convert a location on MEA to hardware channel ID.
Can you give me an example
I would recommend to set all electrodes either to stimulation or no stimulation (Have you look in our new C# example, where this is done) You can define this way also several electrodes, where you want to stimulate. What actual values are you setting amplitude and duration to, to define the stimulus? Please look into the Multi Channel Experimeter files: c:\Program Files\Multi Channel Experimenter\ConfigFiles\ Depending on your adapter you will find a mapping file for the MEA2100-256
I still don't understand this example because I haven't studied C# specifically
Whether the i here is where we want to stimulate
Therefore, the maximum value of i is 255. i can select multiple I positions as stimulus points through the for loop, and finally use a stimulus channel to stimulate
Hello, Now I am trying to use python to control the MEA2100_256 to achieve electrical stimulation of brain organoids.maybe a bit of a newbie question, but I do not really find the given explanations helpful so far. I still don't understand something in the code after reading the manual and samples.
in the electrodes that define the DAC device. SetElectrodeDacMux(electrode,0, Mcs.Usb.ElectrodeDacMuxEnumNet.Stg1); Does this 0 mean the index of the list mode? I don't see the creation of list mode in the example. Hope for a detailed explanation
Also, can tell me more specific input about device.SetupTrigger(0, channelmap, syncoutmap, repeat). For example, in channelmap, the array we input is a one-dimensional array of 0 and 1. Does 1 represent the electrode corresponding to the stimulus? Again entering 255 means connect all stimulation channels to the first trigger and repeat. Then I hope to realize how to use python to control the MEA2100_256 to stimulate only the electrodes I want to stimulate.