Skip to content

Commit

Permalink
Add missing typing to NWBConverter backend and backend options (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin authored Dec 19, 2024
1 parent 2084d35 commit 74ca5b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Use pytest format for dandi tests to avoid window permission error on teardown [PR #1151](https://github.com/catalystneuro/neuroconv/pull/1151)
* Added many docstrings for public functions [PR #1063](https://github.com/catalystneuro/neuroconv/pull/1063)
* Clean up with warnings and deprecations in the testing framework [PR #1158](https://github.com/catalystneuro/neuroconv/pull/1158)

* Enhance the typing of the signature on the `NWBConverter` by adding zarr as a literal option on the backend and backend configuration [PR #1160](https://github.com/catalystneuro/neuroconv/pull/1160)

# v0.6.5 (November 1, 2024)

Expand Down
6 changes: 2 additions & 4 deletions docs/conversion_examples_gallery/fiberphotometry/tdt_fp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,13 @@ Convert TDT Fiber Photometry data to NWB using
>>> LOCAL_PATH = Path(".") # Path to neuroconv
>>> editable_metadata_path = LOCAL_PATH / "tests" / "test_on_data" / "ophys" / "fiber_photometry_metadata.yaml"
>>> interface = TDTFiberPhotometryInterface(folder_path=folder_path, verbose=True)
Source data is valid!
>>> interface = TDTFiberPhotometryInterface(folder_path=folder_path, verbose=False)
>>> metadata = interface.get_metadata()
>>> metadata["NWBFile"]["session_start_time"] = datetime.now(tz=ZoneInfo("US/Pacific"))
>>> editable_metadata = load_dict_from_file(editable_metadata_path)
>>> metadata = dict_deep_update(metadata, editable_metadata)
>>> # Choose a path for saving the nwb file and run the conversion
>>> nwbfile_path = LOCAL_PATH / "example_tdtfp.nwb"
>>> nwbfile_path = f"{path_to_save_nwbfile}"
>>> # t1 and t2 are optional arguments to specify the start and end times for the conversion
>>> interface.run_conversion(nwbfile_path=nwbfile_path, metadata=metadata, t1=0.0, t2=1.0)
NWB file saved at example_tdtfp.nwb!
11 changes: 4 additions & 7 deletions src/neuroconv/nwbconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,8 @@ def run_conversion(
nwbfile: Optional[NWBFile] = None,
metadata: Optional[dict] = None,
overwrite: bool = False,
# TODO: when all H5DataIO prewraps are gone, introduce Zarr safely
# backend: Union[Literal["hdf5", "zarr"]],
# backend_configuration: Optional[Union[HDF5BackendConfiguration, ZarrBackendConfiguration]] = None,
backend: Optional[Literal["hdf5"]] = None,
backend_configuration: Optional[HDF5BackendConfiguration] = None,
backend: Optional[Literal["hdf5", "zarr"]] = None,
backend_configuration: Optional[Union[HDF5BackendConfiguration, ZarrBackendConfiguration]] = None,
conversion_options: Optional[dict] = None,
) -> None:
"""
Expand All @@ -226,11 +223,11 @@ def run_conversion(
overwrite : bool, default: False
Whether to overwrite the NWBFile if one exists at the nwbfile_path.
The default is False (append mode).
backend : "hdf5", optional
backend : {"hdf5", "zarr"}, optional
The type of backend to use when writing the file.
If a `backend_configuration` is not specified, the default type will be "hdf5".
If a `backend_configuration` is specified, then the type will be auto-detected.
backend_configuration : HDF5BackendConfiguration, optional
backend_configuration : HDF5BackendConfiguration or ZarrBackendConfiguration, optional
The configuration model to use when configuring the datasets for this backend.
To customize, call the `.get_default_backend_configuration(...)` method, modify the returned
BackendConfiguration object, and pass that instead.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_on_data/ophys/test_miniscope_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def assertNWBFileStructure(self, nwbfile_path: str):
nwbfile = io.read()

self.assertEqual(
nwbfile.session_start_time,
datetime(2021, 10, 7, 15, 3, 28, 635).astimezone(),
nwbfile.session_start_time.replace(tzinfo=None),
datetime(2021, 10, 7, 15, 3, 28, 635),
)

self.assertIn(self.device_name, nwbfile.devices)
Expand Down

0 comments on commit 74ca5b8

Please sign in to comment.