Skip to content

Commit

Permalink
Update timezone info and minor cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Watters authored and Nicholas Watters committed Dec 20, 2023
1 parent 3245d46 commit 7eb0f4f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
10 changes: 4 additions & 6 deletions src/jazayeri_lab_to_nwb/watters/main_convert_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
23 changes: 7 additions & 16 deletions src/jazayeri_lab_to_nwb/watters/recording_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 12 additions & 4 deletions src/jazayeri_lab_to_nwb/watters/timeseries_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 7eb0f4f

Please sign in to comment.