Feb 03, 2023

Public workspaceBuilding a SpikeGLX Rig with camera: Chronic recoverable Neuropixels in mice V.2

Building a SpikeGLX Rig with camera: Chronic recoverable Neuropixels in mice
  • 1Stanford University
Open access
Protocol CitationEmily A Aery Jones 2023. Building a SpikeGLX Rig with camera: Chronic recoverable Neuropixels in mice. protocols.io https://dx.doi.org/10.17504/protocols.io.kxygxzzxkv8j/v2Version created by Emily A Aery Jones
License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: February 03, 2023
Last Modified: February 03, 2023
Protocol Integer ID: 76318
Keywords: electrophysiology, camera, Neuropixels, freely moving recording, spatial navigation
Funders Acknowledgement:
Simons Collaboration on the Global Brain
Grant ID: 542987SPI
Stanford School of Medicine Dean's Postdoctoral Fellowship
A.P. Giannini Foundation Postdoctoral Fellowship
Abstract
This protocol collection explains how to build a low-cost, lightweight system to implant 1 Neuropixels 1.0 probe or 2 Neuropixels 2.0 probes into mice, record during freely moving behavior, then recover the probes for future use. This protocol first describes how to build a Neuropixels recording system using a National Instruments acquisition system and SpikeGLX software, from parts acquisition through your first recording. It also describes how to integrate a camera, including code and wiring to record and synchronize video frames. See full collection for more details.
Guidelines
The acquisition set up portion of this protocol is intended to be an unofficial, streamlined version of the official documentation, but not a replacement for it.
Materials
Computer:

Acquisition system:

Camera:
Consumables:
  • 12V power supply (Jameco, 170245)
  • 2.1mm barrel jack (Digikey, CP-037A-ND)
  • BNC to wire leads (Digikey, 501-1030-ND)
  • jumper wires (Sparkfun, 11709)
  • resistors (Sparkfun, 10969)
  • breadboard (Sparkfun, 12615)
  • heatshrink tubing (Amazon, B0722HN8SW)
  • solder
Equipment:
  • soldering iron, heat gun, and accessories (wire cutters, soldering clamp, solder, light)
Before start
Set aside a few days to learn how the Neuropixels and SpikeGLX systems work

Select a machine vision camera configuration:
  • You will need a camera that you can manually wire to send synchronizing pulses to the NIDAQ system in order to synchronize video frames with neural data later.
  • You will need a camera, lens, power supply, mount, I/O cable with bare ends, data cable, tripod mount, and computer.
  • Supplier: Allied Vision cameras work with NIDAQ systems. This protocol explains how to wire an Allied Vision camera for this purpose.
  • Camera: Get a high enough resolution & frame rate for your project. Some cameras can adjust their settings so you can capture lower resolution at higher frame rates and vice versa. C(S)-mount refers to the lens attachment. C-mount cameras can take C or CS lenses, but CS-mount cameras can only take CS lenses.
  • Lens: The greater the focal length, the greater the zoom. Use this tool (https://www.baslerweb.com/en/products/tools/lens-selector) to estimate lens size based on camera to object distance and the size of the field. E.g. open field camera might use a 6mm lens, while a pupil camera might use a 24mm lens.
  • Power supply: whatever the camera needs. You may be able to power the camera through the data cable.
  • I/O cable with bare ends: This sends signals to the camera to start/stop capturing and receives signals of frame times.
  • Data cable: GigE (Cat6 cable) & USB are the most common. GigE is generally better over distances >5m.
  • Mounting: Attach to 80/20 by screwing into a tripod mount.
  • Computer: If you don't need real-time control, then just get a tower with enough SSD space to store your videos. If using GigE, make sure you get one that has PCIe cards to fit the Intel network adapter, and also get a PCIe Desktop Adapter.
Set up acquisition hardware
Set up acquisition hardware
Load the PCIe module into your computer
Load the PXIe modules and the IMEC module into the NIDAQ chassis
Connect the PXIe modules to the BNC breakout board and the computer. Connect the IMEC SMA to the BNC board (analog slot 0). Cover remaining unused BNC slots with BNC terminators to prevent TTLs from leaking across channels.
Plug in a probe, connected to a headstage, connected to a cable, into a port on the IMEC module.
NIDAQ chassis (right) has 3 modules, left to right: (1) connect to PCle in the computer, (2) connect to synchronization board, and (3) connect to headstage. The imec module (rightmost) is here connected to a probe (probe box above) and has a cable connecting it to the synchronization board (left), which receives TTL pulses from all hardware to synchronize data streams from multiple sources (e.g. synchronizing video frames to neural data).
NIDAQ chassis (right) has 3 modules, left to right: (1) connect to PCle in the computer, (2) connect to synchronization board, and (3) connect to headstage. The imec module (rightmost) is here connected to a probe (probe box above) and has a cable connecting it to the synchronization board (left), which receives TTL pulses from all hardware to synchronize data streams from multiple sources (e.g. synchronizing video frames to neural data).
Boot the chassis, then the computer.
Note
Always boot the chassis before booting the computer.

Set computer settings
Set computer settings
Get your machine connected to the internet and install any institute-specific software.

Run any Windows updates. These can break things sometimes. If Windows updates that occur after the NIDAQ set up break your SpikeGLX, you can roll them back like this: https://www.howtogeek.com/235474/how-to-roll-back-builds-and-uninstall-updates-on-windows-10/
Install National Instruments drivers
Install National Instruments drivers
Run NI MAX.
The left-hand panel should look like this if everything ran correctly, with no warnings about missing drivers.
The left-hand panel should look like this if everything ran correctly, with no warnings about missing drivers.

Install Enclustra drivers
Install Enclustra drivers
Download the Enclustra drivers: https://billkarsh.github.io/SpikeGLX/Support/Enclustra_Win10.zip. Unzip them anywhere.
Open Device Manager. Under "Other Devices", right-click the PXI device and select "Update". Select browse from my computer and select the folder where you unzipped the Enclustra drivers.
The PXI device should now appear under "Enclustra" in the Device Manager.
Install SpikeGLX
Install SpikeGLX
Create the directory C:/SpikeGLX
Download the latest release: https://billkarsh.github.io/SpikeGLX/#latest-application-downloads. Unzip and place the the whole thing, still inside the release folder, into your new SpikeGLX folder.
Copy all the Calibration files that you received via email when you purchased the probes into the Calibration folder in SpikeGLX. Note that some of them have typos from when IMEC sent them. The correct format is [probe #]/[probe #][ADCCalibration or gainCalValues]. I.e. each probe should have its own directory named after it, with 2 files inside with the probe number once, underscore, and the file type.
Note
If you need a calibration file, email neuropixels.info@imec.be with the probe #

Update firmware
Update firmware
Launch SpikeGLX. Go to Tools/Update Imec Firmware.
Select the slot your IMEC module is in.
Check the box and select the file(s) for a BS and a BSC update. The files for this version of SpikeGLX are in the folder named Firmware that is included in your SpikeGLX release. Click Update.
Power cycle by shutting down the computer, then the NIDAQ, and waiting for a few seconds before rebooting.
Test the probe and headstage
Test the probe and headstage
Launch Spike GLX. Tools/BIST Test or Tools/HST Test.
Select the slot your IMEC module is in, the port your headstage is in, and dock 1.
For HST, plug in the headstage test device. Note as of April 2021, this isn't working in the newest IMEC updates.
First acquisition
First acquisition
Launch SpikeGLX. File/New Acquisition.
Check the boxes for enable IMEC and enable NIDAQ.
Select the slot your module is in and click Add. Then uncheck the boxes except for the row with the port your headstage is plugged into and dock 1 (dock 2 is for 2.0 probes). Click detect.
From here, follow the SpikeGLX user manual. Briefly: set your probe configuration (e.g. which reference to use, which block of channels to record): https://github.com/billkarsh/SpikeGLX/blob/master/Markdown/UserManual.md#im-setup----configuring-imec-probes in the "IM Setup" tab and the name of your file in the "Save" tab. Click "Run" to start streaming, and "Enable recording" to start recording to a file.
Calibrate the headstage clock
Calibrate the headstage clock
Calculate the true sample rate and determine how the headstage and computer clocks map. Do this for every new headstage. First, launch SpikeGLX and detect the headstage, as described above.
In the "NI Setup" tab, specify 0:7 analog (XA) and 0:7 digital (XD).
Go to the Sync tab of the Configuration to set up the sync pulse.
  1. Select “Imec slot x" under Square Wave Source, where x is the slot of the Imec card in the PXIe chassis. This produces a 1 Hz square wave with 50% duty cycle. The sync output will be visible on the last channel of the "imec0 probe", SY0, bit #6.
  2. Input channel should be Analog 0.
  3. Measured period should read “1.00000…” and Threshold should read “1.100."
  4. Check “Use next run for calibration".
  5. Set calibration time: 20 min minimum, 40 min is ideal.
Click Run to do a Calibration run.
When Calibration run is done recording, should get a popup dialog with the measured sample rate. Check “Yes” to apply the new sample rates.
The Calibration file is now in C:/SpikeGLX/Release_<#>/SpikeGLX/_Calibration. You will have:
  • 1 file for _imec, with 1 entry per headstage in the file - if you’ve calibrated with that headstage, you’re calibrated with any probe attached to it.
  • 1 file for _nidaq
During subsequent acquisitions, SpikeGLX should automatically use your most recent Calibration files. You can also choose them manually in the Sync tab. In the Sync tab, make sure "Use next run for calibration" is unchecked and keep the sync pulse enabled to use the calibrated clock.


Note
If you update SpikeGLX, be sure to copy the Calibration files to the new Release folder

Set up the camera
Set up the camera
Plug the I/O cable and the data cable into the camera. Screw tripod adapter onto base, then attach the adapter to an 80/20 L-bracket mounted on 80/20 frame or to Thorlabs components mounted on an air table, depending on your setup.
Allied Vision Mako G mounted to a tripod adapter and an L-bracket to affix it to an 80/20 frame.
Allied Vision Mako G mounted to a tripod adapter and an L-bracket to affix it to an 80/20 frame.
Same as previous figure, implemented
Same as previous figure, implemented

Set up the camera acquisition computer and acquisition software as described by your camera's manufacturer. This should be a separate computer from the SpikeGLX acquisition computer. For Allied Vision cameras connecting via GigE cables, you can follow hardware instructions here: https://github.com/emilyasterjones/X_maze#gige-vimba-camera-acquisition-instructions
Wire I/O cable to send TTL pulses from camera to SpikeGLX
Wire I/O cable to send TTL pulses from camera to SpikeGLX
To synchronize your video data with your neural data, you'll need to send TTL pulses from the camera to the BNC breakout board. To do so, you'll need to wire the Hirose cable to an external power and to the BNC board. First, look up the correct pinout for your Hirose I/O cable: https://cdn.alliedvision.com/fileadmin/content/documents/products/accessories/cable/datasheet/Acc_Cable_DataSheet_K7600xxx_AVT_IOcable_V4.1.1_en.pdf
Wire thusly, to a breadboard first while you troubleshoot, then solder and protect with heatshrink tubing. Use the block diagrams starting on page 136 of this document as a guide: https://cdn.alliedvision.com/fileadmin/content/documents/products/cameras/Mako/techman/Mako_TechMan_en.pdf
  • output power & camera power => power
  • camera ground & BNC ground => ground
  • camera output & BNC input => resistor => ground
Example wiring on a breadboard of the I/O to bare ends cable.
Example wiring on a breadboard of the I/O to bare ends cable.
Note
Test multiple resistors to see which once gives the best TTL pulse.


Set camera settings thusly:
vimba_settings_1.png

Note: unlike in the figure above, don't check the box for 'polarity'.
Note: unlike in the figure above, don't check the box for 'polarity'.

Run SpikeGLX, then hit Run on Vimba Viewer. If it worked, you should see an upward pulse for the duration of the exposure.
TTL pulses received once per frame (up for start of frame, down for end of frame) from a 60fps video capture on channel A2.
TTL pulses received once per frame (up for start of frame, down for end of frame) from a 60fps video capture on channel A2.
Note


Acquire video
Acquire video
Neither SpikeGLX nor Allied Vision have accompanying video acquisition software (Allied Vision's Vimba Viewer allows streaming but not recording of video). To acquire video, use a script to connect to the camera, define its acquisition settings including those for sending TTL pulses, acquire each frame and save it.

One simple option is to install the following: https://github.com/emilyasterjones/X_maze#gige-vimba-camera-acquisition-instructions and then run this script: https://github.com/emilyasterjones/X_maze/tree/main/Capture/Camera. Several camera config files are included; you can create your own by opening Vimba Viewer, searching for and setting relevant variables, then saving this configuration to a file. in particular, adjust the frame rate, gain, and exposure time to suit your project.