<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dmehta</id>
	<title>BCI2000 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dmehta"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Dmehta"/>
	<updated>2026-06-29T19:53:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=11351</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=11351"/>
		<updated>2024-05-23T19:46:55Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
Stimulation has not been implemented yet.&lt;br /&gt;
&lt;br /&gt;
There may be some block timing issues only visually due to how data is being acquired in BCPy2000. In practice, the data acquired is valid.&lt;br /&gt;
&lt;br /&gt;
Some data streams may not be available depending on the device and the front-end used.&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Running the Source Module==&lt;br /&gt;
&lt;br /&gt;
===Initial Parameters===&lt;br /&gt;
Now that you have installed the source module, you can begin testing to make sure that data is being acquired. Before you test the source module, you can make sure that a signal is being passed through by using the Trellis application provided by Ripple. This will eliminate any doubt about whether data is actually being acquired in the first place, since you will be able to see a signal generated in Trellis.&lt;br /&gt;
&lt;br /&gt;
Next, double click on the batch file to start the source module. Here you will be able to configure parameters and even save them as a file to load in for future experiment runs. &lt;br /&gt;
&lt;br /&gt;
First, you can decide the number of source channels. This is going to be the same as the number of electrodes that you would like a signal to be acquired and visualized from. &lt;br /&gt;
&lt;br /&gt;
Next, you can choose the number of samples to be acquired per acquisition block with the sample block size. &lt;br /&gt;
&lt;br /&gt;
Next, you must decide which data acquisition function you would like to choose. The six options are raw, lfp, hifreq, hires, emg, and status. The specifics of these data streams are covered in the Ripple manual. The important thing to note is that the choices for macro and micro are both &amp;quot;raw&amp;quot;. Macro and micro depends on which front-end you are using.&lt;br /&gt;
&lt;br /&gt;
Next, we must check that the sampling rate matches the sampling rate of the data acquisition function you choose. The frequencies are listed in the Parameters section of this wiki. It is important that they match otherwise you will get errors on data acquisition. &lt;br /&gt;
&lt;br /&gt;
The final thing to change would be which specific electrodes to acquire data from, via the specific channel parameter. Here, you set put the electrodes in a 0-indexed list (electrode 1 is 0, electrode 2 is 1, etc.). The length of this list must match the number of source channels you put earlier. Otherwise, this list will be overwritten during preflight.&lt;br /&gt;
&lt;br /&gt;
You can also change other parameters as detailed in the parameter guide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Source_Parameters.png|Source Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulation===&lt;br /&gt;
&lt;br /&gt;
If you would like to use stimulation with your Ripple device, there is a separate parameter tab where you can create stimulation segments, sequences, triggers, and trains. This is still currently under development.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Stimulation_Parameters.png|Stimulation Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| macro || 15&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|-&lt;br /&gt;
| micro || 30&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=11350</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=11350"/>
		<updated>2024-05-23T19:45:22Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* DataStream */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Running the Source Module==&lt;br /&gt;
&lt;br /&gt;
===Initial Parameters===&lt;br /&gt;
Now that you have installed the source module, you can begin testing to make sure that data is being acquired. Before you test the source module, you can make sure that a signal is being passed through by using the Trellis application provided by Ripple. This will eliminate any doubt about whether data is actually being acquired in the first place, since you will be able to see a signal generated in Trellis.&lt;br /&gt;
&lt;br /&gt;
Next, double click on the batch file to start the source module. Here you will be able to configure parameters and even save them as a file to load in for future experiment runs. &lt;br /&gt;
&lt;br /&gt;
First, you can decide the number of source channels. This is going to be the same as the number of electrodes that you would like a signal to be acquired and visualized from. &lt;br /&gt;
&lt;br /&gt;
Next, you can choose the number of samples to be acquired per acquisition block with the sample block size. &lt;br /&gt;
&lt;br /&gt;
Next, you must decide which data acquisition function you would like to choose. The six options are raw, lfp, hifreq, hires, emg, and status. The specifics of these data streams are covered in the Ripple manual. The important thing to note is that the choices for macro and micro are both &amp;quot;raw&amp;quot;. Macro and micro depends on which front-end you are using.&lt;br /&gt;
&lt;br /&gt;
Next, we must check that the sampling rate matches the sampling rate of the data acquisition function you choose. The frequencies are listed in the Parameters section of this wiki. It is important that they match otherwise you will get errors on data acquisition. &lt;br /&gt;
&lt;br /&gt;
The final thing to change would be which specific electrodes to acquire data from, via the specific channel parameter. Here, you set put the electrodes in a 0-indexed list (electrode 1 is 0, electrode 2 is 1, etc.). The length of this list must match the number of source channels you put earlier. Otherwise, this list will be overwritten during preflight.&lt;br /&gt;
&lt;br /&gt;
You can also change other parameters as detailed in the parameter guide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Source_Parameters.png|Source Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulation===&lt;br /&gt;
&lt;br /&gt;
If you would like to use stimulation with your Ripple device, there is a separate parameter tab where you can create stimulation segments, sequences, triggers, and trains. This is still currently under development.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Stimulation_Parameters.png|Stimulation Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| macro || 15&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|-&lt;br /&gt;
| micro || 30&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11349</id>
		<title>Contributions:eegoRTADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11349"/>
		<updated>2024-05-23T19:44:22Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK and the eego MyLab amplifier (EE-225)&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There is currently an issue where trying to access the amplifier&#039;s information results in &amp;quot;need an initialized sdk context&amp;quot;. During testing, the amplifier wouldn&#039;t power on after some time, thus, this is most likely due to an issue with the amplifier not being powered on properly. The amplifier is able to be recognized via USB after drivers are installed properly. When drivers are not installed properly, there is an error stating &amp;quot;amplifier list empty&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the SDK manual provided by ANT neuro for more detail. This wiki guide will give a brief overview of the steps needed to work with BCI2000.&lt;br /&gt;
&lt;br /&gt;
First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
Next, we will set up the device. This guide will go over setting up the device on a Windows system. If you use Linux, please refer to the manual. &lt;br /&gt;
&lt;br /&gt;
When you first plug in the device into the computer via USB, you must first go to Device Manager and find the listed device under &amp;quot;Other Devices&amp;quot;. Right Click on the device and then choose &amp;quot;Update Drivers&amp;quot;. Then click &amp;quot;Browse my computer for drivers&amp;quot;. Navigate to the location of the SDK provided to you by ANT Neuro on your computer. Then, the drivers will be located in &amp;quot;SDK_ROOT/windows/driver&amp;quot;. Click &amp;quot;Next&amp;quot; and &amp;quot;Close&amp;quot;. Your device should now be listed under &amp;quot;Medical Imagining Solutions&amp;quot; as &amp;quot;eego amplifier&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===Source Tab===&lt;br /&gt;
====Signal Properties====&lt;br /&gt;
*&#039;&#039;&#039;SourceCh&#039;&#039;&#039; - This parameter should be &amp;quot;auto&amp;quot;, as it is determined by the amplifier. Can also be set by user if specific channel only is desired.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SampleBlockSize&#039;&#039;&#039; - Cannot be set nor retrieved by the SDK. Automatically is set at 32. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SamplingRate&#039;&#039;&#039; - Depending on the amplifier being used, there are specific sampling rates allowed. If the sampling rate is different, and error will be thrown. Valid values are among: 500, 512, 1000, 1024, 2000, 2048, 4000, 4096, 8000, 8192, 16000, and 16384. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;ChannelNames&#039;&#039;&#039; - Can be manually written by user, but &#039;auto&#039; is simpler.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SourceChOffset&#039;&#039;&#039; - Use &#039;auto&#039;. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SourceChGain&#039;&#039;&#039; - Use &#039;auto&#039;.&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11348</id>
		<title>Contributions:eegoRTADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11348"/>
		<updated>2024-05-23T17:34:51Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK and the eego MyLab amplifier (EE-225)&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There is currently an issue where trying to access the amplifier&#039;s information results in &amp;quot;need an initialized sdk context&amp;quot;. During testing, the amplifier wouldn&#039;t power on after some time, thus, this is most likely due to an issue with the amplifier not being powered on properly. The amplifier is able to be recognized via USB after drivers are installed properly. When drivers are not installed properly, there is an error stating &amp;quot;amplifier list empty&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the SDK manual provided by ANT neuro for more detail. This wiki guide will give a brief overview of the steps needed to work with BCI2000.&lt;br /&gt;
&lt;br /&gt;
First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
Next, we will set up the device. This guide will go over setting up the device on a Windows system. If you use Linux, please refer to the manual. &lt;br /&gt;
&lt;br /&gt;
When you first plug in the device into the computer via USB, you must first go to Device Manager and find the listed device under &amp;quot;Other Devices&amp;quot;. Right Click on the device and then choose &amp;quot;Update Drivers&amp;quot;. Then click &amp;quot;Browse my computer for drivers&amp;quot;. Navigate to the location of the SDK provided to you by ANT Neuro on your computer. Then, the drivers will be located in &amp;quot;SDK_ROOT/windows/driver&amp;quot;. Click &amp;quot;Next&amp;quot; and &amp;quot;Close&amp;quot;. Your device should now be listed under &amp;quot;Medical Imagining Solutions&amp;quot; as &amp;quot;eego amplifier&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
===Source Tab===&lt;br /&gt;
====Signal Properties====&lt;br /&gt;
*&#039;&#039;&#039;SourceCh&#039;&#039;&#039; - This parameter should be &amp;quot;auto&amp;quot;, as it is determined by the size of the &amp;quot;RecordingChIDs&amp;quot; parameter.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SampleBlockSize&#039;&#039;&#039; - Number of samples that are transmitted at a time. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SamplingRate&#039;&#039;&#039; - Some channels on the Neuro Omega are recorded at different sampling rates, so this parameter is dictated by the configuration of the clinical system and must be manually entered accordingly. Information on how to check the sampling rate of a given channel is coming soon. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;ChannelNames&#039;&#039;&#039; - This should be set to auto, as the names of the channels will be automatically acquired from the Neuro Omega.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SourceChOffset&#039;&#039;&#039; - Use &#039;auto&#039;, or needs to be the length of number of channels in RecordingChIDs. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SourceChGain&#039;&#039;&#039; - Use &#039;auto&#039;, or needs to be the length of number of channels in RecordingChIDs. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;RecordingChIDs&#039;&#039;&#039; - This parameter should be a list of channel IDs corresponding to the channels you want to record from. Each of these channels must have the same sampling rate.&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11347</id>
		<title>Contributions:eegoRTADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11347"/>
		<updated>2024-05-23T17:26:58Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK and the eego MyLab amplifier (EE-225)&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There is currently an issue where trying to access the amplifier&#039;s information results in &amp;quot;need an initialized sdk context&amp;quot;. During testing, the amplifier wouldn&#039;t power on after some time, thus, this is most likely due to an issue with the amplifier not being powered on properly. The amplifier is able to be recognized via USB after drivers are installed properly. When drivers are not installed properly, there is an error stating &amp;quot;amplifier list empty&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the SDK manual provided by ANT neuro for more detail. This wiki guide will give a brief overview of the steps needed to work with BCI2000.&lt;br /&gt;
&lt;br /&gt;
First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
Next, we will set up the device. This guide will go over setting up the device on a Windows system. If you use Linux, please refer to the manual. &lt;br /&gt;
&lt;br /&gt;
When you first plug in the device into the computer via USB, you must first go to Device Manager and find the listed device under &amp;quot;Other Devices&amp;quot;. Right Click on the device and then choose &amp;quot;Update Drivers&amp;quot;. Then click &amp;quot;Browse my computer for drivers&amp;quot;. Navigate to the location of the SDK provided to you by ANT Neuro on your computer. Then, the drivers will be located in &amp;quot;SDK_ROOT/windows/driver&amp;quot;. Click &amp;quot;Next&amp;quot; and &amp;quot;Close&amp;quot;. Your device should now be listed under &amp;quot;Medical Imagining Solutions&amp;quot; as &amp;quot;eego amplifier&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11346</id>
		<title>Contributions:eegoRTADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11346"/>
		<updated>2024-05-23T16:39:02Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Initial Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK and the eego MyLab amplifier (EE-225)&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There is currently an issue where trying to access the amplifier&#039;s information results in &amp;quot;need an initialized sdk context&amp;quot;. During testing, the amplifier wouldn&#039;t power on after some time, thus, this is most likely due to an issue with the amplifier not being powered on properly. The amplifier is able to be recognized via USB after drivers are installed properly. When drivers are not installed properly, there is an error stating &amp;quot;amplifier list empty&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the SDK manual provided by ANT neuro for more detail. This wiki guide will give a brief overview of the steps needed to work with BCI2000.&lt;br /&gt;
&lt;br /&gt;
First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11345</id>
		<title>Contributions:eegoRTADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:eegoRTADC&amp;diff=11345"/>
		<updated>2024-05-23T16:36:06Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: Created page with &amp;quot;==Introduction== eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]  ==Video Overview==  ==Versioning==  ===Authors=== * Dhruva Mehta (mehta@neurotechcenter.org)  ===Version History=== * 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
eegoRTADC is a source module that allows for utilization of the eego product family from ANT neuro and its associated SDK within BCI2000. For more information on the eego product family, please visit [https://www.ant-neuro.com/products/eego_product_family this site]&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 5/23/2024 Initial testing done with Version 1.3.30.57172 of the eego SDK and the eego MyLab amplifier (EE-225)&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There is currently an issue where trying to access the amplifier&#039;s information results in &amp;quot;need an initialized sdk context&amp;quot;. During testing, the amplifier wouldn&#039;t power on after some time, thus, this is most likely due to an issue with the amplifier not being powered on properly. The amplifier is able to be recognized via USB after drivers are installed properly. When drivers are not installed properly, there is an error stating &amp;quot;amplifier list empty&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the SDK manual provided by ANT neuro for more detail. This wiki guide will give a brief overview of the steps needed to work with BCI2000.&lt;br /&gt;
&lt;br /&gt;
 First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:ADCs&amp;diff=11344</id>
		<title>Contributions:ADCs</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:ADCs&amp;diff=11344"/>
		<updated>2024-05-23T16:12:10Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following data acquisition filters are available in the [[Contributions:Contents|Contributions]] section of BCI2000:&lt;br /&gt;
&lt;br /&gt;
*[[Contributions:AmpServerProADC]]: Interface to the EGI AmpServerPro.&lt;br /&gt;
*[[Contributions:BioRadioADC]]: Interface to the BioRadio amplifer.&lt;br /&gt;
*[[Contributions:Biosemi2ADC]]: Interface to the Biosemi amplifier.&lt;br /&gt;
*[[Contributions:BioPacADC]]: Interface to the BioPac MP160 amplifier.&lt;br /&gt;
*[[Contributions:Blackrock]]: Interface Blackrock devices through CereLink.&lt;br /&gt;
*[[Contributions:B-Alert]]: Interface to B-Alert brain monitoring systems.&lt;br /&gt;
*[[Contributions:DAS_ADC]]: Interface to MeasurementComputing AD cards.&lt;br /&gt;
*[[Contributions:DTADC]]: Interface to Data Translation boards.&lt;br /&gt;
*[[CortecADC]]: Interface to the Cortec Brain Interchange.&lt;br /&gt;
*[[Contributions:eegoRTADC]]: Interface to the eego product family and SDK.&lt;br /&gt;
*[[Contributions:Emotiv]]: Interface to the Emotiv EPOC.&lt;br /&gt;
*[[Contributions:FieldTripBufferSource]]: Interface to the FieldTrip buffer.&lt;br /&gt;
*[[Contributions:FilePlayback]]: A source module that replays sessions from recorded data files.&lt;br /&gt;
*[[Contributions:gHIamp]]: Interface to the gHIamp.&lt;br /&gt;
*[[Contributions:gNautilus]]: Interface to the gNautilus bypassing the server&lt;br /&gt;
*[[Contributions:gNautilusNEEDAccess]]: Interface to the gNautilus via g.NEEDAccess.&lt;br /&gt;
*[[Contributions:MicroLeadsADC]]: Interface to the Micro-Leads Implant system.&lt;br /&gt;
*[[Contributions:MicromedADC]]: Interface to the Micromed EEG system.&lt;br /&gt;
*[[Contributions:ModularEEG]]: Interface to the ModularEEG system.&lt;br /&gt;
*[[Contributions:NeuralynxADC]]: Interface to Neuralynx systems.&lt;br /&gt;
*[[Contributions:NeuroOmegaADC]]: Interface to the AlphaOmega NeuroOmega.&lt;br /&gt;
*[[Contributions:NIADC]]: Interface to National Instruments boards.&lt;br /&gt;
*[[Contributions:NIDAQ-MX]]: Interface to National Instruments boards using the MX driver.&lt;br /&gt;
*[[Contributions:NIDAQLogger]]: Interface to multiple National Instruments DAQ boards using MX driver (INPUT ONLY).&lt;br /&gt;
*[[Contributions:NIDAQFilter]]: Interface to multiple National Instruments DAQ boards using MX driver (OUTPUT ONLY).&lt;br /&gt;
*[[Contributions:NeuroscanADC]]: Neuroscan Acquire socket protocol client.&lt;br /&gt;
*[[Contributions:NeuroscanAccessSDK]]: Interface to Neuroscan Direct Access SDK.&lt;br /&gt;
*[[Contributions:NeuroSky]]: Interface to Neurosky MindSet.&lt;br /&gt;
*[[Contributions:NicoletOne]]: Interface to NicoletOne nEEG series amplifiers.&lt;br /&gt;
*[[Contributions:ctfneurod]]: CTF RealTime to Neuroscan Acquire relay.&lt;br /&gt;
*[[Contributions:RDAClientADC]]: Brain Vision RDA socket protocol client.&lt;br /&gt;
*[[Contributions:TDTADC]]: Interface to Tucker-Davis Pentusa systems.&lt;br /&gt;
*[[Contributions:TMSiADC]]: Interface to TMSi Refa and Porti systems.&lt;br /&gt;
*[[Contributions:vAmpADC]]: Interface to Brain Products V-amp systems.&lt;br /&gt;
*[[Contributions:EnobioADC]]: Interface to Enobio sensor.&lt;br /&gt;
*[[Contributions:DSISerial]]: Interface to Dry Sensor Interface (DSI) EEG systems by Wearable Sensing.&lt;br /&gt;
*[[Contributions:MicRecorderFilter]]: Interface to the system soundcard, logging audio input.&lt;br /&gt;
*[[Contributions:actiCHamp]]: Interface to the Brain Products actiCHamp system.&lt;br /&gt;
*[[Contributions:actiCHampPlus]]: Interface to the Brain Products actiCHamp Plus system.&lt;br /&gt;
*[[Contributions:LiveAmpADC]]: Interface to the Brain Products LiveAmp system.&lt;br /&gt;
*[[Contributions:LSLSource]]: Interface to the Brain Products Hardware system.&lt;br /&gt;
*[[Contributions:OpenBCISource]]: Interface to the OpenBCI system.&lt;br /&gt;
*[[Contributions:OpenBCI_Module]]: Interface to the OpenBCI system.&lt;br /&gt;
*[[Contributions:NeuroSpark]]: Interface to NeuroSpark.&lt;br /&gt;
*[[Contributions:NeuSenW]]: Interface to NeuSenW.&lt;br /&gt;
*[[Contributions:LabJackADC]]: Interface to LabJack devices.&lt;br /&gt;
*[[Contributions:RipplePyADC]]: Interface to Ripple devices.&lt;br /&gt;
*[[Contributions:SerialWidgetADC]]: Interface to programmable Arduino-like devices.&lt;br /&gt;
*[[Contributions:FlexEEG]]: Interface (via NC_flexXADC filter) to the FlexEEG system by NeuroCONCISE Ltd.&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:How to use a Contributed Source Module]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contents]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:ADCs&amp;diff=11343</id>
		<title>Contributions:ADCs</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:ADCs&amp;diff=11343"/>
		<updated>2024-05-23T16:11:49Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The following data acquisition filters are available in the [[Contributions:Contents|Contributions]] section of BCI2000:&lt;br /&gt;
&lt;br /&gt;
*[[Contributions:AmpServerProADC]]: Interface to the EGI AmpServerPro.&lt;br /&gt;
*[[Contributions:BioRadioADC]]: Interface to the BioRadio amplifer.&lt;br /&gt;
*[[Contributions:Biosemi2ADC]]: Interface to the Biosemi amplifier.&lt;br /&gt;
*[[Contributions:BioPacADC]]: Interface to the BioPac MP160 amplifier.&lt;br /&gt;
*[[Contributions:Blackrock]]: Interface Blackrock devices through CereLink.&lt;br /&gt;
*[[Contributions:B-Alert]]: Interface to B-Alert brain monitoring systems.&lt;br /&gt;
*[[Contributions:DAS_ADC]]: Interface to MeasurementComputing AD cards.&lt;br /&gt;
*[[Contributions:DTADC]]: Interface to Data Translation boards.&lt;br /&gt;
*[[CortecADC]]: Interface to the Cortec Brain Interchange.&lt;br /&gt;
*[[Contriburtions:eegoRTADC]]: Interface to the eego product family and SDK.&lt;br /&gt;
*[[Contributions:Emotiv]]: Interface to the Emotiv EPOC.&lt;br /&gt;
*[[Contributions:FieldTripBufferSource]]: Interface to the FieldTrip buffer.&lt;br /&gt;
*[[Contributions:FilePlayback]]: A source module that replays sessions from recorded data files.&lt;br /&gt;
*[[Contributions:gHIamp]]: Interface to the gHIamp.&lt;br /&gt;
*[[Contributions:gNautilus]]: Interface to the gNautilus bypassing the server&lt;br /&gt;
*[[Contributions:gNautilusNEEDAccess]]: Interface to the gNautilus via g.NEEDAccess.&lt;br /&gt;
*[[Contributions:MicroLeadsADC]]: Interface to the Micro-Leads Implant system.&lt;br /&gt;
*[[Contributions:MicromedADC]]: Interface to the Micromed EEG system.&lt;br /&gt;
*[[Contributions:ModularEEG]]: Interface to the ModularEEG system.&lt;br /&gt;
*[[Contributions:NeuralynxADC]]: Interface to Neuralynx systems.&lt;br /&gt;
*[[Contributions:NeuroOmegaADC]]: Interface to the AlphaOmega NeuroOmega.&lt;br /&gt;
*[[Contributions:NIADC]]: Interface to National Instruments boards.&lt;br /&gt;
*[[Contributions:NIDAQ-MX]]: Interface to National Instruments boards using the MX driver.&lt;br /&gt;
*[[Contributions:NIDAQLogger]]: Interface to multiple National Instruments DAQ boards using MX driver (INPUT ONLY).&lt;br /&gt;
*[[Contributions:NIDAQFilter]]: Interface to multiple National Instruments DAQ boards using MX driver (OUTPUT ONLY).&lt;br /&gt;
*[[Contributions:NeuroscanADC]]: Neuroscan Acquire socket protocol client.&lt;br /&gt;
*[[Contributions:NeuroscanAccessSDK]]: Interface to Neuroscan Direct Access SDK.&lt;br /&gt;
*[[Contributions:NeuroSky]]: Interface to Neurosky MindSet.&lt;br /&gt;
*[[Contributions:NicoletOne]]: Interface to NicoletOne nEEG series amplifiers.&lt;br /&gt;
*[[Contributions:ctfneurod]]: CTF RealTime to Neuroscan Acquire relay.&lt;br /&gt;
*[[Contributions:RDAClientADC]]: Brain Vision RDA socket protocol client.&lt;br /&gt;
*[[Contributions:TDTADC]]: Interface to Tucker-Davis Pentusa systems.&lt;br /&gt;
*[[Contributions:TMSiADC]]: Interface to TMSi Refa and Porti systems.&lt;br /&gt;
*[[Contributions:vAmpADC]]: Interface to Brain Products V-amp systems.&lt;br /&gt;
*[[Contributions:EnobioADC]]: Interface to Enobio sensor.&lt;br /&gt;
*[[Contributions:DSISerial]]: Interface to Dry Sensor Interface (DSI) EEG systems by Wearable Sensing.&lt;br /&gt;
*[[Contributions:MicRecorderFilter]]: Interface to the system soundcard, logging audio input.&lt;br /&gt;
*[[Contributions:actiCHamp]]: Interface to the Brain Products actiCHamp system.&lt;br /&gt;
*[[Contributions:actiCHampPlus]]: Interface to the Brain Products actiCHamp Plus system.&lt;br /&gt;
*[[Contributions:LiveAmpADC]]: Interface to the Brain Products LiveAmp system.&lt;br /&gt;
*[[Contributions:LSLSource]]: Interface to the Brain Products Hardware system.&lt;br /&gt;
*[[Contributions:OpenBCISource]]: Interface to the OpenBCI system.&lt;br /&gt;
*[[Contributions:OpenBCI_Module]]: Interface to the OpenBCI system.&lt;br /&gt;
*[[Contributions:NeuroSpark]]: Interface to NeuroSpark.&lt;br /&gt;
*[[Contributions:NeuSenW]]: Interface to NeuSenW.&lt;br /&gt;
*[[Contributions:LabJackADC]]: Interface to LabJack devices.&lt;br /&gt;
*[[Contributions:RipplePyADC]]: Interface to Ripple devices.&lt;br /&gt;
*[[Contributions:SerialWidgetADC]]: Interface to programmable Arduino-like devices.&lt;br /&gt;
*[[Contributions:FlexEEG]]: Interface (via NC_flexXADC filter) to the FlexEEG system by NeuroCONCISE Ltd.&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:How to use a Contributed Source Module]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contents]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11254</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11254"/>
		<updated>2024-04-11T19:28:12Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There are a few known issues with the MicroLeads device system.&lt;br /&gt;
&lt;br /&gt;
Sometimes when the device has been commanded to stop recording or stimulating, further commands to it will not work as the device is unresponsive. The solution for this has been to let the device lose power completely, and then recharge it. &lt;br /&gt;
&lt;br /&gt;
There are some issues with getting consistent data from stimulation. At times, the stimulation will abruptly stop as well. When using the associated GUI from MicroLeads, this was usually accompanied by a &amp;quot;Compliance&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
Communication for commands is not consistent either. It may take several attempts to get the device to start working.&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11253</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11253"/>
		<updated>2024-04-11T19:27:45Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There are a few known issues with the MicroLeads device system.&lt;br /&gt;
&lt;br /&gt;
Sometimes when the device has been commanded to stop recording or stimulating, further commands to it will not work as the device is unresponsive. The solution for this has been to let the device lose power completely, and then recharge it. \n&lt;br /&gt;
There are some issues with getting consistent data from stimulation. At times, the stimulation will abruptly stop as well. When using the associated GUI from MicroLeads, this was usually accompanied by a &amp;quot;Compliance&amp;quot; error.&lt;br /&gt;
Communication for commands is not consistent either. It may take several attempts to get the device to start working.&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11252</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11252"/>
		<updated>2024-04-11T19:27:34Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There are a few known issues with the MicroLeads device system.&lt;br /&gt;
&lt;br /&gt;
Sometimes when the device has been commanded to stop recording or stimulating, further commands to it will not work as the device is unresponsive. The solution for this has been to let the device lose power completely, and then recharge it.&lt;br /&gt;
There are some issues with getting consistent data from stimulation. At times, the stimulation will abruptly stop as well. When using the associated GUI from MicroLeads, this was usually accompanied by a &amp;quot;Compliance&amp;quot; error.&lt;br /&gt;
Communication for commands is not consistent either. It may take several attempts to get the device to start working.&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11251</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11251"/>
		<updated>2024-04-11T19:27:14Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There are a few known issues with the MicroLeads device system.&lt;br /&gt;
&lt;br /&gt;
First, sometimes when the device has been commanded to stop recording or stimulating, further commands to it will not work as the device is unresponsive. The solution for this has been to let the device lose power completely, and then recharge it.&lt;br /&gt;
Second, there are some issues with getting consistent data from stimulation. At times, the stimulation will abruptly stop as well. When using the associated GUI from MicroLeads, this was usually accompanied by a &amp;quot;Compliance&amp;quot; error.&lt;br /&gt;
Third, communication for commands is not consistent either. It may take several attempts to get the device to start working.&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11250</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=11250"/>
		<updated>2024-04-11T19:27:03Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Known Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
There are a few known issues with the MicroLeads device system.&lt;br /&gt;
&lt;br /&gt;
First, sometimes when the device has been commanded to stop recording or stimulating, further commands to it will not work as the device is unresponsive. The solution for this has been to let the device lose power completely, and then recharge it.&lt;br /&gt;
&lt;br /&gt;
Second, there are some issues with getting consistent data from stimulation. At times, the stimulation will abruptly stop as well. When using the associated GUI from MicroLeads, this was usually accompanied by a &amp;quot;Compliance&amp;quot; error.&lt;br /&gt;
&lt;br /&gt;
Third, communication for commands is not consistent either. It may take several attempts to get the device to start working.&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10982</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10982"/>
		<updated>2023-12-12T18:19:11Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Stimulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Running the Source Module==&lt;br /&gt;
&lt;br /&gt;
===Initial Parameters===&lt;br /&gt;
Now that you have installed the source module, you can begin testing to make sure that data is being acquired. Before you test the source module, you can make sure that a signal is being passed through by using the Trellis application provided by Ripple. This will eliminate any doubt about whether data is actually being acquired in the first place, since you will be able to see a signal generated in Trellis.&lt;br /&gt;
&lt;br /&gt;
Next, double click on the batch file to start the source module. Here you will be able to configure parameters and even save them as a file to load in for future experiment runs. &lt;br /&gt;
&lt;br /&gt;
First, you can decide the number of source channels. This is going to be the same as the number of electrodes that you would like a signal to be acquired and visualized from. &lt;br /&gt;
&lt;br /&gt;
Next, you can choose the number of samples to be acquired per acquisition block with the sample block size. &lt;br /&gt;
&lt;br /&gt;
Next, you must decide which data acquisition function you would like to choose. The six options are raw, lfp, hifreq, hires, emg, and status. The specifics of these data streams are covered in the Ripple manual. The important thing to note is that the choices for macro and micro are both &amp;quot;raw&amp;quot;. Macro and micro depends on which front-end you are using.&lt;br /&gt;
&lt;br /&gt;
Next, we must check that the sampling rate matches the sampling rate of the data acquisition function you choose. The frequencies are listed in the Parameters section of this wiki. It is important that they match otherwise you will get errors on data acquisition. &lt;br /&gt;
&lt;br /&gt;
The final thing to change would be which specific electrodes to acquire data from, via the specific channel parameter. Here, you set put the electrodes in a 0-indexed list (electrode 1 is 0, electrode 2 is 1, etc.). The length of this list must match the number of source channels you put earlier. Otherwise, this list will be overwritten during preflight.&lt;br /&gt;
&lt;br /&gt;
You can also change other parameters as detailed in the parameter guide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Source_Parameters.png|Source Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulation===&lt;br /&gt;
&lt;br /&gt;
If you would like to use stimulation with your Ripple device, there is a separate parameter tab where you can create stimulation segments, sequences, triggers, and trains. This is still currently under development.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Stimulation_Parameters.png|Stimulation Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10981</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10981"/>
		<updated>2023-12-12T18:18:51Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Initial Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Running the Source Module==&lt;br /&gt;
&lt;br /&gt;
===Initial Parameters===&lt;br /&gt;
Now that you have installed the source module, you can begin testing to make sure that data is being acquired. Before you test the source module, you can make sure that a signal is being passed through by using the Trellis application provided by Ripple. This will eliminate any doubt about whether data is actually being acquired in the first place, since you will be able to see a signal generated in Trellis.&lt;br /&gt;
&lt;br /&gt;
Next, double click on the batch file to start the source module. Here you will be able to configure parameters and even save them as a file to load in for future experiment runs. &lt;br /&gt;
&lt;br /&gt;
First, you can decide the number of source channels. This is going to be the same as the number of electrodes that you would like a signal to be acquired and visualized from. &lt;br /&gt;
&lt;br /&gt;
Next, you can choose the number of samples to be acquired per acquisition block with the sample block size. &lt;br /&gt;
&lt;br /&gt;
Next, you must decide which data acquisition function you would like to choose. The six options are raw, lfp, hifreq, hires, emg, and status. The specifics of these data streams are covered in the Ripple manual. The important thing to note is that the choices for macro and micro are both &amp;quot;raw&amp;quot;. Macro and micro depends on which front-end you are using.&lt;br /&gt;
&lt;br /&gt;
Next, we must check that the sampling rate matches the sampling rate of the data acquisition function you choose. The frequencies are listed in the Parameters section of this wiki. It is important that they match otherwise you will get errors on data acquisition. &lt;br /&gt;
&lt;br /&gt;
The final thing to change would be which specific electrodes to acquire data from, via the specific channel parameter. Here, you set put the electrodes in a 0-indexed list (electrode 1 is 0, electrode 2 is 1, etc.). The length of this list must match the number of source channels you put earlier. Otherwise, this list will be overwritten during preflight.&lt;br /&gt;
&lt;br /&gt;
You can also change other parameters as detailed in the parameter guide.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_Source_Parameters.png|Source Parameters&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulation===&lt;br /&gt;
&lt;br /&gt;
If you would like to use stimulation with your Ripple device, there is a separate parameter tab where you can create stimulation segments, sequences, triggers, and trains. This is still currently under development.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_Stimulation_Parameters.png&amp;diff=10980</id>
		<title>File:Ripple Stimulation Parameters.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_Stimulation_Parameters.png&amp;diff=10980"/>
		<updated>2023-12-12T18:18:22Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_Source_Parameters.png&amp;diff=10979</id>
		<title>File:Ripple Source Parameters.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_Source_Parameters.png&amp;diff=10979"/>
		<updated>2023-12-12T18:18:08Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10978</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10978"/>
		<updated>2023-12-12T18:08:03Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Running the Source Module==&lt;br /&gt;
&lt;br /&gt;
===Initial Parameters===&lt;br /&gt;
Now that you have installed the source module, you can begin testing to make sure that data is being acquired. Before you test the source module, you can make sure that a signal is being passed through by using the Trellis application provided by Ripple. This will eliminate any doubt about whether data is actually being acquired in the first place, since you will be able to see a signal generated in Trellis.&lt;br /&gt;
&lt;br /&gt;
Next, double click on the batch file to start the source module. Here you will be able to configure parameters and even save them as a file to load in for future experiment runs. &lt;br /&gt;
&lt;br /&gt;
First, you can decide the number of source channels. This is going to be the same as the number of electrodes that you would like a signal to be acquired and visualized from. &lt;br /&gt;
&lt;br /&gt;
Next, you can choose the number of samples to be acquired per acquisition block with the sample block size. &lt;br /&gt;
&lt;br /&gt;
Next, you must decide which data acquisition function you would like to choose. The six options are raw, lfp, hifreq, hires, emg, and status. The specifics of these data streams are covered in the Ripple manual. The important thing to note is that the choices for macro and micro are both &amp;quot;raw&amp;quot;. Macro and micro depends on which front-end you are using.&lt;br /&gt;
&lt;br /&gt;
Next, we must check that the sampling rate matches the sampling rate of the data acquisition function you choose. The frequencies are listed in the Parameters section of this wiki. It is important that they match otherwise you will get errors on data acquisition. &lt;br /&gt;
&lt;br /&gt;
The final thing to change would be which specific electrodes to acquire data from, via the specific channel parameter. Here, you set put the electrodes in a 0-indexed list (electrode 1 is 0, electrode 2 is 1, etc.). The length of this list must match the number of source channels you put earlier. Otherwise, this list will be overwritten during preflight.&lt;br /&gt;
&lt;br /&gt;
You can also change other parameters as detailed in the parameter guide.&lt;br /&gt;
&lt;br /&gt;
===Stimulation===&lt;br /&gt;
&lt;br /&gt;
If you would like to use stimulation with your Ripple device, there is a separate parameter tab where you can create stimulation segments, sequences, triggers, and trains. This is still currently under development.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10977</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10977"/>
		<updated>2023-12-12T17:51:33Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* SamplingRate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. &#039;&#039;&#039;It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10976</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10976"/>
		<updated>2023-12-12T17:51:09Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. ***It is important that this parameter matches the sampling rate of the data acquisition function that you want to use. Otherwise, the two frequencies will be out of sync and you will eventually get either an error or a flat line in the signal visualizer.***&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10915</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10915"/>
		<updated>2023-11-03T19:28:29Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Creating a Batch File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing  --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication       --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10914</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10914"/>
		<updated>2023-11-03T19:28:05Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Creating a Batch File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
 &lt;br /&gt;
 start executable DummySignalProcessing --local &lt;br /&gt;
 &lt;br /&gt;
 start executable DummyApplication      --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10913</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10913"/>
		<updated>2023-11-03T19:27:51Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Creating a Batch File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the values of &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=BciSource.py --PythonSrcShell=0 --PythonSrcLog=Srclogger.txt&lt;br /&gt;
&lt;br /&gt;
 start executable PythonSignalProcessing --local --PythonSigClassFile=BciSignalProcessing.py --PythonSigShell=0 --PythonSigLog=Siglogger.txt&lt;br /&gt;
&lt;br /&gt;
 start executable PythonApplication      --local --PythonAppClassFile=BciApplication.py --PythonAppShell=0 --PythonAppLog=Applogger.txt&lt;br /&gt;
to &lt;br /&gt;
 start executable PythonSource           --local --PythonSrcClassFile=ripple/ripplePC.py --PythonSrcShell=0 --PythonSrcLog=aaaaa.txt&lt;br /&gt;
&lt;br /&gt;
 start executable DummySignalProcessing --local &lt;br /&gt;
&lt;br /&gt;
 start executable DummyApplication      --local &lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10912</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10912"/>
		<updated>2023-11-03T18:06:06Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Installing the Python Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=300px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10911</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10911"/>
		<updated>2023-11-03T18:05:50Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Installing the Python Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_api_install.png&amp;diff=10910</id>
		<title>File:Ripple api install.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_api_install.png&amp;diff=10910"/>
		<updated>2023-11-03T18:05:29Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_whl_path.png&amp;diff=10909</id>
		<title>File:Ripple whl path.png</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=File:Ripple_whl_path.png&amp;diff=10909"/>
		<updated>2023-11-03T18:05:20Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10908</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10908"/>
		<updated>2023-11-03T18:03:28Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Installing the Python Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:ripple_whl_path.png|Copying the path&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:ripple_api_install.png|Installing the module&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10907</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10907"/>
		<updated>2023-11-03T18:02:03Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* How to set up with BCPy2000 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Installing the Python Module===&lt;br /&gt;
&lt;br /&gt;
To actually be able to use the Ripple&#039;s Python API with BCPy2000, it needs to be installed with your BCPy installation. First download and unzip the whl files provided by Ripple. Depending on your operating system, right-click and copy the path to the whl file. For reference, I used version 0.16.19 on Python 3.8.&lt;br /&gt;
&lt;br /&gt;
image here&lt;br /&gt;
&lt;br /&gt;
Now, open command prompt and navigate to the folder containing your BCPy2000 installation. Now, run the command&lt;br /&gt;
 python -m pip install &amp;quot;YOUR_PATH_HERE&amp;quot;&lt;br /&gt;
where &amp;quot;YOUR_PATH_HERE&amp;quot; is your path in quotations. &lt;br /&gt;
&lt;br /&gt;
image here&lt;br /&gt;
&lt;br /&gt;
After installing, you should be good to test the source module!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=10904</id>
		<title>Contributions:MicroLeadsADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:MicroLeadsADC&amp;diff=10904"/>
		<updated>2023-11-02T21:43:07Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Proper Charging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
MicroLeadsADC is a source module that allows for utilization of the Micro-Leads StimZ recording and stimulation device within BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 2/10/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the MicroLeads ADC==&lt;br /&gt;
&lt;br /&gt;
To use the MicroLeads ADC, you will need to have been provided with the basic hardware from Micro-Leads. Below we will go over the mandatory and optional hardware/software parts necessary to ensure a smooth use of the MicroLeads ADC.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Hardware==&lt;br /&gt;
&lt;br /&gt;
===Included Hardware===&lt;br /&gt;
&lt;br /&gt;
The following is a list of the hardware that should have been provided to you:&lt;br /&gt;
*&#039;&#039;&#039;Wireless Implant&#039;&#039;&#039;&lt;br /&gt;
** This is the implantable device that can record and stimulate wirelessly.&lt;br /&gt;
*&#039;&#039;&#039;Powerpad with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that allows for wireless charging of the implantable device.&lt;br /&gt;
*&#039;&#039;&#039;Basestation with power cable&#039;&#039;&#039;&lt;br /&gt;
** This is the device that communicates with the implant and the powerpad by sending commands, receiving information and data, and then relaying it to the router.&lt;br /&gt;
*&#039;&#039;&#039;Wireless Router with power cable&#039;&#039;&#039;&lt;br /&gt;
** The router is require for creating an ethernet sub-network for base station ethernet communication&lt;br /&gt;
*&#039;&#039;&#039;Two Ethernet cables&#039;&#039;&#039;&lt;br /&gt;
** Required to connect the basestation to the router and the router to the computer.&lt;br /&gt;
*&#039;&#039;&#039;Ethernet to USB adapter&#039;&#039;&#039;&lt;br /&gt;
** Optional adapter if the computer you are using does not have an ethernet port. Will be needed for verification with the Micro-Leads provided laptop.&lt;br /&gt;
*&#039;&#039;&#039;Laptop with Micro-Leads Interface Software&#039;&#039;&#039;&lt;br /&gt;
** This laptop should have the interface executable to use for initial device verification. It should also have the ***stimZ_config.ini*** that has the device information and properties.&lt;br /&gt;
&lt;br /&gt;
Below are figures detailing what each device looks like with labels.&lt;br /&gt;
&lt;br /&gt;
===Hardware Setup===&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup_overview.png|Hardware Setup Overview&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Considering how many cables and devices there are, it is helpful to have a step-by-step procedure to ensure that everything is set up smoothly.&lt;br /&gt;
&lt;br /&gt;
====Laptop====&lt;br /&gt;
&lt;br /&gt;
The first thing to set up is the laptop. Ensure that the laptop charger is plugged into an outlet and that the charger is plugged into the laptop.&lt;br /&gt;
&lt;br /&gt;
====Router====&lt;br /&gt;
&lt;br /&gt;
The next step is to set up the router. &lt;br /&gt;
&lt;br /&gt;
First, plug the power adapter for the router into an outlet and then plug the power adapter into the router. Ensure that the router turns on.&lt;br /&gt;
&lt;br /&gt;
Next, plug the ethernet to USB adapter into an open USB port on the laptop.&lt;br /&gt;
&lt;br /&gt;
Finally, we will use one of the ethernet cables to connect the router and the laptop. &lt;br /&gt;
Plug one end of the cable into the open port on the ethernet to USB adapter. &lt;br /&gt;
Plug the other end of the cable into one of the 4 available black ports on the router. &lt;br /&gt;
Do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Basestation====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the basestation.&lt;br /&gt;
&lt;br /&gt;
First, ensure that the antenna is securely attached to the basestation. Use the &#039;&#039;&#039;shorter&#039;&#039;&#039; antenna.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into the outlet and then into the micro-usb port of the basestation. &lt;br /&gt;
&lt;br /&gt;
Finally, we will use the other ethernet cable to connect the router to the basestation.&lt;br /&gt;
Plug one end of the cable into the open ethernet port on the basestation.&lt;br /&gt;
Then, similarly to the previous step, plug the other end of the cable into one of the 3 remaining available black ports on the router.&lt;br /&gt;
Once again, do &#039;&#039;&#039;not&#039;&#039;&#039; plug it into the blue port.&lt;br /&gt;
&lt;br /&gt;
====Powerpad====&lt;br /&gt;
&lt;br /&gt;
Next we will set up the powerpad. &lt;br /&gt;
&lt;br /&gt;
First, screw the power adapter onto the powerpad, ensuring that it is tightly attached.&lt;br /&gt;
&lt;br /&gt;
Next, plug the power adapter into a wall outlet.&lt;br /&gt;
&lt;br /&gt;
Test to see if the powerpad turns on by pressing the rubber power switch located on one of the short sides of the pad. The switch should light up blue when it is on. A square should also light up green, located to the left of the switch and the right of the location to screw the power adapter on.&lt;br /&gt;
&lt;br /&gt;
Finally, attach the &#039;&#039;&#039;longer&#039;&#039;&#039; antenna to the powerpad by screwing it on.&lt;br /&gt;
&lt;br /&gt;
With this, your initial setup should be complete! You should keep the powerpad and implant decently close to the basestation to ensure proper communication, but they don&#039;t need to be right next to each other.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_setup.png|Example setup&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Level Setup===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This section is only relevant to users with multiple devices.&lt;br /&gt;
&lt;br /&gt;
The Micro-Leads system has capabilities for multiple device integration. You would follow the same steps as previous for each device. &lt;br /&gt;
&lt;br /&gt;
However, there are limitations to the system overall when using multiple devices:&lt;br /&gt;
* There can only be one router per laptop at a time.&lt;br /&gt;
* There can only be one basestation per router at a time.&lt;br /&gt;
* A basestation can connect to up to 7 powerpads simulataneously.&lt;br /&gt;
* A basestation can connect to up to 7 implants simultaneously.&lt;br /&gt;
* A powerpad can connect to only one basestation at a time.&lt;br /&gt;
* An implant can connect to only one basestation at a time.&lt;br /&gt;
* A basestation can only stream recording data from one implant at a time. &lt;br /&gt;
* When a basestation is streaming recording data, it cannot communicate with any other powerpads or implants.&lt;br /&gt;
* Two implants cannot share the same frequency/channel.&lt;br /&gt;
&lt;br /&gt;
In essence, if you would like to stream recording data for multiple devices at once &#039;&#039;&#039;you need another full setup&#039;&#039;&#039;. This is because a basestation can only stream recording data from one implant at a time.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you may just need more powerpads and implants if you would like to switch between which device you are streaming recording data from.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Currently, MicroLeads ADC only supports one hardware setup at a time.&#039;&#039;&#039; However, if you have multiple hardware setups, you can still use BCI2000 with each. You would just need to have a PC with BCI2000 installed for each of them.&lt;br /&gt;
&lt;br /&gt;
==Verifying with Micro-Leads Software==&lt;br /&gt;
&lt;br /&gt;
At this point, all of the hardware should be set up to allow for communication and verification.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
First we will open up the interface executable on the provided laptop. This may be called &#039;&#039;&#039;Stim-Z-GUI&#039;&#039;&#039; or &#039;&#039;&#039;RHD2000Interface&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You should now see a GUI that looks similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will connect to the basestation. Click the pulldown menu that says &amp;quot;Select Base Station&amp;quot;, and then click connect once you have it selected.&lt;br /&gt;
&lt;br /&gt;
Next, click on the button in the lower left corner that says &amp;quot;Select Devices&amp;quot;. A pop-up menu should appear.&lt;br /&gt;
&lt;br /&gt;
In this menu, select the devices on the left and click the middle arrow button. The devices should appear in the columns on the right like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_select_devices_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Click &amp;quot;Confirm&amp;quot; to close the pop-up.&lt;br /&gt;
&lt;br /&gt;
Next, click the &amp;quot;Pair Devices&amp;quot; button. Another pop-up menu should appear that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_scan_gui.png&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On this menu, click the box labeled &amp;quot;Enable Charging&amp;quot;. Then click &amp;quot;Scan&amp;quot;. The scan will take a few seconds and take multiple tries to discover all devices. Discovered devices will be highlighted green while unverified devices will show up as red. If your implant has no charge, it may show up red for some time. In this case, you will need to charge the device which is discussed next.&lt;br /&gt;
&lt;br /&gt;
At this time, you should be able to test your implant device.&lt;br /&gt;
&lt;br /&gt;
===Charging the Device===&lt;br /&gt;
&lt;br /&gt;
First, we will make sure that the device is charged. There are two ways to do this. The first way is through the Micro-Leads GUI while the second one is through the Micro-Leads Python API.&lt;br /&gt;
&lt;br /&gt;
====Proper Charging====&lt;br /&gt;
&lt;br /&gt;
To ensure that the implant will be charging properly, make sure that the device is positioned as shown in the following diagram:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_charging_picture.png|Charging Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Essentially, you want to make sure there is enough surface area for the implant relative to the powerpad to be able to charge. You also want to make sure that the implant is not too far from the powerpad to be able to charge. There may be dead zones on the powerpad, so there might be some trial and error required for optimal placement.&lt;br /&gt;
&lt;br /&gt;
====Micro-Leads GUI====&lt;br /&gt;
&lt;br /&gt;
In the Micro-Leads GUI, click on the &amp;quot;Charge All&amp;quot; tab. Here, you can charge the devices that are connected to the base station. To do this, click &amp;quot;Start Monitor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should be able to hear a dull whirring noise from the powerpad if it is charging your device.&lt;br /&gt;
&lt;br /&gt;
Clicking on a device will query its statement of health.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;There is a bug where sometimes the powerpad stops charging, despite showing it is within the GUI&#039;&#039;&#039;. If that happens, click &amp;quot;Stop Monitor&amp;quot; and &amp;quot;Start Monitor&amp;quot; again. This may require some supervision as a result. If you have access to the Python API, however, there is a method to make sure the powerpad continues to charge, described next.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
If you have access to the Python API, you can use a Powershell script to ensure charging.&lt;br /&gt;
&lt;br /&gt;
First, make sure that the wheel file you received is installed in a python environment properly.&lt;br /&gt;
&lt;br /&gt;
Next open a Powershell terminal and navigate to your python environment. &#039;&#039;&#039;You will need to know the address and channel for the powerpad.&#039;&#039;&#039; This can be found from the config.ini file. Details on where to find that are [[#Using MicroLeads ADC|here]]&lt;br /&gt;
&lt;br /&gt;
Run the &amp;quot;charge enable&amp;quot; function. An example looks like this:&lt;br /&gt;
&lt;br /&gt;
 python -m stimZscripts.example_charge_enable -a 192.168.1.10 -z 10 -c 70&lt;br /&gt;
&lt;br /&gt;
Next, we will be running a script that queries &amp;quot;statements of health&amp;quot; from the powerpad. &#039;&#039;&#039;This is required because if a statement of health is not queried within a certain time period, the powerpad will turn off.&#039;&#039;&#039; And example of this script is shown below:&lt;br /&gt;
&lt;br /&gt;
 for ($je1; $j -le 100; $j++) {&amp;lt;br&amp;gt;python -m stimZscripts.example_soh -a 192.168.1.10 -z 10 -d powerpad -c 70&amp;lt;br&amp;gt;Sleep(60);&amp;lt;br&amp;gt;}&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
To verify the device works properly, we need to test the leads. I used an oscilloscope and breadboard to test, but you may use another method if you wish.&lt;br /&gt;
&lt;br /&gt;
First I will discuss the device layout and the leads themselves. &lt;br /&gt;
&lt;br /&gt;
The top of the device has the white leads to the right of the blue leads. The bottom will show an inverse. It should match the following image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:microleads_implant_position.png|Implant Position Guide&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we will identify the electrodes. The white wires correspond to &amp;quot;ENG0/Stim0&amp;quot; and &amp;quot;EMG0&amp;quot;. The blue wires correspond to &amp;quot;ENG1/Stim1&amp;quot; and &amp;quot;EMG1&amp;quot;. The ENG/Stim wires are connected to 300 micrometer bipolar cuff electrodes. EMG1 is connected to a bipolar EUS electrode while EMG0 is not connected. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note: The wires haven&#039;t been labeled by Micro-Leads. Determining which wire corresponds to which channel, as well as which wires are the reference wires will need to be determined through trial and error.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once you have determined which wires correspond to which channel, we can test them to confirm they work properly.&lt;br /&gt;
&lt;br /&gt;
I used a Tektronix TDS2014C Oscilloscope to verify the stimulation output matched the parameters set in the MicroLeads GUI.&lt;br /&gt;
&lt;br /&gt;
First, we must set our parameters within the MicroLeads GUI. Click the “Select Stimulation Parameters” button.&lt;br /&gt;
&lt;br /&gt;
The meaning of each parameter corresponds to the following diagram. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=400px&amp;gt;&lt;br /&gt;
File:microleads_pulse_definition.png|Pulse Definition&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Period is the overall frequency of repetition of the pulse waveform&lt;br /&gt;
#Phase Durations (1&amp;amp;2) are the durations of positive and negative stimulationcurrent.&lt;br /&gt;
#Phase Amplitudes (1&amp;amp;2) are the amplitudes of the stimulation current.&lt;br /&gt;
#Interpulse Duration is the period between the two phases of current pulses.&lt;br /&gt;
#Charge Recovery Duration is the duration after the current phases when the stimulation channel is grounded to clear any residual unbalanced charge.&lt;br /&gt;
&lt;br /&gt;
For verification, set the parameters to your desired values. If you don’t have values for your experiment yet, feel free to match the values shown here. &lt;br /&gt;
&lt;br /&gt;
Check STIM0 and/or STIM1 if stimulation is needed. Check “Enable Recording” if&lt;br /&gt;
streaming neural data is needed. &lt;br /&gt;
#If stimulation is used (with or without recording), set “Supply Voltage” to 9V&lt;br /&gt;
#If Recording only is used (no stimulation) set “Supply Voltage” to 4V&lt;br /&gt;
&lt;br /&gt;
Now, click “Verify Stimulation Parameters” and close the dialogue box.&lt;br /&gt;
&lt;br /&gt;
You can now run the recording and use your preferred method to verify that pulses are being generated.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCI2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCI2000 installation guide found [[Programming_Howto:Building_and_Customizing_BCI2000|here]] to install BCI2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Connecting to the Devices===&lt;br /&gt;
&lt;br /&gt;
when using BCI2000, the research PC will replace the provided laptop from MicroLeads. First, we will have to connect the PC to the devices using the ethernet adapter. Simply plug it in to an empty USB port.&lt;br /&gt;
&lt;br /&gt;
Next, we have to make sure that the ethernet connection is on the same network subnet mask and that the IPv4 address is able to communicate with the basestation.&lt;br /&gt;
&lt;br /&gt;
To do this, first open up a command prompt and type&lt;br /&gt;
 ipconfig /all&lt;br /&gt;
&lt;br /&gt;
A list of IP connections should show up now. Scroll and find the connection that lists ethernet and might have Realtek USB controller as the connection.&lt;br /&gt;
&lt;br /&gt;
Check to see if the IPv4 configuration starts with 192.168.1.X where X is any number. Also check to make sure that the default gateway is set.&lt;br /&gt;
&lt;br /&gt;
If it does, great! You can move on to the next step. If not, all we need to do is change the IPv4 configuration.&lt;br /&gt;
&lt;br /&gt;
In the Windows toolbar, search control panel. Then click on Network and Internet. Then click on Network and Sharing Center.&lt;br /&gt;
&lt;br /&gt;
On the left hand side, you should see &amp;quot;Change adapter settings&amp;quot;. Click on that, and then right click on the Ethernet connection associated with the adapter. It should say &amp;quot;Realtek USB controller&amp;quot; or something similar. Click on &amp;quot;Properties&amp;quot; in the popup.&lt;br /&gt;
&lt;br /&gt;
Find &amp;quot;Internet Protocol Version 4 (TCP/IPv4)&amp;quot; and double-click. Toggle the section &amp;quot;Use the following IP address&amp;quot; on.&lt;br /&gt;
&lt;br /&gt;
For IP address, use any IP address that isn&#039;t in use currently and starts with 192.168.1 . &lt;br /&gt;
For subnet mask, use 255.255.255.0.&lt;br /&gt;
For default gateway, use 192.168.1.1.&lt;br /&gt;
&lt;br /&gt;
Make sure no warnings popup after validating, and you should be able to continue!&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Although it is not necessary, it is convenient to create a batch file to run BCI2000 with the MicroLeadsADC.  To create the batch file, start out with a copy of a suitable batch file in &amp;lt;tt&amp;gt;BCI2000/batch/&amp;lt;/tt&amp;gt;, and open it in a text editor.&lt;br /&gt;
&lt;br /&gt;
Towards the end of the file, you will see a sequence of lines beginning with&lt;br /&gt;
 start executable &lt;br /&gt;
&lt;br /&gt;
These lines are responsible for starting up source, signal processing, and application module, in that sequence. To use the MicroleadsADC module, you will need to replace the executable name in the first entry, e.g.&lt;br /&gt;
 start executable SignalGenerator --local&lt;br /&gt;
becomes&lt;br /&gt;
 start executable MicroLeadsADC --local&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Contributions:How_to_use_a_Contributed_Source_Module#Creating_batch_files|this page]].&lt;br /&gt;
&lt;br /&gt;
===Using MicroLeads ADC===&lt;br /&gt;
&lt;br /&gt;
To set up your experiment using BCI2000, there are a list of parameters that you may set during configuration. &lt;br /&gt;
&lt;br /&gt;
First you will need to locate the configuration file on the laptop provided to you by MicroLeads. Navigate to the GUI configuration file, located at &#039;&#039;&#039;&amp;lt;user&amp;gt;/AppData/Roaming/RHD2000interface/config/stimZ_config.ini&#039;&#039;&#039;. Here you will see a list of configurations for the various devices in the system.&lt;br /&gt;
&lt;br /&gt;
The file should look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Config_ini_arrows.PNG&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifically look for the sections for the &amp;quot;PowerPad&amp;quot; and the &amp;quot;Remote&amp;quot;. For each of these, note down the &amp;quot;stimZ_addr&amp;quot; and the &amp;quot;radio_addr&amp;quot;. These will be used for BCI2000.&lt;br /&gt;
&lt;br /&gt;
Once you have compiled the MicroLeadsADC module, you can begin collecting data with BCI2000 by following the steps below.&lt;br /&gt;
# Double click &amp;lt;tt&amp;gt;BCI2000/batch/DummyApplication_MicroLeadsADC.bat&amp;lt;/tt&amp;gt; - the batch file that was created in the previous section - to start BCI2000.&lt;br /&gt;
# Click the &amp;quot;Configure&amp;quot; button.&lt;br /&gt;
# Set the appropriate parameters. The MicroLeadsADC module is initialized with a number of parameters that can be configured from the &amp;quot;Source&amp;quot; tab. A summary and description of these parameters can be found [[#Parameters|below]]. Importantly, make sure to enter the numbers that you noted down from the previous step for the corresponding device!&lt;br /&gt;
# Click &amp;quot;Set Config&amp;quot;.&lt;br /&gt;
# Click &amp;quot;Start&amp;quot; to begin your experiment.&lt;br /&gt;
&lt;br /&gt;
==Understanding how it works==&lt;br /&gt;
&lt;br /&gt;
===Communication Protocol===&lt;br /&gt;
&lt;br /&gt;
Communication between the various devices in the MicroLeads system is governed by the basestation. The base station will initiate Stim-Z wireless communications, while the implants and chargers respond to the commands they received from the base station. For any data to be transferred, the basestation must request it from the respective device; no unsolicited information will be transmitted.&lt;br /&gt;
&lt;br /&gt;
To facilitate this, 3 different ports are used. The command packet relay is done through TCP port 3031, while data streaming is done through UDP ports 2020 and 2323. UDP port 2323 is used to listen for a data streaming request while UDP port 2020 is the port that data is sent to.&lt;br /&gt;
&lt;br /&gt;
===Command Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Commands are sent in a specific structure. They consist of a four-byte packet header, followed by a data payload, followed by a packet ender.&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
 Byte[0]: Start byte, value is always 0x7e&lt;br /&gt;
 Byte[1]: OP byte (packet type).  Range is 0x00 to 0xff&lt;br /&gt;
 Byte[2]: Sequence/Address byte.&lt;br /&gt;
 Byte[3]: Packet data payload length in bytes.&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload structure depends specifically on the packet type. If you need to manipulate this during debugging, please refer to the Stim-Z_API provided by MicroLeads.&lt;br /&gt;
&lt;br /&gt;
====Ender====&lt;br /&gt;
&lt;br /&gt;
The ender for commands is calculated from the following CRC8 polynomial&lt;br /&gt;
&lt;br /&gt;
 x^8 + x^7 + x^6 + x^3 + x^2 + 1&lt;br /&gt;
&lt;br /&gt;
The second byte is always 0x0a.&lt;br /&gt;
&lt;br /&gt;
===Data Packet Structure===&lt;br /&gt;
&lt;br /&gt;
Similar to the command packets, data packets also have a specific structure, consisting of the following:&lt;br /&gt;
&lt;br /&gt;
 Header:  4 bytes&lt;br /&gt;
 Payload: 960 + 8 + 16 = 984 bytes&lt;br /&gt;
 CRC:     4 bytes&lt;br /&gt;
&lt;br /&gt;
====Header====&lt;br /&gt;
&lt;br /&gt;
The header matches the same specification of the command packet. However, importantly, the second byte indicates the FEC decoder status of the packet:&lt;br /&gt;
&lt;br /&gt;
 0x40: The FEC decoder marked the packet bad (undecodeable)&lt;br /&gt;
 0x20: The FEC decoder corrected bits in the packet and got a valid checksum&lt;br /&gt;
 0x10: The FEC decoder corrected bits in the packet, but the packet checksum is still bad&lt;br /&gt;
&lt;br /&gt;
====Data====&lt;br /&gt;
&lt;br /&gt;
The data payload includes 960 bytes of recording data and 24 bytes of out-of-band data.&lt;br /&gt;
&lt;br /&gt;
The 960 bytes of recording data are split into 160 smaller tuples like so:&lt;br /&gt;
&lt;br /&gt;
 sample[0]: ENG0 sample&lt;br /&gt;
 sample[1]: EMG0 sample&lt;br /&gt;
 sample[2]: ENG1 sample&lt;br /&gt;
 sample[3]: ENG0 sample&lt;br /&gt;
 sample[4]: EMG1 sample&lt;br /&gt;
 sample[5]: ENG1 sample&lt;br /&gt;
&lt;br /&gt;
Since the ENG channels record at twice the frequency of the EMG channels, there are twice as many samples. The OOB data has not been implemented with BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Debugging with the MicroLeads system is a relatively straightforward process. This section assumes that you have API access and the documentation provided from MicroLeads.&lt;br /&gt;
&lt;br /&gt;
First, please make sure that the devices are functioning properly with the MicroLeads software and that the device issue lies with BCI2000 rather than an error within the device or experiment implementation.&lt;br /&gt;
&lt;br /&gt;
Next, download Wireshark on your research PC [https://www.wireshark.org/download.html here]. Wireshark is a network protocol analysis tool that we will use to analyze the commands that are sent from the basestation through BCI2000 as well as verify that we are receiving data.&lt;br /&gt;
&lt;br /&gt;
Now open up Wireshark and click on the Ethernet network, shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; heights=500px&amp;gt;&lt;br /&gt;
File:Wireshark_1.PNG|&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you may run the experiment through BCI2000 following the previously discussed procedure [[# |here]].&lt;br /&gt;
&lt;br /&gt;
At this time, you should see more requests appearing through Wireshark. After some time, you can stop BCI2000 as well as stop the recording on Wireshark. &lt;br /&gt;
&lt;br /&gt;
There are two main things to learn from the Wireshark data. First, we can manually verify the packets and headers sent to and from the basestation to see if they match up with what is expected in the API. Second, we should be able to see a constant stream of data coming from UDP port 2020. &lt;br /&gt;
&lt;br /&gt;
If either of these do not occur, there is most likely an issue with the stimulation device. The solution to this is to let the implant lose power, and then recharge it to reset communication with the basestation. &lt;br /&gt;
&lt;br /&gt;
If both of these do occur, there may have been a communication error with BCI2000. In this case, try to rerun the experiment settings multiple times to be able to visualize the data stream in BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels. Because of device limitations, this is set to 4 channels explicitly.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter cannot be edited, and will default to the sampling rate available from the implant which is 21500 Hz. &lt;br /&gt;
In case you are experiencing problems by higher sampling rates (e.g., data loss, jerky display, etc.), increase the SampleBlockSize so that you are updating the system less frequently (usually, updating the system 20-30 times per second is sufficient for most applications).&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Device Settings&amp;quot; tab of the BCI2000 config window. These settings are provided to you from MicroLeads and are set for each device. &lt;br /&gt;
&lt;br /&gt;
===Implant StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Powerpad StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Powerpad StimZ address===&lt;br /&gt;
This parameter sets sets the StimZ address of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 0-13, and it will not be the same as the Implant StimZ address.&lt;br /&gt;
&lt;br /&gt;
===Implant Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the implant for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Powerpad Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
===Powerpad Radio Frequency Channel===&lt;br /&gt;
This parameter sets sets the radio frequency channel of the powerpad for use with BCI2000. This parameter is necessary to ensure that commands sent through BCI2000 are actually sent. &lt;br /&gt;
&lt;br /&gt;
The possible values for this parameter are 10, 20, 30, ... 80, and it will not be the same as the Implant Radio Frequency Channel.&lt;br /&gt;
&lt;br /&gt;
==Stimulation Parameters==&lt;br /&gt;
These parameters can be found in the &amp;quot;Stimulation&amp;quot; tab of the BCI2000 config window. &lt;br /&gt;
&amp;lt;gallery mode=&amp;quot;packed&amp;quot; widths=300px heights=300px&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enable STIM0===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM0 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable STIM1===&lt;br /&gt;
This parameter enables/disables stimulation for the STIM1 channel. &lt;br /&gt;
&lt;br /&gt;
===Enable Recording===&lt;br /&gt;
This parameter enables/disables streaming of neural data.&lt;br /&gt;
&lt;br /&gt;
===Supply Voltage===&lt;br /&gt;
This parameter sets the supply voltage from a range of 4V to 9V. &#039;&#039;&#039;When the user is recording only, the voltage must be 4V. When the user is stimulating at all, the voltage must be 9V.&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
===Stimulation Pulse Settings===&lt;br /&gt;
This group of parameters define the shape of the charge balanced stimulation pulses, as described in Fig 1. Limitations will be detailed for each parameter.&lt;br /&gt;
[[File: |600px|thumb|center|upright=2.5|Figure 1. Pulse definition]]&lt;br /&gt;
&lt;br /&gt;
====Phase1 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 1 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Interphase Duration====&lt;br /&gt;
This parameter sets the length of the Interphase Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase2 Duration====&lt;br /&gt;
This parameter sets the length of the Phase 2 Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM0 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase1 STIM1 Amplitude counts====&lt;br /&gt;
This parameter sets the Phase 1 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM0 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM0 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Phase2 STIM1 Amplitude count====&lt;br /&gt;
This parameter sets the Phase 2 amplitude for the STIM1 channel in counts of 10 microAmps. To obtain the proper value, divide your amplitude by 10 microAmps.&lt;br /&gt;
&lt;br /&gt;
====Charge Recovery Counts====&lt;br /&gt;
This parameter sets the length of the Charge Recovery Duration in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====Stim Period Counts====&lt;br /&gt;
This parameter sets the length of the Stim Period Duation in counts of 11.6 microseconds. To obtain the proper value, divide your duration by 11.6 microseconds.&lt;br /&gt;
&lt;br /&gt;
====ADC Gain====&lt;br /&gt;
This parameter sets the ADC Gain. When recording only, set the parameter to 0. When stimulating, set the parameter to 1.&lt;br /&gt;
&lt;br /&gt;
====Exfil_Iface====&lt;br /&gt;
This parameter sets the exfil settings. When recording only, set the parameter to 2. When stimulating, set the parameter to 0.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10774</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10774"/>
		<updated>2023-09-28T22:37:19Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* DataStream */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before trying to use a specific data stream, test to make sure you can acquire data from Trellis with it. If you don&#039;t see a signal in Trellis, you will not be able to see data in BcPy2000 either.&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10773</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10773"/>
		<updated>2023-09-28T22:35:27Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* SpecificCh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error and the electrode list will automatically be changed to match the value of SourchCh.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10767</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10767"/>
		<updated>2023-09-26T17:56:41Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* SpecificCh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039; Otherwise, you will get thrown an error.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10766</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10766"/>
		<updated>2023-09-26T17:56:26Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* SpecificCh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. &#039;&#039;&#039;Make sure that the number of specific channels matches the SourceCh parameter.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10765</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10765"/>
		<updated>2023-09-26T17:55:56Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* SpecificChannels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificCh===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom. ***Make sure that the number of specific channels matches the SourceCh parameter.***&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10743</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10743"/>
		<updated>2023-09-22T22:38:31Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Using the RipplePyADC */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10742</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10742"/>
		<updated>2023-09-22T22:38:12Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
You can also manually edit the python source module and utilize print statements or write to a file within the program. The source module will print out to the designated logger file that was named in the batch file.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10741</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10741"/>
		<updated>2023-09-22T22:37:28Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Creating a Batch File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
Creating a batch file with BCPy2000 is very straightforward. If you followed the guide, you will already have a few python batch files in the batch folder of your BCI2000 installation since you copied them over from your BCPy2000 installation. If you don&#039;t already have a batch file related to Ripple Python, you can create one by copying the template batch file, and editing it. All you need to do is change the value of &lt;br /&gt;
 --PythonSrcClassFile=TrefoilSource.py&lt;br /&gt;
to &lt;br /&gt;
 --PythonSrcClassFile=RipplePy.py&lt;br /&gt;
&lt;br /&gt;
Here, you can also manually change the logger files for use with debugging.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10740</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10740"/>
		<updated>2023-09-22T22:32:45Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
Most of the time, the error will be:&lt;br /&gt;
 xipppy.exception.XippPyException: Library already open or failed to initialize&lt;br /&gt;
It is hard to pinpoint exactly what caused the error in this case, and even Ripple&#039;s documentation states that this error lacks any additional information.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10738</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10738"/>
		<updated>2023-09-22T22:30:11Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
The following script can be used to test data acquisition:&lt;br /&gt;
&lt;br /&gt;
 import xipppy&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import time&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    with xipppy.open(use_tcp=true):&lt;br /&gt;
        i = 0&lt;br /&gt;
        data_arrays = []&lt;br /&gt;
        while i &amp;lt; 10:&lt;br /&gt;
            ts = xipppy.time()&lt;br /&gt;
            time.sleep(1)&lt;br /&gt;
            array = xipppy.cont_hires(100, [0], ts)&lt;br /&gt;
            data_arrays.append(array)&lt;br /&gt;
            i += 1&lt;br /&gt;
        print(data_arrays)&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10737</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10737"/>
		<updated>2023-09-22T22:29:02Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 &lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 &lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
 &lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10736</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10736"/>
		<updated>2023-09-22T22:28:44Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10735</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10735"/>
		<updated>2023-09-22T22:28:25Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10734</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10734"/>
		<updated>2023-09-22T22:27:35Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10733</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10733"/>
		<updated>2023-09-22T22:27:21Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/bin/env python3&lt;br /&gt;
 # -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
 import xipppy as xp&lt;br /&gt;
 from time import sleep&lt;br /&gt;
&lt;br /&gt;
 def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10732</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10732"/>
		<updated>2023-09-22T22:26:30Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
import xipppy as xp&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10731</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10731"/>
		<updated>2023-09-22T22:26:15Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
import xipppy as xp&lt;br /&gt;
from time import sleep&lt;br /&gt;
&lt;br /&gt;
def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10730</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10730"/>
		<updated>2023-09-22T22:23:50Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
import xipppy as xp&lt;br /&gt;
from time import sleep&lt;br /&gt;
def connectToProcessor():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Close connection&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Connect to processor (Try UDP then TCP).&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10729</id>
		<title>Contributions:RipplePyADC</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Contributions:RipplePyADC&amp;diff=10729"/>
		<updated>2023-09-22T22:23:13Z</updated>

		<summary type="html">&lt;p&gt;Dmehta: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
RipplePyADC is a source module that allows for utilization of the Ripple Grapevine and other Ripple devices within BCI2000 through BCPy2000.&lt;br /&gt;
&lt;br /&gt;
==Video Overview==&lt;br /&gt;
&lt;br /&gt;
==Versioning==&lt;br /&gt;
&lt;br /&gt;
===Authors===&lt;br /&gt;
* Dhruva Mehta (mehta@neurotechcenter.org)&lt;br /&gt;
&lt;br /&gt;
===Version History===&lt;br /&gt;
* 9/22/2023 Initial Creation and Setup&lt;br /&gt;
&lt;br /&gt;
===Source Code Revisions===&lt;br /&gt;
*Initial development: &lt;br /&gt;
*Tested under: &lt;br /&gt;
*Known to compile under: &lt;br /&gt;
*Broken since: --&lt;br /&gt;
&lt;br /&gt;
===Known Issues===&lt;br /&gt;
&lt;br /&gt;
==Using the RipplePyADC==&lt;br /&gt;
&lt;br /&gt;
To use the Ripple Python ADC, you will need to have a Ripple device that works with Trellis and Ripple&#039;s Python API. You will also need a computer set up with both BCI2000 and BCPy2000, which we will go over later.&lt;br /&gt;
&lt;br /&gt;
===Initial Setup===&lt;br /&gt;
&lt;br /&gt;
For the initial setup of your device, please follow the Ripple user manual for your specific device. &lt;br /&gt;
&lt;br /&gt;
====Trellis====&lt;br /&gt;
&lt;br /&gt;
Trellis is a user interface program that has been included with your device. Please use Trellis to test your connection with the device, such as stimulating and recording, as a means of debugging any connection issues or errors.&lt;br /&gt;
&lt;br /&gt;
====Python API====&lt;br /&gt;
&lt;br /&gt;
Ripple has developed a Python interface to Trellis and the Grapevine Neural Interface Processor (NIP) called Xipppy, which is being used in this source module. If there is a functionality that is not implemented, please first check the Python API to see if Ripple has it implemented themselves. If it is missing from this source module but implemented in their API, please contact us to update the source module.&lt;br /&gt;
&lt;br /&gt;
===Verifying Device Properties===&lt;br /&gt;
&lt;br /&gt;
==How to set up with BCPy2000==&lt;br /&gt;
&lt;br /&gt;
Now we will set up the research PC. First, follow the BCPy2000 installation guide found &#039;&#039;&#039;[[BCPy2000|here]]&#039;&#039;&#039; to install BCPy2000 and compile the solution on your PC.&lt;br /&gt;
&lt;br /&gt;
===Creating a Batch File===&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
Before debugging with BCPy2000, please use Trellis to make sure a proper connection is established. Once you have done that, there are a few methods to test the functionality of both the source module and the underlying Python API.&lt;br /&gt;
&lt;br /&gt;
First we will test the Python API. The following is a simple script to test connecting to a device in both UDP and TCP:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
import xipppy as xp&lt;br /&gt;
from time import sleep&lt;br /&gt;
def connectToProcessor():&lt;br /&gt;
    # Close connection&lt;br /&gt;
    xp._close()&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
    # Connect to processor (Try UDP then TCP). &lt;br /&gt;
    try:&lt;br /&gt;
        xp._open()&lt;br /&gt;
    except:&lt;br /&gt;
        try:&lt;br /&gt;
            xp._open(use_tcp=True)&lt;br /&gt;
        except:&lt;br /&gt;
            print(&amp;quot;Failed to connect to processor.&amp;quot;)&lt;br /&gt;
        else:&lt;br /&gt;
            print(&amp;quot;Connected over TCP&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Connected over UDP&amp;quot;)&lt;br /&gt;
    sleep(0.001)&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    connectToProcessor()&lt;br /&gt;
    xp._close()&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
===SourceCh===&lt;br /&gt;
The total number of digitized and stored channels.&lt;br /&gt;
&lt;br /&gt;
===SampleBlockSize===&lt;br /&gt;
Samples per channel per digitized block. &lt;br /&gt;
Together with the sampling rate, this parameter determines how often per second data are collected, processed, and feedback is updated. For example, at 1000 Hz sampling and a SampleBlockSize of 20, the system (e.g., source signal display, signal processing, and stimulus presentation) will be updated 50 times per second.&lt;br /&gt;
&lt;br /&gt;
===SamplingRate===&lt;br /&gt;
The sample rate of the system. This parameter can be changed, however it will be overridden by the source module depending on the data stream type that you choose.&lt;br /&gt;
&lt;br /&gt;
===SourceChOffset===&lt;br /&gt;
Offset for each channel.&lt;br /&gt;
&lt;br /&gt;
===SourceChGain===&lt;br /&gt;
Gain for each channel. &lt;br /&gt;
&lt;br /&gt;
===ChannelNames===&lt;br /&gt;
Names of each channel.&lt;br /&gt;
&lt;br /&gt;
===ReferenceCh===&lt;br /&gt;
This list defines what channels will be used as reference. This list is uploaded to the device and set in hardware, effecting the raw bio-signal data that is recorded by BCI2000. If you do not want to effect the raw bio-signal data that is recorded, you can use the [https://www.bci2000.org/mediawiki/index.php/User_Reference:SpatialFilter spatial filter]. If this parameter is set to auto, no reference channels are used.&lt;br /&gt;
&lt;br /&gt;
===DataStream===&lt;br /&gt;
The type of data stream you would like to use for acquisition. There are six types of data streams you can use, each with different frequencies:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-right:auto; margin-left:10px; text-align:center;&amp;quot;&lt;br /&gt;
|+ Data Streams&lt;br /&gt;
|-&lt;br /&gt;
! Stream !! Frequency (kHz)&lt;br /&gt;
|-&lt;br /&gt;
| raw || 30&lt;br /&gt;
|-&lt;br /&gt;
| lfp || 1&lt;br /&gt;
|-&lt;br /&gt;
| hires || 2&lt;br /&gt;
|-&lt;br /&gt;
| hifreq || 15&lt;br /&gt;
|-&lt;br /&gt;
| emg || 15&lt;br /&gt;
|-&lt;br /&gt;
| status || 2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===SpecificChannels===&lt;br /&gt;
Here, you can choose which channels you want to actually acquire data from, just put the number of the channel you would like in a corresponding list section. Channel numbers start with 0. You can choose any number of channels by readjusting the list matrix size. Numbers do not need to be in ascending order, however the channels will appear in order they are put in the list from top to bottom.&lt;br /&gt;
&lt;br /&gt;
==Device Parameters==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[User Reference:Filters]], [[Contributions:ADCs]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributions]][[Category:Data Acquisition]]&lt;/div&gt;</summary>
		<author><name>Dmehta</name></author>
	</entry>
</feed>