From 88f3e90448a7f3a509f29085f432ef4b12a8dabc Mon Sep 17 00:00:00 2001 From: CodyCBakerPhD Date: Wed, 7 Aug 2024 13:36:16 -0400 Subject: [PATCH] add direct fix internal to GUIDE --- .../manageNeuroconv/manage_neuroconv.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 7fbe53a53..f0c0de716 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -13,6 +13,8 @@ from shutil import copytree, rmtree from typing import Any, Dict, List, Optional, Union +import signature +from pynwb import NWBFile from tqdm_publisher import TQDMProgressHandler from .info import ( @@ -364,6 +366,28 @@ class CustomNWBConverter(NWBConverter): def temporally_align_data_interfaces(self): set_interface_alignment(self, alignment_info=alignment_info) + # From previous issue regarding SpikeGLX not generating previews of correct size + def add_to_nwbfile(self, nwbfile: NWBFile, metadata, conversion_options: Optional[dict] = None) -> None: + conversion_options = conversion_options or dict() + for interface_key, data_interface in self.data_interface_objects.items(): + if isinstance(data_interface, NWBConverter): + subconverter_kwargs = dict(nwbfile=nwbfile, metadata=metadata) + + # Certain subconverters fully expose control over their interfaces conversion options + # (such as iterator options, including progress bar details) + subconverter_keyword_arguments = list(signature(data_interface.add_to_nwbfile).parameters.keys()) + if "conversion_options" in subconverter_keyword_arguments: + subconverter_kwargs["conversion_options"] = conversion_options.get(interface_key, None) + # Others do not, and instead expose simplified global keywords similar to a classic interface + else: + subconverter_kwargs.update(conversion_options.get(interface_key, dict())) + + data_interface.add_to_nwbfile(**subconverter_kwargs) + else: + data_interface.add_to_nwbfile( + nwbfile=nwbfile, metadata=metadata, **conversion_options.get(interface_key, dict()) + ) + return CustomNWBConverter