Skip to main content

This NWB extension defines data types for Fast-Scan Cyclic Voltammetry (FSCV), a neurochemical recording technique used to study dopamine and other neuromodulator dynamics. It supports storing the applied triangular ramp waveform and the measured electrochemical current.

Project description

ndx-fscv Extension for NWB

This NWB extension defines data types for Fast-Scan Cyclic Voltammetry (FSCV), a neurochemical recording technique used to study dopamine and other neuromodulator dynamics. It supports storing the applied triangular ramp waveform and the measured electrochemical current.

Installation

You can install the stable version of the extension from PyPI using pip:

pip install ndx-fscv

If you want to install the development version of the extension you can install it directly from the GitHub repository. The following command installs the development version of the extension:

pip install -U git+https://github.com/catalystneuro/ndx-fscv.git

Usage

Writing FSCV Data

Below is a minimal example of how to use the extension to add FSCV data to an NWB file:

from datetime import datetime
import numpy as np
from dateutil.tz import tzutc
from pynwb import NWBFile, NWBHDF5IO
from ndx_fscv import FSCVExcitationSeries, FSCVResponseSeries

# Create NWBFile
nwbfile = NWBFile(
    session_description="FSCV experiment",
    identifier="FSCV123",
    session_start_time=datetime(2024, 1, 1, tzinfo=tzutc()),
)

# Create FSCVExcitationSeries
applied_voltages = np.random.randn(100,)  # example data with 100 time points
excitation_series = FSCVExcitationSeries(
    name="fscv_excitation_series",
    description="The applied FSCV excitation waveform over time.",
    data=applied_voltages,
    rate=25_000.0,
    scan_frequency=10.0,
    sweep_rate=400.0,
    waveform_shape="Triangle",
    unit="volts",
)

# Create device and electrode group
device = nwbfile.create_device(
    name="fscv_device",
    description="A 4-channel FSCV device.",
)
electrode_group = nwbfile.create_electrode_group(
    name="fscv_electrode_group",
    description="The electrode group for the FSCV electrodes.",
    device=device,
    location="brain region",
)

# Add the electrodes to the NWBFile
for _ in range(4):
    nwbfile.add_electrode(group=electrode_group, location="brain region")

# Create an electrode table region referencing the FSCV electrodes
electrodes = nwbfile.create_electrode_table_region(region=[0, 1, 2, 3], description="FSCV electrodes")

# Create FSCVResponseSeries
measured_currents = np.random.randn(100, 4)  # example data with 100 time points and 4 electrodes
response_series = FSCVResponseSeries(
    name="fscv_response_series",
    description="The measured FSCV response currents over time.",
    data=measured_currents,
    rate=25_000.0,
    electrodes=electrodes,
    excitation_series=excitation_series,
    unit="amperes",
)

# Add to NWBFile
nwbfile.add_acquisition(excitation_series)
nwbfile.add_acquisition(response_series)

# Write to file
with NWBHDF5IO("example_fscv.nwb", "w") as io:
    io.write(nwbfile)

Reading FSCV Data

To read FSCV data from an NWB file:

from pynwb import NWBHDF5IO
from ndx_fscv import FSCVExcitationSeries, FSCVResponseSeries

with NWBHDF5IO("example_fscv.nwb", "r") as io:
    nwbfile = io.read()
    excitation = nwbfile.acquisition["fscv_excitation_series"]
    response = nwbfile.acquisition["fscv_response_series"]
    print(excitation.data[:])
    print(response.data[:])

Visualization

ndx-fscv provides built-in plotting utilities for visualizing FSCV data directly from NWB files.

You will need matplotlib to use these plotting functions:

pip install -U matplotlib

The main plotting functions are:

  • plot_series: Plots the FSCV excitation (voltage) and response (current) time series for a specified time window.
  • plot_cv: Plots the cyclic voltammogram (CV) for one or more scans, overlaid for each electrode.

Example usage:

from ndx_fscv.plot import plot_series, plot_cv
from pynwb import NWBHDF5IO

with NWBHDF5IO("example_fscv.nwb", "r") as io:
    nwbfile = io.read()
    response = nwbfile.acquisition["fscv_response_series"]
    excitation = nwbfile.acquisition["fscv_excitation_series"]

    # Plot the time series data for the first 0.5 seconds
    plot_series(
        response_series=response,
        excitation_series=excitation,
        start_time=0.0,
        stop_time=0.5,
    )
    # Plot the cyclic voltammogram for the first scan
    plot_cv(response_series=response, excitation_series=excitation, start_scan_index=0, num_scans=1)

This extension was created using ndx-template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndx_fscv-0.1.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndx_fscv-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file ndx_fscv-0.1.0.tar.gz.

File metadata

  • Download URL: ndx_fscv-0.1.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ndx_fscv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 079bce1b782b917b1288d6a54413a13247237f06279dcab427aed7d929fcae39
MD5 b0bc528b629cd4f65458eadf526b4f74
BLAKE2b-256 95ec9f9aaa1abcdf1494cf96e2e2e3459e77457f6ab4df2f80fcae19c9c8edbc

See more details on using hashes here.

File details

Details for the file ndx_fscv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ndx_fscv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ndx_fscv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa37482918500c8a2c1750d77dc561e84763b68c7985ba82fab855a8517f0413
MD5 1be3e763720a5b484f5a9a365a00f10e
BLAKE2b-256 d8661db1242d391a2afbc33f170cc22555c07cf3cb051e54e5e03e21671aab35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page