NEO#

get_electrodes_metadata(neo_reader, electrodes_ids: list, block: int = 0) list[source]#

Get electrodes metadata from Neo reader.

The typical information we look for is the information accepted by pynwb.icephys.IntracellularElectrode:
  • name – the name of this electrode

  • device – the device that was used to record from this electrode

  • description – Recording description, description of electrode (e.g., whole-cell, sharp, etc.)

  • comment: Free-form text (can be from Methods)

  • slice – Information about slice used for recording.

  • seal – Information about seal used for recording.

  • location – Area, layer, comments on estimation, stereotaxis coordinates (if in vivo, etc.).

  • resistance – Electrode resistance COMMENT: unit: Ohm.

  • filtering – Electrode specific filtering.

  • initial_access_resistance – Initial access resistance.

Parameters
  • neo_reader ([type]) (Neo reader)

  • electrodes_ids (list) (List of electrodes ids.)

  • block (int, optional) (Block id. Defaults to 0.)

Returns

list

Return type

List of dictionaries containing electrodes metadata.

get_number_of_electrodes(neo_reader) int[source]#

Get number of electrodes from Neo reader.

Returns

The total number of electrodes in the recording.

Return type

int

get_number_of_segments(neo_reader, block: int = 0) int[source]#

Get number of segments from Neo reader.

Parameters
  • neo_reader (neo.io.baseio) – The Neo reader object.

  • block (int, default: 0) – Block index.

Returns

The number of segments in the specified block.

Return type

int

get_command_traces(neo_reader, segment: int = 0, cmd_channel: int = 0) tuple[list, str, str][source]#

Get command traces (e.g. voltage clamp command traces).

Parameters
  • neo_reader (neo.io.baseio) – The Neo reader object.

  • segment (int, optional) – Segment index. Defaults to 0.

  • cmd_channel (int, optional) – ABF command channel (0 to 7). Defaults to 0.

Returns

A tuple containing: - list: The command trace data - str: The title of the command trace - str: The units of the command trace

Return type

tuple[list, str, str]

Notes

This function only works for AxonIO interface.

get_conversion_from_unit(unit: str) float[source]#

Get conversion (to Volt or Ampere) from unit in string format.

Parameters

unit (str) – Unit as string. E.g. pA, mV, uV, etc…

Returns

The conversion factor to convert to Ampere or Volt. For example, for ‘pA’ returns 1e-12 to convert to Ampere.

Return type

float

get_nwb_metadata(neo_reader, metadata: dict = None) dict[source]#

Return default metadata for all recording fields.

Parameters
  • neo_reader (neo.io.baseio) – Neo reader object

  • metadata (dict, optional) – Metadata info for constructing the nwb file.

Returns

Default metadata dictionary containing NWBFile and Icephys device information.

Return type

dict

add_icephys_electrode(neo_reader, nwbfile, metadata: dict = None)[source]#

Add icephys electrodes to nwbfile object.

Will always ensure nwbfile has at least one icephys electrode. Will auto-generate a linked device if the specified name does not exist in the nwbfile.

Parameters
  • neo_reader (neo.io.baseio)

  • nwbfile (NWBFile) – NWBFile object to add the icephys electrode to.

  • metadata (dict, optional) – Metadata info for constructing the nwb file. Should be of the format:

    metadata['Icephys']['Electrodes'] = [
        {
            'name': my_name,
            'description': my_description,
            'device_name': my_device_name
        },
        ...
    ]
    
add_icephys_recordings(neo_reader, nwbfile: NWBFile, metadata: dict = None, icephys_experiment_type: str = 'voltage_clamp', stimulus_type: str = 'not described', skip_electrodes: tuple[int] = ())[source]#

Add icephys recordings (stimulus/response pairs) to nwbfile object.

Parameters
  • neo_reader (neo.io.baseio)

  • nwbfile (NWBFile)

  • metadata (dict, optional)

  • icephys_experiment_type ({‘voltage_clamp’, ‘current_clamp’, ‘izero’}) – Type of icephys recording.

  • stimulus_type (str, default: ‘not described’)

  • skip_electrodes (tuple, default: ()) – Electrode IDs to skip.

add_neo_to_nwb(neo_reader, nwbfile: NWBFile, metadata: dict = None, icephys_experiment_type: str = 'voltage_clamp', stimulus_type: Optional[str] = None, skip_electrodes: tuple[int] = ())[source]#

Auxiliary static method for nwbextractor.

Adds all recording related information from recording object and metadata to the nwbfile object.

Parameters
  • neo_reader (Neo reader object)

  • nwbfile (NWBFile) – nwb file to which the recording information is to be added

  • metadata (dict) – metadata info for constructing the nwb file (optional). Check the auxiliary function docstrings for more information about metadata format.

  • icephys_experiment_type (str (optional)) – Type of Icephys experiment. Allowed types are: ‘voltage_clamp’, ‘current_clamp’ and ‘izero’. If no value is passed, ‘voltage_clamp’ is used as default.

  • stimulus_type (str, optional)

  • skip_electrodes (tuple, optional) – Electrode IDs to skip. Defaults to ().

write_neo_to_nwb(neo_reader: BaseIO, save_path: Optional[Path] = None, overwrite: bool = False, nwbfile=None, metadata: dict = None, icephys_experiment_type: Optional[str] = None, stimulus_type: Optional[str] = None, skip_electrodes: Optional[tuple] = ())[source]#

Primary method for writing a Neo reader object to an NWBFile.

Parameters
  • neo_reader (Neo reader)

  • save_path (PathType) – Required if an nwbfile is not passed. Must be the path to the nwbfile being appended, otherwise one is created and written.

  • overwrite (bool) – If using save_path, whether to overwrite the NWBFile if it already exists.

  • nwbfile (NWBFile) – Required if a save_path is not specified. If passed, this function will fill the relevant fields within the nwbfile.

  • metadata (dict) –

    metadata info for constructing the nwb file (optional). Should be of the format:

    metadata['Ecephys'] = {}
    

    with keys of the forms:

    metadata['Ecephys']['Device'] = [
        {
            'name': my_name,
            'description': my_description
        },
        ...
    ]
    metadata['Ecephys']['ElectrodeGroup'] = [
        {
            'name': my_name,
            'description': my_description,
            'location': electrode_location,
            'device': my_device_name
        },
        ...
    ]
    metadata['Ecephys']['Electrodes'] = [
        {
            'name': my_name,
            'description': my_description
        },
        ...
    ]
    metadata['Ecephys']['ElectricalSeries'] = {
        'name': my_name,
        'description': my_description
    }
    

    Note that data intended to be added to the electrodes table of the NWBFile should be set as channel properties in the RecordingExtractor object.

  • icephys_experiment_type (str (optional)) – Type of Icephys experiment. Allowed types are: ‘voltage_clamp’, ‘current_clamp’ and ‘izero’. If no value is passed, ‘voltage_clamp’ is used as default.

  • stimulus_type (str, optional)

  • skip_electrodes (tuple, optional) – Electrode IDs to skip. Defaults to ().