pynwb.io.utils module
- pynwb.io.utils.get_nwb_version(builder: Builder, include_prerelease=False) Tuple[int, ...][source]
Get the version of the NWB file from the root of the given builder, as a tuple.
If the “nwb_version” attribute on the root builder equals “2.5.1”, then (2, 5, 1) is returned. If the “nwb_version” attribute on the root builder equals “2.5.1-alpha” and include_prerelease=False, then (2, 5, 1) is returned. If the “nwb_version” attribute on the root builder equals “2.5.1-alpha” and include_prerelease=True, then (2, 5, 1, “alpha”) is returned.
If the “nwb_version” attribute == “2.0b” (the only deviation from semantic versioning in the 2.x series), then if include_prerelease=True, (2, 0, 0, “b”) is returned; else, (2, 0, 0) is returned.
- Parameters:
- Returns:
The version of the NWB file, as a tuple.
- Return type:
- Raises:
ValueError – if the ‘nwb_version’ attribute is missing from the root of the NWB file.
- pynwb.io.utils.parse_date(datestr, field_name)[source]
Parse an ISO 8601 date string read from a file into a
datetime.datestrmay bestror UTF-8bytes. Scalar datasets are decoded on read, while elements of an array-valued dataset (file_create_date) carry whichever the file stores: a variable-lengthstrdataset is decoded, a variable-lengthbytesone is not.dateutilhandles the common formats.datetime.fromisoformatcovers UTC offsets that carry a seconds component (e.g.-05:50:36), which some writers emit. A value that neither accepts raises aValueErrornaming the field and the offending string.