Intracellular Electrophysiology#

Base Interface#

Shared writing contract for modern intracellular-electrophysiology interfaces.

class BaseIcephysInterface(verbose: bool = False, **source_data)[source]#

Bases: BaseDataInterface

Base interface for patch-clamp data written as NWB icephys series.

Concrete interfaces return source data through _get_icephys_series_data(). This base owns NWB object construction, metadata-linked electrode resolution, and the per-sweep IntracellularRecordings rows. The hierarchy above those rows remains a converter responsibility, once every interface has contributed.

add_to_nwbfile(nwbfile: NWBFile, metadata: dict | None = None) None[source]#

Write this interface’s response, optional stimulus, and sweep rows to an NWB file.

Abf Interface#

get_start_datetime(neo_reader)[source]#

Get start datetime for Abf file.

Parameters:

neo_reader (neo.io.AxonIO) – The Neo reader object for the ABF file.

Returns:

The start date and time of the recording.

Return type:

datetime

class AbfInterface(file_paths: list[Annotated[pathlib._local.Path, PathType(path_type='file')]], *args, icephys_metadata: dict | None = None, icephys_metadata_file_path: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None)[source]#

Bases: LegacyBaseIcephysInterface

Interface for ABF intracellular electrophysiology data.

ABF IcephysInterface based on Neo AxonIO.

Parameters:
  • file_paths (list of FilePaths) – List of files to be converted to the same NWB file.

  • icephys_metadata (dict, optional) – Dictionary containing the Icephys-specific metadata.

  • icephys_metadata_file_path (FilePath, optional) – JSON file containing the Icephys-specific metadata.

display_name: str | None = 'ABF Icephys'#
associated_suffixes: tuple[str] = ('.abf',)#
info: str | None = 'Interface for ABF intracellular electrophysiology data.'#
classmethod get_extractor_class()[source]#

Get the extractor class for this interface.

This classmethod must be implemented by each concrete interface to specify which extractor class to use.

Returns:

The extractor class or function to use for initialization.

Return type:

type or callable

classmethod get_source_schema() dict[source]#

Infer the JSON schema for the source_data from the method signature (annotation typing).

Returns:

The JSON schema for the source_data.

Return type:

dict

get_metadata() DeepDict[source]#

Child DataInterface classes should override this to match their metadata.

Returns:

The metadata dictionary containing basic NWBFile metadata.

Return type:

DeepDict

set_aligned_starting_time(aligned_starting_time: float)[source]#

Align the starting time for this interface relative to the common session start time.

Must be in units seconds relative to the common ‘session_start_time’.

Parameters:

aligned_starting_time (float) – The starting time for all temporal data in this interface.

set_aligned_segment_starting_times(aligned_segment_starting_times: list[list[float]], stub_test: bool = False)[source]#

Align the individual starting time for each video in this interface relative to the common session start time.

Must be in units seconds relative to the common ‘session_start_time’.

Parameters:
  • aligned_segment_starting_times (list of list of floats) – The relative starting times of each video. Outer list is over file paths (readers). Inner list is over segments of each recording.

  • stub_test (bool, default=False)

Bruker VoltageRecording Interface#

Interface for intracellular electrophysiology recorded by Bruker PrairieView’s VoltageRecording.

class BrukerVoltageRecordingInterface(file_paths: list[Annotated[pathlib._local.Path, PathType(path_type='file')]], *, response_signal_name: str | None = None, mode: Literal['voltage_clamp', 'current_clamp', 'izero'] | None = None, stimulus_type: str | None = None, repetition: str | None = None, condition: str | None = None, metadata_key: str | None = None, verbose: bool = False)[source]#

Bases: BaseIcephysInterface

Interface for intracellular electrophysiology recorded by Bruker PrairieView’s VoltageRecording.

PrairieView writes one CSV/XML pair per cycle, a cycle being one trigger of the acquisition and so one sweep. One interface instance corresponds to one electrode’s cycles, given as an explicit list: nothing in the format states which cycles belong to which cell, so the list is the caller’s assertion rather than something inferred from a folder layout. Those cycles are concatenated into a single continuous PatchClampSeries, placed on one timeline by each cycle’s DateTime, and each is recorded through the NWB IntracellularRecordings table via a (start_index, count) range.

Like the other icephys interfaces it stops there: the upper hierarchy tables (SimultaneousRecordings and above) are built only once the full set of electrodes is known, which is BrukerVoltageRecordingConverter’s job.

Parameters:
  • file_paths (list of FilePath) – The cycle CSV files of one electrode, in acquisition order. Each must have its VoltageRecording XML beside it, as PrairieView writes it. The list is explicit because nothing in the format states which cycles belong together; globbing a session folder belongs in the conversion script.

  • response_signal_name (str, optional) – Which recorded signal is this electrode’s response, given as its name in the CSV header and the XML SignalList (for example "Primary"). Optional while only one signal was recorded, which is the common case. See get_signal_names.

  • mode ({“voltage_clamp”, “current_clamp”, “izero”}, optional) – The clamp mode, which selects the NWB series class. Derived from Primary’s unit when it can be (mV for current clamp, pA for voltage clamp), so this is needed only to record an izero run, which is indistinguishable from ordinary current clamp in the file, or when the response is a signal other than Primary.

  • stimulus_type (str, optional) – What kind of run this was, written to the stimulus_type column and carried up to the sequential recording. PrairieView records no protocol section, so there is nothing to derive it from; when no run in the file states one the column is omitted rather than filled with a placeholder, and when a sibling run states one this run’s rows are left empty.

  • repetition (str, optional) – Label grouping this run’s sequential recording with others into a Repetitions entry (the same protocol repeated). Used only when combining interfaces in a converter; if set on any interface it must be set on all of them.

  • condition (str, optional) – Label grouping this run’s repetition with others into an ExperimentalConditions entry. Requires repetition (conditions group repetitions); if set on any interface it must be set on all.

  • metadata_key (str, optional) – Identity of this interface’s response PatchClampSeries in the metadata dict. Defaults to the acquisition stem the cycles share plus the response signal name.

  • verbose (bool, default: False)

display_name: str | None = 'Bruker VoltageRecording'#
keywords: tuple[str] = ('intracellular electrophysiology', 'patch clamp', 'icephys', 'bruker', 'prairie view')#
associated_suffixes: tuple[str] = ('.csv', '.xml')#
info: str | None = 'Interface for intracellular electrophysiology recorded by Bruker PrairieView (VoltageRecording).'#
get_metadata() DeepDict[source]#

Child DataInterface classes should override this to match their metadata.

Returns:

The metadata dictionary containing basic NWBFile metadata.

Return type:

DeepDict

classmethod get_signal_names(file_path: Annotated[Path, PathType(path_type=file)]) list[str][source]#

Names of the signals recorded in a cycle CSV: the options for response_signal_name. Call this before constructing the interface to see what is available.

Parameters:

file_path (FilePath) – Path to one cycle’s VoltageRecording CSV.

Returns:

The recorded signal names, in the order their columns appear. Taken from the XML’s enabled signals rather than the CSV header, whose names are unreliable.

Return type:

list of str

Converter that combines several BrukerVoltageRecordingInterface instances (for example dual patch).

class BrukerVoltageRecordingConverter(data_interfaces: list[neuroconv.basedatainterface.BaseDataInterface] | dict[str, neuroconv.basedatainterface.BaseDataInterface], verbose=False)[source]#

Bases: ConverterPipe

Combine one or more BrukerVoltageRecordingInterface instances into a single NWB icephys table.

Each interface writes one electrode’s cycles as a continuous PatchClampSeries and one intracellular-recordings row per cycle, tagging each row with the run-level grouping columns (sequence, the optional stimulus_type, and the optional repetition / condition). This converter aligns the electrodes on one timeline, then hands off to _build_icephys_hierarchical_tables(), which reads those columns back and builds the SimultaneousRecordings / SequentialRecordings / Repetitions / ExperimentalConditions tables, and to _add_sweep_time_intervals_to_nwbfile(), which writes the sweep start and stop times as a TimeIntervals table. Both are deliberately format-agnostic, and the interfaces never call them, because building those tables locks their membership and no single interface knows whether it is the last contributor to the file.

So it is also worth using for a single electrode: that is where its hierarchy and sweep tables come from.

Initialize an NWBConverter instance by validating the provided source data and dynamically instantiating the data interfaces on the source_data dictionary.

Parameters:
  • source_data (dict[str, dict]) – A dictionary where keys are interface names and values are the corresponding parameters required to initialize each data interface.

  • verbose (bool, optional) – If True, enables verbose mode, by default False. This is propagated to the data interfaces.

display_name: str | None = 'Bruker VoltageRecording Converter'#
keywords: tuple[str] = ('intracellular electrophysiology', 'patch clamp', 'icephys', 'bruker', 'prairie view')#
associated_suffixes: tuple[str] = ('.csv', '.xml')#
info: str | None = 'Combines several BrukerVoltageRecordingInterface instances into one icephys hierarchy.'#
get_metadata() dict[source]#

Auto-fill as much of the metadata as possible. Must comply with metadata schema.

Parameters:

use_new_metadata_format (bool, default: True) – Ask each interface for the dict-based format. Interfaces that emit only that format ignore the argument, so a converter mixing the two kinds returns one consistently dict-based dictionary.

Returns:

The metadata dictionary containing auto-filled metadata from all interfaces.

Return type:

DeepDict

add_to_nwbfile(nwbfile: NWBFile, metadata: dict | None = None, conversion_options: dict | None = None) None[source]#

Add data from the instantiated data interfaces to the given NWBFile.

Parameters:
  • nwbfile (NWBFile) – The NWB file object to which the data from the data interfaces will be added.

  • metadata (dict) – The metadata dictionary that contains information used to describe the data.

  • conversion_options (dict, optional) – A dictionary containing conversion options for each interface, where non-default behavior is requested. Each key corresponds to a data interface name, and the values are dictionaries with options for that interface. By default, None.