Skip to main content

feature_calculators.NwbSource

feature_calculators.NwbSource(
    kind,
    path=None,
    dandiset_id=None,
    filepath=None,
    version='draft',
    backend='auto',
    electrical_series=None,
    stream_mode=None,
)

Describes how to obtain one SpikeInterface recording from an NWB asset.

This is the composition object for the acquisition axis: backend (HDF5/Zarr) and location (local/remote/DANDI) are fields here instead of subclasses. Build one with the named constructors :meth:local, :meth:remote, or :meth:dandi, then call :meth:to_recording.

Attributes: kind (str): One of "local", "remote", or "dandi". path (str | None): Local path (local) or S3/HTTPS URL (remote). dandiset_id (str | None): DANDI dataset id (dandi). filepath (str | None): Asset path within the dandiset (dandi). version (str): DANDI version, e.g. "draft" or a published version. backend (str): "auto" (detect from the extension), "hdf5", or "zarr". electrical_series (str | None): Which ElectricalSeries to read. One NWB file often holds both an AP and an LFP series, so this selects the band. stream_mode (str | None): SpikeInterface stream mode override. When None a sensible default is chosen per kind/backend (None for local, "remfile" for streamed HDF5, "zarr" for streamed Zarr).

Methods

Name Description
dandi Build a source that streams a DANDI asset (resolved to its S3 URL).
local Build a source for a local NWB file (HDF5 or Zarr).
remote Build a source that streams a remote NWB file from an S3/HTTPS URL.
to_recording Open this source as a SpikeInterface BaseRecording (lazy imports).

dandi

feature_calculators.NwbSource.dandi(
    dandiset_id,
    filepath,
    version='draft',
    backend='auto',
    electrical_series=None,
    stream_mode=None,
)

Build a source that streams a DANDI asset (resolved to its S3 URL).

stream_mode=None auto-selects "remfile" (HDF5) or "zarr" from the backend; pass an explicit mode to override.

local

feature_calculators.NwbSource.local(
    path,
    backend='auto',
    electrical_series=None,
)

Build a source for a local NWB file (HDF5 or Zarr).

remote

feature_calculators.NwbSource.remote(
    url,
    backend='auto',
    electrical_series=None,
    stream_mode=None,
)

Build a source that streams a remote NWB file from an S3/HTTPS URL.

stream_mode=None auto-selects "remfile" (HDF5) or "zarr" from the backend; pass an explicit mode to override.

to_recording

feature_calculators.NwbSource.to_recording()

Open this source as a SpikeInterface BaseRecording (lazy imports).

Returns: A SpikeInterface NwbRecordingExtractor.

Raises: ImportError: If the optional NWB/streaming dependencies are missing.