Skip to main content

ndx-photometry Extension for NWB

Build Status Documentation Status

NWB - Photometry

Introduction

This is an NWB extension for storing photometry recordings and associated metadata. This extension stores photometry information across three folders in the NWB file: acquisition, processing, and general. The acquisiton folder contains a FiberPhotometryResponseSeries which references rows of FibersTable, ExcitationSourcesTable, PhotodetectorsTable and FluorophoresTable. The new types for this extension are in metadata and processing.

Metadata

  1. FibersTable stores rows for each fiber with information about the location, photodetector, and more (associated with each fiber).
  2. ExcitationSourcesTable stores rows for each excitation source with information about the peak wavelength, source type, and the commanded voltage series of type CommandedVoltageSeries
  3. PhotodectorsTable stores rows for each photodetector with information about the peak wavelength, type, etc.
  4. FluorophoresTable stores rows for each fluorophore with information about the fluorophore itself and the injeciton site.

Processing

  1. DeconvoledROIResponseSeries stores DfOverF and Fluorescence traces and extends ROIResponseSeries to contain information about the deconvolutional and downsampling procedures performed.

This extension was developed by Akshay Jaggi, Ben Dichter, and Ryan Ly.

Installation

pip install ndx-photometry

Usage

import datetime
import numpy as np

from pynwb import NWBHDF5IO, NWBFile
from pynwb.ophys import RoiResponseSeries
from ndx_photometry import (
    FibersTable,
    PhotodetectorsTable,
    ExcitationSourcesTable,
    FluorophoresTable,
    FiberPhotometryResponseSeries,
    FiberPhotometry
)


nwbfile = NWBFile(
    session_description="session_description",
    identifier="identifier",
    session_start_time=datetime.datetime.now(datetime.timezone.utc),
)

# Create a Fibers table, and add one (or many) fiber
fibers_table = FibersTable(description="fibers table")
fibers_table.add_row(
    location="my location",
    notes="notes"
)

# Create an Excitation Sources table, and a one (or many) excitation source
excitationsources_table = ExcitationSourcesTable(description="excitation sources table")
excitationsources_table.add_row(
    peak_wavelength=700.0,
    source_type="laser",
)

# Create a Photodetectors table, and add one (or many) photodetector
photodetectors_table = PhotodetectorsTable(description="photodetectors table")
photodetectors_table.add_row(
    peak_wavelength=500.0,
    type="PMT",
    gain=100.0
)

# Create a Fluorophores table, and add one (or many) fluorophore
fluorophores_table = FluorophoresTable(description="fluorophores")
fluorophores_table.add_row(
    label="dlight",
    location="VTA",
    coordinates=(3.0,2.0,1.0),
    excitation_peak_wavelength=700.0,
    emission_peak_wavelength=500.0
)

# Here we add the metadata tables to the metadata section
nwbfile.add_lab_meta_data(
    FiberPhotometry(
        fibers=fibers_table,
        excitation_sources=excitationsources_table,
        photodetectors=photodetectors_table,
        fluorophores=fluorophores_table
    )
)

# Create a raw FiberPhotometryResponseSeries, this is your main acquisition
# We should create DynamicTableRegion referencing the correct rows for each table
fiber_ref = fibers_table.create_fiber_region(region=[0], description='source fiber')
excitation_ref = excitationsources_table.create_excitation_source_region(region=[0], description='excitation sources')
photodetector_ref = photodetectors_table.create_photodetector_region(region=[0], description='photodetector')
fluorophore_ref = fluorophores_table.create_fluorophore_region(region=[0], description='fluorophore')

fp_response_series = FiberPhotometryResponseSeries(
    name="MyFPRecording",
    data=np.random.randn(100, 1),
    unit='F',
    rate=30.0,
    fibers=fiber_ref,
    excitation_sources=excitation_ref,
    photodetectors=photodetector_ref,
    fluorophores=fluorophore_ref,
)

nwbfile.add_acquisition(fp_response_series)

# write nwb file
filename = 'test.nwb'
with NWBHDF5IO(filename, 'w') as io:
    io.write(nwbfile)

# read nwb file and check its contents
with NWBHDF5IO(filename, 'r', load_namespaces=True) as io:
    nwbfile = io.read()
    # Access and print information about the acquisition
    print(nwbfile.acquisition["MyFPRecording"])
    # Access and print all of the metadata
    print(nwbfile.lab_meta_data)

This extension was created using ndx-template.

Metadata

Release files for ndx-photometry 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ndx-photometry 0.4.0
File Size Uploaded
ndx-photometry-0.4.0.tar.gz 19.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ndx-photometry 0.4.0
File Interpreter ABI Platform
ndx_photometry-0.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 30.6 kB

Release files / ndx-photometry-0.4.0.tar.gz

Download URL ndx-photometry-0.4.0.tar.gz
Size 19.3 kB
Tags Source
SHA-256 checksum
How to use checksums
07ea66d10a1cf65ddf968e7f92f909466ba2deaca16613ce0b320cd56ae21684
BLAKE2b-256 checksum
How to use checksums
7b757e97c8ab553bd9f5a95cba4b4efcd87e0f815ff41dedb3f2ce2f202617da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release files / ndx_photometry-0.4.0-py2.py3-none-any.whl

Download URL ndx_photometry-0.4.0-py2.py3-none-any.whl
Size 11.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ce5740e7638410208032829d23bfc3a7aa3ad63976332c8b420a443d60534285
BLAKE2b-256 checksum
How to use checksums
8a1b573436722a6215da972acea7511d5d77ba84ac76eabfacbf20a85ec3fe3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page