jnwb
Dataset-agnostic Python library for Neurodata Without Borders (NWB 2.0+) electrophysiology: addressing, spikes, LFP, spectral analysis, statistics, population methods, decoding, connectivity, laminar CSD, filtering, QC, and visualization.
Documentation: https://jnwb.readthedocs.io/ | Source: https://github.com/HNXJ/jnwb
jnwb is a toolbox, not a pipeline. It supplies small operations over NWB files, arrays, and metadata tables. Task structure, condition codes, and experimental hypotheses stay in project code.
- Dataset-agnostic. No experiment condition names or manuscript results live in the library.
- Explicit nulls. Label permutation requires an exchangeability scheme (
globalorwithin_group). - Preserved signal semantics. Units, sampling rates, coordinate frames, and 0- vs 1-indexing do not change across a function boundary.
Capabilities
| Area | Representative API |
|---|---|
| NWB metadata & addressing | get_all_units_metadata, electrode_inventory, map_peak_channel_to_area, classify_layer_from_depth |
| Spiking | raster_psth, compute_response_metrics, causal_exp_smooth, fit_exponential_onset, pairwise_phase_consistency |
| LFP & spectral | compute_psd, compute_multitaper_psd, band_power, complex_tfr, aggregate_to_db, current_source_density_1d |
| Filtering | bandpass_filter, notch_filter |
| Statistics | permute_labels, cluster_permutation_test, shuffle_pvalue_paired, paired_fire_prob_test |
| Population & decoding | jrsa, nested_cv_linear_svm, compute_population_trajectory |
| Connectivity | granger, phase_slope_index, transfer_entropy, directed_network |
| Quality control | channel_correlation_matrix, repair_lfp_trials, audit_units, audit_electrodes |
| Visualization | raster_psth, setup_vector_graphics, save_figure_suite |
Installation
Python 3.12 only.
pip install jnwb
pip install jnwb==0.1.1
pip install "jnwb[torch,gpu]" # optional
Core dependencies: numpy, scipy, pandas, h5py, pynwb, hdmf, matplotlib, scikit-learn, statsmodels, joblib.
Quickstart
import numpy as np
import jnwb
rng = np.random.default_rng(42)
spikes = np.sort(rng.uniform(0.0, 10.0, 300))
events = np.array([1.0, 3.0, 5.0, 7.0])
time_bins, rate_hz, _ = jnwb.raster_psth(spikes, events, win_ms=(-100.0, 400.0), bin_ms=10.0)
smooth_hz = jnwb.causal_exp_smooth(rate_hz, bin_ms=10.0, tau_ms=25.0)
fit = jnwb.fit_exponential_onset(time_bins, smooth_hz, t0_bounds=(0.0, 200.0))
print(f"Onset t0: {fit['t0']:.1f} ms (R2={fit['r2']:.2f}, {fit['bound_status']})")
fs = 1000.0
lfp = rng.normal(size=1000)
tfr = jnwb.complex_tfr(lfp, fs=fs, freqs=np.linspace(10.0, 60.0, 10))
beta = jnwb.band_power(lfp, fs=fs, freq_range=jnwb.CANONICAL_BANDS["beta"], normalize=False)
print(f"TFR shape: {tfr.shape}, beta power: {beta:.4f}")
NWB session inventory:
import jnwb
units = jnwb.get_all_units_metadata("session.nwb")
electrodes = jnwb.electrode_inventory("session.nwb")
units = jnwb.enrich_units_dataframe(units, electrodes)
print(len(units), "units;", jnwb.audit_units(units))
Documentation
Guides, the public API (jnwb.__all__, 111 symbols), and common mistakes are on Read the Docs.
License
MIT. See LICENSE.
Release files for jnwb 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jnwb-0.1.1.tar.gz | 227.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jnwb-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 393.0 kB
Release files / jnwb-0.1.1.tar.gz
| Download URL | jnwb-0.1.1.tar.gz |
|---|---|
| Size | 227.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77524a2c735fc594fb56a011251482b96317318069794bf833a9403548892bd1
|
|
BLAKE2b-256 checksum How to use checksums |
2f133b81f049bcdee18c40bb14cfd6620212354616f269e122a3e9e3d0a36ecb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / jnwb-0.1.1-py3-none-any.whl
| Download URL | jnwb-0.1.1-py3-none-any.whl |
|---|---|
| Size | 165.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fa51317d0ebaec3f675bc4aa7228d117d6b453784efc08cb4d923318eab6ec3
|
|
BLAKE2b-256 checksum How to use checksums |
bc467e3707a12809a3adb393bad739bd6ade0377130c3be16292874da53dfc89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log