- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
Added ephys socket tutorial #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 18 commits
      Commits
    
    
            Show all changes
          
          
            24 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      ea5c4ed
              
                add initial content
              
              
                ChucklesOnGitHub 983c1ce
              
                added to toc
              
              
                ChucklesOnGitHub 5a541d9
              
                add workflows
              
              
                ChucklesOnGitHub f018406
              
                added the sockets package
              
              
                ChucklesOnGitHub a702d47
              
                changed from hs-64 to npV1e
              
              
                ChucklesOnGitHub c282c59
              
                populated existing text
              
              
                ChucklesOnGitHub 0b8edad
              
                title cleanup
              
              
                ChucklesOnGitHub 50ce509
              
                active voice
              
              
                ChucklesOnGitHub 256bb02
              
                added images
              
              
                ChucklesOnGitHub b295915
              
                added video
              
              
                ChucklesOnGitHub f33ec64
              
                add text
              
              
                ChucklesOnGitHub 986c66f
              
                added missing text and edits
              
              
                ChucklesOnGitHub 8e96d14
              
                spellcheck
              
              
                ChucklesOnGitHub ba5564c
              
                Merge branch 'main' into issue-121-socket
              
              
                bparks13 5ad8d09
              
                Remove unnecessary video file
              
              
                bparks13 b73813a
              
                Fixed invalid bookmarks, xrefs, and video links
              
              
                bparks13 251d4ba
              
                Wrap file at 100 characters
              
              
                bparks13 60826d9
              
                Merge branch 'main' into issue-121-socket
              
              
                bparks13 58ee8bd
              
                Correct formatting introduced by wrapping
              
              
                bparks13 bb42e93
              
                cs edits based on my own & bpark's feedback
              
              
                cjsha c6e21cf
              
                Review socket tutorial
              
              
                jonnew a52e9e5
              
                Address jon's PR feedback
              
              
                cjsha 2690c1c
              
                Fix TIP admonition
              
              
                cjsha aed57e3
              
                Merge branch 'main' into issue-121-socket
              
              
                cjsha File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,217 @@ | ||
| --- | ||
| uid: ephys-socket | ||
| title: Visualizing Data in the Open Ephys GUI | ||
| --- | ||
|  | ||
| This tutorial shows how to establish a TCP connection to visualize data acquired with ONIX hardware | ||
| in the Open Ephys GUI, using the OpenEphys.Sockets.Bonsai and OpenEphys.Onix1 Bonsai packages, and | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| the Ephys Socket Open Ephys GUI plugin. | ||
|  | ||
| In this example, we transmit two data streams from a NeuropixelsV1e probe: the LFP band and the AP | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| band data (384 channels). This approach lets users take advantage of the specialized visualizers | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| available in the Open Ephys GUI, such as the Probe Viewer which was specifically designed for very | ||
| dense arrays like Neuropixels probes. | ||
|  | ||
| Even though the Open Ephys GUI has recording functionality, when acquiring data using the Bonsai | ||
| ONIX package, data should be written to file in Bonsai following the [Hardware | ||
| Guides](xref:hardware). In particular, for the NeuropixelsV1e data presented in this example, follow | ||
| the [NeuropixelsV1e Headstage Hardware Guide](xref:np1e). | ||
|  | ||
| This tutorial guides you through building the following workflow in Bonsai: | ||
|  | ||
| ::: workflow  ::: | ||
|  | ||
| And the corresponding Signal Chains for visualization of the SpikeData and LFPData in the Open Ephys | ||
| GUI. | ||
|  | ||
| {width=650px} | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| {width=650px} | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| <!-- This method is generalizable to any continuous data stream in the correct matrix format --> | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| > [!NOTE] This tutorial uses NeuropixelsV1e Headstage as an example, but the process is similar for | ||
| > other ephys headstages. This tutorial assumes you are familiar with the [hardware | ||
| > guide](xref:hardware) of the ONIX headstage you intend to use. Use the information on the | ||
| > <xref:dataio> reference page to know which shift and scaling you need to use for each device on | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| > other headstages. | ||
|  | ||
| ## Get Started in Bonsai and the Open Ephys GUI | ||
|  | ||
| 1. Follow the [Getting Started](xref:getting-started) guide to set up and get familiarized with | ||
| Bonsai. In particular: | ||
|  | ||
| - [Download the necessary Bonsai packages](xref:install-configure-bonsai#package-installation) | ||
| or [check for updates](xref:install-configure-bonsai#update-packages) if they're already installed. | ||
| This tutorial assumes you're using the latest packages. | ||
| - Read about [visualizing data](xref:visualize-data). We recommend verifying each step of the | ||
| tutorial by visualizing the data produced. | ||
|  | ||
| <!-- Do we list OpenEphys.Sockets.Bonsai or assume they'll download what is included in the "necessary Bonsai packages"? --> | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| 2. Follow the [Open Ephys GUI documentation](https://open-ephys.github.io/gui-docs/) to set up and | ||
| get familiarized with the Open Ephys GUI. In particular: | ||
|  | ||
| - Download and install the application by following the [Open Ephys GUI installation | ||
| instructions](https://open-ephys.github.io/gui-docs/User-Manual/Installing-the-GUI.html) | ||
| - Install the Ephys Socket plugin and the Probe Viewer plugin by using the [Plugin | ||
|         
                  ChucklesOnGitHub marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| Installer](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/index.html#plugin-installer). | ||
| - Read about [Exploring the user | ||
| interface](https://open-ephys.github.io/gui-docs/User-Manual/Exploring-the-user-interface.html), | ||
| [Building a signal | ||
| chain](https://open-ephys.github.io/gui-docs/User-Manual/Building-a-signal-chain.html) and | ||
| [General plugin | ||
| features](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/index.html#general-plugin-features), | ||
| as well as specific plugin pages such as the [Ephys Socket | ||
| plugin](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/Ephys-Socket.html), [Probe | ||
| Viewer plugin](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/Probe-Viewer.html) | ||
| and the [LFP Viewer | ||
| plugin](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/LFP-Viewer.html). | ||
|  | ||
|  | ||
| ## Configure the TCP Connection in Bonsai | ||
|  | ||
| Place one TcpServer node per datastream at the top of the workflow and set their properties: | ||
|  | ||
| ::: workflow  ::: | ||
|  | ||
| - Address: Use "localhost" if using the Open Ephys GUI on the same PC or local network as Bonsai. | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| - Name: give the communication channel a unique name. We will use this name to provide the | ||
| datastream to the socket within Bonsai. In this example, we have named them "socket1" and | ||
| "socket2". | ||
| - Port: choose a unique port number. We will use this port number to establish the connection with | ||
| the Open Ephys GUI. | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| > [!TIP] The TcpServer nodes need to be at the top of the workflow. If they end up somewhere else | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| > and you need to move them, do the following: click and hold on the node, hold down the Alt key on | ||
| > the keyboard, hover over a node in the workflow row over which you want to place it until an arrow | ||
| > appears, and let go. | ||
|  | ||
|  | ||
| ## Configure the Hardware | ||
|  | ||
| Construct an ONIX [top-level hardware configuration chain](xref:onix-configuration): | ||
|  | ||
| ::: workflow  ::: | ||
|  | ||
| 1. Place the [configuration operators](xref:configure) that correspond to the hardware you intend to | ||
| use between <xref:OpenEphys.Onix1.CreateContext> and <xref:OpenEphys.Onix1.StartAcquisition>. In | ||
| this example, these are <xref:OpenEphys.Onix1.ConfigureNeuropixelsV1eHeadstage> and | ||
| <xref:OpenEphys.Onix1.ConfigureBreakoutBoard>. | ||
| 1. Confirm that the device that streams electrophysiology data is enabled. In this example, we will | ||
| be using the device NeuropixelsV1eData. | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| 1. Configure the hardware as necessary. In the case of NeuropixelsV1e Headstage, you must provide | ||
| gain and calibration files and can perform other configurations as explained in the | ||
| [NeuropixelsV1e Headstage Configuration](xref:np1e_configuration). In this example, we used an AP | ||
| Gain value of 1000 and LFP Gain value of 50. | ||
|  | ||
| ## Stream Ephys Data into Bonsai | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| Place the relevant operators to stream electrophysiology data from your headstage: | ||
|  | ||
| ::: workflow  ::: | ||
|  | ||
| 1. Place the <xref:OpenEphys.Onix1.NeuropixelsV1eData> node into the workflow, since the device on | ||
| NeuropixelsV1e Headstage that streams electrophysiology data is the Neuropixels 1.0 probe. | ||
| 1. Select the relevant members from the data frames that `NeuropixelsV1eData` produces. In this | ||
| example, the relevant members are "SpikeData" and "LfpData". To do this, right-click | ||
| `NeuropixelsV1eData`, hover over the output option in the context menu, and select "SpikeData" | ||
| from the list. Repeat for "LfpData". | ||
|  | ||
| Visualize the raw data to confirm that the ephys data operator is streaming data. | ||
|  | ||
| ## Configure the Data Streams to Transmit | ||
|  | ||
| Connect a `SendMatOverSocket` operator to each of the electrophysiology data streams. This operator | ||
| comes from the OpenEphys.Sockets Bonsai package. Make sure it's [installed and | ||
| updated](xref:install-configure-bonsai). | ||
|  | ||
| <!-- I'm not sure how to link to the reference as was done with other nodes <xref:Bonsai.Dsp.SelectChannels> --> | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| ::: workflow  ::: | ||
|  | ||
| Configure the "Connection" property of each `SendMatOverSocket` node to each of the TCP Socket names | ||
| configured earlier. In this example, we used "socket1" for "SpikeData" and "socket2" for "LfPData". | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
|  | ||
| ## Configure the TCP Socket in the Open Ephys GUI to Stream and View Data | ||
| ### Using the Ephys Socket and Probe Viewer processors for SpikeData | ||
|         
                  cjsha marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| Drag the source processor `Ephys Socket` from the Processor list and drop it onto the Signal Chain | ||
| area, followed by the sink processor `Probe Viewer`. | ||
|  | ||
| Configure the Scale and Offset properties of the `Ephys Socket` processor: | ||
|  | ||
| - Edit its "Scale" property to multiply the signal by a scalar in order to get microvolt values. | ||
| This scalar is determined by the gain of the amplifier and resolution the ADC contained in the | ||
| amplifier device. In this example, we "Scale" by 1.171875 because the NeuropixelsV1e device on | ||
| NeuropixelsV1e headstage has a step size of 1.2e6/1024/_gain_ μV/bit and the AP Gain was | ||
| configured at 1000. | ||
|  | ||
| - Edit its "Offset" property to subtract 2^bit depth - 1^ from the signal. In this example, we | ||
| "Offset" 512 because the NeuropixelsV1e device outputs unsigned 10-bit data. | ||
|  | ||
| {width=650px} | ||
|  | ||
| Press the "Connect" button on the `Ephys Socket` and open the visualizer by clicking the “tab” | ||
| button in the upper right of the `Probe Viewer`. | ||
|  | ||
| {width=650px} | ||
|  | ||
| Click the play button in the Control Panel at the top of the GUI to begin data acquisition. | ||
|  | ||
| {width=650px} | ||
|  | ||
| ### Using the Ephys Socket and LFP Viewer processors for LfpData | ||
|  | ||
| Drag the source processor `Ephys Socket` from the Processor list and drop it onto the Signal Chain | ||
| area, followed by the sink processor `Probe Viewer`. | ||
|  | ||
| Configure the Scale and Offset properties of the `Ephys Socket` processor: | ||
|  | ||
| - Edit its "Scale" property to multiply the signal by a scalar in order to get microvolt values. | ||
| This scalar is determined by the gain of the amplifier and resolution the ADC contained in the | ||
| amplifier device. In this example, we "Scale" by 23.4375 because the NeuropixelsV1e device on | ||
| NeuropixelsV1e headstage has a step size of 1.2e6/1024/_gain_ μV/bit and the LFP Gain was | ||
| configured at 50. | ||
|  | ||
| - Edit its "Offset" property to subtract 2^bit depth - 1^ from the signal. In this example, we | ||
| "Offset" 512 because the NeuropixelsV1e device outputs unsigned 10-bit data. | ||
|  | ||
| {width=650px} | ||
|  | ||
| Press the "Connect" button on the `Ephys Socket` and open the visualizer by clicking the “tab” | ||
| button in the upper right of the `LFP Viewer`. | ||
|  | ||
| {width=650px} | ||
|  | ||
| Click the play button in the Control Panel at the top of the GUI to begin data acquisition. | ||
|  | ||
| {width=650px} | ||
|  | ||
| > [!TIP] You can read more about using each specific plugin in the [Plugins section of the Open | ||
| > Ephys GUI documentation](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/index.html) | ||
|  | ||
| ## Stream Ephys Data in Bonsai and Visualize it in the Open Ephys GUI | ||
|  | ||
| Here is a video showing how this works: | ||
|  | ||
| <video controls> | ||
| <source src="../../images/ephys-socket-tut/ephys_socket.mp4" type="video/mp4"> | ||
|         
                  cjsha marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| </video> | ||
|  | ||
|  | ||
| <!-- add troubleshooting --> | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,13 +1,4 @@ | ||
| - href: index.md | ||
| items: | ||
| - href: ephys-processing-listening.md | ||
| # - href: open-ephys-socket.md | ||
| # - href: buffers-memory-usage.md | ||
| # - href: bno-calibration.md | ||
| # - href: dynamic-properties.md | ||
| # - href: custom-operator.md | ||
| # - href: integrate-harp.md | ||
| # - href: behavioral-experiment.md | ||
| # - href: create-gui.md | ||
| # - href: custom-operator.md | ||
| # - href: low-latency-closed-loop.md | ||
| - href: ephys-processing-listening.md | ||
| - href: ephys-socket.md | 
            Binary file not shown.
          
    
        
          
          Binary file added
          
            BIN
              
                +18 KB
              
          
        
  images/ephys-socket-tut/ephys_socket_gui_signalchain_connect_lfp_viewer.png
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
          Binary file added
          
            BIN
              
                +21.6 KB
              
          
        
  images/ephys-socket-tut/ephys_socket_gui_signalchain_connect_probe_viewer.png
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
          Binary file added
          
            BIN
              
                +12 KB
              
          
        
  images/ephys-socket-tut/ephys_socket_gui_signalchain_working_lfp_viewer.png
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
          Binary file added
          
            BIN
              
                +23.5 KB
              
          
        
  images/ephys-socket-tut/ephys_socket_gui_signalchain_working_probe_viewer.png
  
  
      
      
   
        
      
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
        
          
          Binary file removed
          
            BIN
              
                -3.89 MB
              
          
        
  images/neuropixelsv1e-gui-tut/headstage-configuration-enable-electrodes.mp4
  
  
      
      
   
        
      
      
    
            Binary file not shown.
          
    Large diffs are not rendered by default.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <WorkflowBuilder Version="2.8.5" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns:p1="clr-namespace:OpenEphys.Sockets.Bonsai;assembly=OpenEphys.Sockets.Bonsai" | ||
| xmlns="https://bonsai-rx.org/2018/workflow"> | ||
| <Workflow> | ||
| <Nodes> | ||
| <Expression xsi:type="Combinator"> | ||
| <Combinator xsi:type="p1:TcpServer"> | ||
| <p1:Name>socket1</p1:Name> | ||
| <p1:Port>9001</p1:Port> | ||
| <p1:Address>localhost</p1:Address> | ||
| </Combinator> | ||
| </Expression> | ||
| <Expression xsi:type="Combinator"> | ||
| <Combinator xsi:type="p1:TcpServer"> | ||
| <p1:Name>socket2</p1:Name> | ||
| <p1:Port>9002</p1:Port> | ||
| <p1:Address>localhost</p1:Address> | ||
| </Combinator> | ||
| </Expression> | ||
| </Nodes> | ||
| <Edges /> | ||
| </Workflow> | ||
| </WorkflowBuilder> | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.