pynwb package
Subpackages
- pynwb.io package
- Submodules
- pynwb.io.base module
- pynwb.io.behavior module
- pynwb.io.core module
- pynwb.io.device module
- pynwb.io.ecephys module
- pynwb.io.epoch module
- pynwb.io.file module
- pynwb.io.icephys module
- pynwb.io.image module
- pynwb.io.misc module
- pynwb.io.ogen module
- pynwb.io.ophys module
- pynwb.io.retinotopy module
- pynwb.io.utils module
- Module contents
- Submodules
- pynwb.legacy package
- pynwb.testing package
Submodules
- pynwb.base module
ProcessingModuleProcessingModule.descriptionProcessingModule.data_interfacesProcessingModule.containersProcessingModule.add_containerProcessingModule.get_containerProcessingModule.add_data_interfaceProcessingModule.get_data_interfaceProcessingModule.keysProcessingModule.valuesProcessingModule.itemsProcessingModule.__getitem__ProcessingModule.addProcessingModule.getProcessingModule.namespaceProcessingModule.neurodata_type
TimeSeriesTimeSeries.DEFAULT_DATATimeSeries.DEFAULT_UNITTimeSeries.DEFAULT_RESOLUTIONTimeSeries.DEFAULT_CONVERSIONTimeSeries.DEFAULT_OFFSETTimeSeries.timestamps_unitTimeSeries.intervalTimeSeries.starting_timeTimeSeries.starting_time_unitTimeSeries.num_samplesTimeSeries.dataTimeSeries.data_linkTimeSeries.timestampsTimeSeries.timestamp_linkTimeSeries.time_unitTimeSeries.get_timestampsTimeSeries.get_data_in_unitsTimeSeries.commentsTimeSeries.continuityTimeSeries.controlTimeSeries.control_descriptionTimeSeries.conversionTimeSeries.descriptionTimeSeries.namespaceTimeSeries.neurodata_typeTimeSeries.offsetTimeSeries.rateTimeSeries.resolutionTimeSeries.unit
BaseImageImageExternalImageImageReferencesImagesTimeSeriesReferenceTimeSeriesReferenceVectorDataTimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_TUPLETimeSeriesReferenceVectorData.TIME_SERIES_REFERENCE_NONE_TYPETimeSeriesReferenceVectorData.namespaceTimeSeriesReferenceVectorData.neurodata_typeTimeSeriesReferenceVectorData.add_rowTimeSeriesReferenceVectorData.appendTimeSeriesReferenceVectorData.get
- pynwb.behavior module
- pynwb.core module
- pynwb.device module
- pynwb.ecephys module
- pynwb.epoch module
- pynwb.file module
LabMetaDataSubjectNWBFileNWBFile.all_childrenNWBFile.objectsNWBFile.epoch_tagsNWBFile.icephys_filteringNWBFile.add_epoch_columnNWBFile.add_epochNWBFile.add_electrode_columnNWBFile.add_electrodeNWBFile.create_electrode_table_regionNWBFile.add_unit_columnNWBFile.add_unitNWBFile.add_trial_columnNWBFile.add_trialNWBFile.add_invalid_times_columnNWBFile.add_invalid_time_intervalNWBFile.set_electrode_tableNWBFile.add_acquisitionNWBFile.add_stimulusNWBFile.add_stimulus_templateNWBFile.get_intracellular_recordingsNWBFile.add_intracellular_recordingNWBFile.get_icephys_simultaneous_recordingsNWBFile.add_icephys_simultaneous_recordingNWBFile.get_icephys_sequential_recordingsNWBFile.add_icephys_sequential_recordingNWBFile.get_icephys_repetitionsNWBFile.add_icephys_repetitionNWBFile.get_icephys_experimental_conditionsNWBFile.add_icephys_experimental_conditionNWBFile.get_icephys_meta_parent_tableNWBFile.add_scratchNWBFile.get_scratchNWBFile.copyNWBFile.acquisitionNWBFile.add_analysisNWBFile.add_deviceNWBFile.add_device_modelNWBFile.add_electrode_groupNWBFile.add_icephys_electrodeNWBFile.add_imaging_planeNWBFile.add_lab_meta_dataNWBFile.add_ogen_siteNWBFile.add_processing_moduleNWBFile.add_time_intervalsNWBFile.analysisNWBFile.create_deviceNWBFile.create_device_modelNWBFile.create_electrode_groupNWBFile.create_icephys_electrodeNWBFile.create_imaging_planeNWBFile.create_lab_meta_dataNWBFile.create_ogen_siteNWBFile.create_processing_moduleNWBFile.create_time_intervalsNWBFile.data_collectionNWBFile.device_modelsNWBFile.devicesNWBFile.electrode_groupsNWBFile.electrodesNWBFile.epochsNWBFile.experiment_descriptionNWBFile.experimenterNWBFile.file_create_dateNWBFile.get_acquisitionNWBFile.get_analysisNWBFile.get_deviceNWBFile.get_device_modelNWBFile.get_electrode_groupNWBFile.get_icephys_electrodeNWBFile.get_imaging_planeNWBFile.get_lab_meta_dataNWBFile.get_ogen_siteNWBFile.get_processing_moduleNWBFile.get_stimulusNWBFile.get_stimulus_templateNWBFile.get_time_intervalsNWBFile.icephys_electrodesNWBFile.icephys_experimental_conditionsNWBFile.icephys_repetitionsNWBFile.icephys_sequential_recordingsNWBFile.icephys_simultaneous_recordingsNWBFile.identifierNWBFile.imaging_planesNWBFile.institutionNWBFile.intervalsNWBFile.intracellular_recordingsNWBFile.invalid_timesNWBFile.keywordsNWBFile.labNWBFile.lab_meta_dataNWBFile.namespaceNWBFile.neurodata_typeNWBFile.notesNWBFile.ogen_sitesNWBFile.pharmacologyNWBFile.processingNWBFile.protocolNWBFile.related_publicationsNWBFile.scratchNWBFile.session_descriptionNWBFile.session_idNWBFile.session_start_timeNWBFile.slicesNWBFile.source_scriptNWBFile.source_script_file_nameNWBFile.stimulusNWBFile.stimulus_notesNWBFile.stimulus_templateNWBFile.subjectNWBFile.surgeryNWBFile.sweep_tableNWBFile.timestamps_reference_timeNWBFile.trialsNWBFile.unitsNWBFile.virusNWBFile.was_generated_by
TrialTableInvalidTimesTableElectrodeTable
- pynwb.icephys module
ensure_unitIntracellularElectrodeIntracellularElectrode.cell_idIntracellularElectrode.descriptionIntracellularElectrode.deviceIntracellularElectrode.filteringIntracellularElectrode.initial_access_resistanceIntracellularElectrode.locationIntracellularElectrode.namespaceIntracellularElectrode.neurodata_typeIntracellularElectrode.resistanceIntracellularElectrode.sealIntracellularElectrode.slice
PatchClampSeriesCurrentClampSeriesIZeroClampSeriesCurrentClampStimulusSeriesVoltageClampSeriesVoltageClampSeries.capacitance_fastVoltageClampSeries.capacitance_slowVoltageClampSeries.resistance_comp_bandwidthVoltageClampSeries.resistance_comp_correctionVoltageClampSeries.resistance_comp_predictionVoltageClampSeries.whole_cell_capacitance_compVoltageClampSeries.whole_cell_series_resistance_compVoltageClampSeries.namespaceVoltageClampSeries.neurodata_type
VoltageClampStimulusSeriesSweepTableIntracellularElectrodesTableIntracellularStimuliTableIntracellularResponsesTableIntracellularRecordingsTableSimultaneousRecordingsTableSequentialRecordingsTableRepetitionsTableExperimentalConditionsTable
- pynwb.image module
- pynwb.misc module
- pynwb.ogen module
- pynwb.ophys module
OpticalChannelImagingPlaneImagingPlane.conversionImagingPlane.descriptionImagingPlane.deviceImagingPlane.excitation_lambdaImagingPlane.grid_spacingImagingPlane.grid_spacing_unitImagingPlane.imaging_rateImagingPlane.indicatorImagingPlane.locationImagingPlane.manifoldImagingPlane.namespaceImagingPlane.neurodata_typeImagingPlane.optical_channelImagingPlane.origin_coordsImagingPlane.origin_coords_unitImagingPlane.reference_frameImagingPlane.unit
OnePhotonSeriesTwoPhotonSeriesCorrectedImageStackMotionCorrectionPlaneSegmentationImageSegmentationRoiResponseSeriesDfOverFFluorescence
- pynwb.resources module
- pynwb.spec module
- pynwb.validation module
- pynwb.validation_cli module
Module contents
This package will contain functions, classes, and objects for reading and writing data in NWB format
- pynwb.load_type_config(config_path, type_map=None)[source]
This method will either load the default config or the config provided by the path.
- pynwb.unload_type_config(type_map=None)[source]
Remove validation.
- Parameters:
type_map (
TypeMap) – The TypeMap.
- pynwb.get_type_map(extensions=None, copy=True)[source]
- Get the TypeMap for the given extensions. If no extensions are provided,
return the TypeMap for the core namespace
- Parameters:
- Returns:
TypeMap loaded for the given extension or NWB core namespace
- Return type:
- pynwb.get_manager(extensions=None, copy=True)[source]
- Get a BuildManager to use for I/O using the given extensions. If no extensions are provided,
return a BuildManager that uses the core namespace
- Parameters:
- Returns:
the namespaces loaded from the given file
- Return type:
- pynwb.register_class(neurodata_type, namespace, container_cls=None)[source]
- Register an NWBContainer class to use for reading and writing a neurodata_type from a specification
If container_cls is not specified, returns a decorator for registering an NWBContainer subclass as the class for neurodata_type in namespace.
- pynwb.get_nwbfile_version(h5py_file)[source]
Get the NWB version of the file if it is an NWB file.
- Returns:
Tuple consisting of: 1) the original version string as stored in the file and 2) a tuple with the parsed components of the version string, consisting of integers and strings, e.g., (2, 5, 1, beta). (None, None) will be returned if the file is not a valid NWB file or the nwb_version is missing, e.g., in the case when no data has been written to the file yet.
- Parameters:
h5py_file (
File) – An NWB file
- pynwb.register_map(container_cls, mapper_cls=None)[source]
- Register an ObjectMapper to use for a Container class type
If mapper_cls is not specified, returns a decorator for registering an ObjectMapper class as the mapper for container_cls. If mapper_cls is specified, register the class as the mapper for container_cls
- pynwb.get_class(neurodata_type, namespace)[source]
- Parse the YAML file for a given neurodata_type that is a subclass of NWBContainer and automatically generate its
python API. This will work for most containers, but is known to not work for descendants of MultiContainerInterface and DynamicTable, so these must be defined manually (for now). get_class infers the API mapping directly from the specification. If you want to define a custom mapping, you should not use this function and you should define the class manually.
Examples:
Generating and registering an extension is as simple as:
MyClass = get_class('MyClass', 'ndx-my-extension')
get_class defines only the __init__ for the class. In cases where you want to provide additional methods for querying, plotting, etc. you can still use get_class and attach methods to the class after-the-fact, e.g.:
def get_sum(self, a, b): return self.feat1 + self.feat2 MyClass.get_sum = get_sum
- class pynwb.NWBHDF5IO(path=None, mode='r', load_namespaces=True, manager=None, extensions=None, file=None, comm=None, driver=None, aws_region=None, herd_path=None)[source]
Bases:
HDF5IO- Parameters:
mode (
str) – the mode to open the HDF5 file with, one of (“w”, “r”, “r+”, “a”, “w-”, “x”)load_namespaces (
bool) – whether or not to load cached namespaces from given path - not applicable in write mode or when manager is not None or when extensions is not Nonemanager (
BuildManager) – the BuildManager to use for I/Oextensions (
strorTypeMaporlist) – a path to a namespace, a TypeMap, or a list consisting paths to namespaces and TypeMapsfile (
FileorS3FileorRemFile) – a pre-existing h5py.File, S3File, or RemFile objectcomm (
Intracomm) – the MPI communicator to use for parallel I/Odriver (
str) – driver for h5py to use when opening HDF5 fileaws_region (
str) – If driver is ros3, then specify the aws region of the url.herd_path (
str) – The path to read/write the HERD file
- property nwb_version
Get the version of the NWB file opened via this NWBHDF5IO object.
- Returns:
Tuple consisting of: 1) the original version string as stored in the file and 2) a tuple with the parsed components of the version string, consisting of integers and strings, e.g., (2, 5, 1, beta). (None, None) will be returned if the nwb_version is missing, e.g., in the case when no data has been written to the file yet.
- read(skip_version_check=False)[source]
Read the NWB file from the IO source.
- raises TypeError:
If the NWB file version is missing or not supported
- return:
NWBFile container
- Parameters:
skip_version_check (
bool) – skip checking of NWB version
- export(src_io, nwbfile=None, write_args=None, cache_spec=True)[source]
Export an NWB file to a new NWB file using the HDF5 backend.
If
nwbfileis provided, then the build manager ofsrc_iois used to build the container, and the resulting builder will be exported to the new backend. So ifnwbfileis provided,src_iomust have a non-None manager property. Ifnwbfileis None, then the contents ofsrc_iowill be read and exported to the new backend.Arguments can be passed in for the
write_buildermethod usingwrite_args. Some arguments may not be supported during export.{'link_data': False}can be used to copy any datasets linked to from the original file instead of creating a new link to those datasets in the exported file.The exported file will not contain any links to the original file. All links, internal and external, will be preserved in the exported file. All references will also be preserved in the exported file.
The exported file will use the latest schema version supported by the version of PyNWB used. For example, if the input file uses the NWB schema version 2.1 and the latest schema version supported by PyNWB is 2.3, then the exported file will use the 2.3 NWB schema.
Example usage:
with NWBHDF5IO(self.read_path, mode='r') as read_io: nwbfile = read_io.read() # ... # modify nwbfile nwbfile.set_modified() # this may be necessary if the modifications are changes to attributes with NWBHDF5IO(self.export_path, mode='w') as export_io: export_io.export(src_io=read_io, nwbfile=nwbfile)
See Exporting NWB files and Adding/Removing Containers from an NWB File for more information and examples.
- Parameters:
src_io (
HDMFIO) – the HDMFIO object (such as NWBHDF5IO) that was used to read the data to exportnwbfile (
NWBFile) – the NWBFile object to export. If None, then the entire contents of src_io will be exportedwrite_args (
dict) – arguments to pass towrite_buildercache_spec (
bool) – whether to cache the specification to file
- pynwb.read_nwb(path)[source]
Read an NWB file from a local path.
High-level interface for reading NWB files. Automatically handles both HDF5 and Zarr formats. For advanced use cases (parallel I/O, custom namespaces), use NWBHDF5IO or NWBZarrIO.
- See also
- Notes
- This function uses the following defaults:
Always opens in read-only mode
Automatically loads namespaces
Reads any backend (e.g. HDF5 or Zarr) if there is an IO class available.
- Advanced features requiring direct use of IO classes (e.g. NWBHDF5IO NWBZarrIO) include:
Streaming data from s3
Custom namespace extensions
Parallel I/O with MPI
Custom build managers
Write or append modes
Pre-opened HDF5 file objects or Zarr stores
Remote file access configuration
Example usage reading a local NWB file:
from pynwb import read_nwb nwbfile = read_nwb("path/to/file.nwb")
- Returns:
pynwb.NWBFile The loaded NWB file object.