From 7eb0f4f49017b290e7c467ec0db7718cab45def9 Mon Sep 17 00:00:00 2001 From: Nicholas Watters Date: Tue, 19 Dec 2023 22:30:47 -0500 Subject: [PATCH] Update timezone info and minor cleanups. --- .../watters/main_convert_session.py | 10 ++++---- .../watters/recording_interface.py | 23 ++++++------------- .../watters/timeseries_interface.py | 16 +++++++++---- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/jazayeri_lab_to_nwb/watters/main_convert_session.py b/src/jazayeri_lab_to_nwb/watters/main_convert_session.py index 1640828..ee629f3 100644 --- a/src/jazayeri_lab_to_nwb/watters/main_convert_session.py +++ b/src/jazayeri_lab_to_nwb/watters/main_convert_session.py @@ -295,12 +295,10 @@ def session_to_nwb( # Check if session_start_time was found/set if "session_start_time" not in metadata["NWBFile"]: - try: - date = datetime.datetime.strptime(session, "%Y-%m-%d") - date = date.replace(tzinfo=ZoneInfo("US/Eastern")) - except: - raise ValueError("Session start time was not auto-detected. Please provide it " "in `metadata.yaml`") - metadata["NWBFile"]["session_start_time"] = date + raise ValueError("Session start time was not auto-detected. Please provide it " "in `metadata.yaml`") + session_start_time = metadata["NWBFile"]["session_start_time"] + metadata["NWBFile"]["session_start_time"] = session_start_time.replace( + tzinfo=ZoneInfo("US/Eastern")) # Run conversion logging.info("Running processed conversion") diff --git a/src/jazayeri_lab_to_nwb/watters/recording_interface.py b/src/jazayeri_lab_to_nwb/watters/recording_interface.py index 216bfaf..89523d2 100644 --- a/src/jazayeri_lab_to_nwb/watters/recording_interface.py +++ b/src/jazayeri_lab_to_nwb/watters/recording_interface.py @@ -46,23 +46,14 @@ def __init__( self.probe_name = probe_name # add probe information - probe_metadata = None - if probe_metadata_file is not None and probe_key is not None: - with open(probe_metadata_file, "r") as f: - all_probe_metadata = json.load(f) - for entry in all_probe_metadata: - if entry["label"] == probe_key: - probe_metadata = entry + with open(probe_metadata_file, "r") as f: + all_probe_metadata = json.load(f) + for entry in all_probe_metadata: + if entry["label"] == probe_key: + probe_metadata = entry - if probe_metadata is not None and "electrodes_locations" in probe_metadata: - # Grab electrode position from metadata - locations_array = np.array(probe_metadata["electrodes_locations"]) - ndim = locations_array.shape[1] - probe = probeinterface.Probe(ndim=ndim) - probeinterface.set_contacts(locations_array) - else: - # Generate V-probe geometry: 64 channels arranged vertically with 50 um spacing - probe = probeinterface.generate_linear_probe(num_elec=channel_count, ypitch=50) + # Generate V-probe geometry: 64 channels arranged vertically with 50 um spacing + probe = probeinterface.generate_linear_probe(num_elec=channel_count, ypitch=50) probe.set_device_channel_indices(np.arange(channel_count)) probe.name = probe_name diff --git a/src/jazayeri_lab_to_nwb/watters/timeseries_interface.py b/src/jazayeri_lab_to_nwb/watters/timeseries_interface.py index 20e1a57..ca0f83c 100644 --- a/src/jazayeri_lab_to_nwb/watters/timeseries_interface.py +++ b/src/jazayeri_lab_to_nwb/watters/timeseries_interface.py @@ -71,6 +71,8 @@ def __init__(self, folder_path: FolderPathType): self._eye_pos = np.stack([eye_h_values, eye_v_values], axis=1) def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): + del metadata + # Make SpatialSeries eye_position = SpatialSeries( name="eye_position", @@ -83,7 +85,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): ) # Get processing module - module_description = "Contains behavioral data from experiment." + module_description = "Contains behavior, audio, and reward data from experiment." processing_module = get_module(nwbfile=nwbfile, name="behavior", description=module_description) # Add data to module @@ -107,6 +109,8 @@ def __init__(self, folder_path: FolderPathType): self._pupil_size = np.array(pupil_size_data["values"]) def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): + del metadata + # Make TimeSeries pupil_size = TimeSeries( name="pupil_size", @@ -118,7 +122,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): ) # Get processing module - module_description = "Contains behavioral data from experiment." + module_description = "Contains behavior, audio, and reward data from experiment." processing_module = get_module(nwbfile=nwbfile, name="behavior", description=module_description) # Add data to module @@ -142,6 +146,8 @@ def __init__(self, folder_path: FolderPathType): self._reward_line = reward_line_data["values"] def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): + del metadata + # Make LabeledEvents reward_line = LabeledEvents( name="reward_line", @@ -152,7 +158,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): ) # Get processing module - module_description = "Contains audio and reward data from experiment." + module_description = "Contains behavior, audio, and reward data from experiment." processing_module = get_module(nwbfile=nwbfile, name="behavior", description=module_description) # Add data to module @@ -181,6 +187,8 @@ def __init__(self, folder_path: FolderPathType): self._sound_codes = [sound_to_code[x] for x in audio] def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): + del metadata + # Make LabeledEvents audio = LabeledEvents( name="audio", @@ -191,7 +199,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict): ) # Get processing module - module_description = "Contains audio and reward data from experiment." + module_description = "Contains behavior, audio, and reward data from experiment." processing_module = get_module(nwbfile=nwbfile, name="behavior", description=module_description) # Add data to module