Skip to main content

CICADA NWB

Documentation

cicada-nwb reads NWB files (Neurodata Without Borders) from Python. It is the data access layer of CICADA (BiorXiv preprint), and it works on its own: no GUI and no analysis package needed.

A file opens through submodules: calcium_imaging, electrophysiology, behavior, widefield, optogenetic and metadata (lab packages can add more). It is read-only: it never changes a file. A file on your disk or on the DANDI archive is opened the same way. The file stays open while the session object exists, so only the data you ask for is read. Use a with block to close it.

Install

From PyPI:

conda create -n cicada_env python=3.11
conda activate cicada_env
pip install cicada-nwb

Or from GitLab, a given release (tag):

pip install "git+https://gitlab.com/cossartlab/cicada_nwb.git@0.5.0"
Contributor: install from a clone
git clone https://gitlab.com/cossartlab/cicada_nwb.git /path/to/cicada_nwb
conda create -n cicada_env python=3.11
conda activate cicada_env
pip install -e "/path/to/cicada_nwb[dev]"

Quick start

A getter returns None, or an empty list or dict, for what is missing: check before you read.

from cicada_nwb import NWBSession

path = "my_file.nwb"    # a local .nwb file, or a DANDI address: dandi://000728/sub-.../sub-..._ophys.nwb

with NWBSession(path) as session:
    print(session.identifier, session.subject_id, session.age, session.age_unit)

    # Calcium imaging: a series is addressed by [module, interface, series name]
    series = session.calcium_imaging.get_roi_response_series()      # {module: {interface: [names]}}
    if series:
        module = next(iter(series))
        interface = next(iter(series[module]))
        keys = [module, interface, series[module][interface][0]]
        traces = session.calcium_imaging.get_roi_response_serie_data(keys)        # (n_cells, n_frames)
        times = session.calcium_imaging.get_roi_response_serie_timestamps(keys)   # (n_frames,) in s
    # Or pick series by the kind of their values: "traces", or rasters, spike counts, event amplitudes
    traces_series = session.calcium_imaging.get_roi_response_series_by_kind("traces")   # [[module, interface, name], ...]
    raster_series = session.calcium_imaging.get_raster_like_series()

    # Electrophysiology
    if session.electrophysiology.has_units():
        spike_trains = session.electrophysiology.get_spike_times("spike_times")   # one array per unit

    # Behavior
    trial_table = session.behavior.get_trial_table()                  # DataFrame, or None without trials
    events = session.behavior.get_behavioral_events_names()           # [] without events
    if events:
        event_times = session.behavior.get_behavioral_events_times(events[0])     # (2, n_events): start, stop

    # Widefield: an acquisition is addressed by [module, name]
    acquisitions = session.widefield.get_wf_acquisition_dict()        # {module: [names]}
    if acquisitions:
        module = next(iter(acquisitions))
        wf_times = session.widefield.get_widefield_timestamps([module, acquisitions[module][0]])

Complete script: template. For computations (PSTH, assemblies), see the cicada-tools quick start.

The submodules

Submodule Accessed via Key methods
2P calcium imaging session.calcium_imaging get_roi_response_series(), get_roi_response_serie_data(), get_cell_indices_by_cell_type()
Electrophysiology session.electrophysiology get_units_table(), get_spike_times(), get_units_location(), get_electrical_series_data()
Behavior session.behavior get_trial_table(), get_behavioral_epochs_times(), get_behavioral_events_times()
Widefield calcium imaging session.widefield get_widefield_timestamps(), get_widefield_dff0()
Optogenetic stimulation session.optogenetic has_opto_stimulation(), get_opto_stimulation_times()
Metadata session.metadata get_sessions_info()

Lab-specific submodules

Lab packages add session.<lab> submodules, for example session.petersen (cicada-petersen) and session.cossart (cicada-cossart). Example: template.

Documentation

Quick start, user guide and API reference: cicada-analysis.readthedocs.io.

What's inside the package
cicada_nwb/
├── nwb_session.py     # NWBSession: opens one NWB file (local or DANDI), holds the submodules
├── submodules/        # metadata, calcium_imaging, electrophysiology, behavior, widefield,
│                      # optogenetic (getters and question methods)
├── lab_submodules/    # NWBLabSubmodule: base of the lab submodules of the lab packages
├── dandi.py           # DANDI addresses, streaming and download
├── cli.py             # the cicada-dandi command
└── testing/           # Synthetic NWB files for tests

Metadata

Release files for cicada-nwb 0.5.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 cicada-nwb 0.5.0
File Size Uploaded Provenance Actions
cicada_nwb-0.5.0.tar.gz 91.5 kB Without provenance Details for cicada_nwb-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cicada-nwb 0.5.0
File Interpreter ABI Platform Actions
cicada_nwb-0.5.0-py3-none-any.whl Python 3 none any Details for cicada_nwb-0.5.0-py3-none-any.whl

Total release size: 154.3 kB

Release files / cicada_nwb-0.5.0.tar.gz

Download URL cicada_nwb-0.5.0.tar.gz
Size 91.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c0cbb53306990cd05177d6f7141390db67b779db7d2041251a98ca16e2c1f7a9
BLAKE2b-256 checksum
How to use checksums
abb30368a47902511813762b7c48094c05adc9f66953a6a997fe334cde144c36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / cicada_nwb-0.5.0-py3-none-any.whl

Download URL cicada_nwb-0.5.0-py3-none-any.whl
Size 62.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b3620ff9a7a9f07c2b03f56ff5b5c64fee3bbb64f0c17e2316288bc2ce41765
BLAKE2b-256 checksum
How to use checksums
bda73f1a6d1e43a73f4f51ef02cce4f3a2c45a82f91b521001a13667d419aefc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.11.18

Security for cicada-nwb 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

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