Skip to content

Commit 1143eda

Browse files
authored
Skip empty timestamp objs (#1347)
* Skip empty timestamp objs * Update changelog * Use get_timestamps method * Change empty check to method for either np array or HDMF5 dataset
1 parent 0874912 commit 1143eda

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ ImportedLFP().drop()
9898
- Common
9999
- Default `AnalysisNwbfile.create` permissions are now 777 #1226
100100
- Make `Nwbfile.fetch_nwb` functional # 1256
101-
- Calculate mode of timestep size in log scale when estimating sampling rate #1270
101+
- Calculate mode of timestep size in log scale when estimating sampling rate
102+
#1270
102103
- Ingest all `ImageSeries` objects in nwb file to `VideoFile` #1278
103104
- Allow ingestion of multi-row task epoch tables #1278
104105
- Add `SensorData` to `populate_all_common` #1281
@@ -107,8 +108,9 @@ ImportedLFP().drop()
107108
- `IntervalList.fetch_interval` now returns `Interval` object #1293
108109
- Correct name parsing in Session.Experimenter insertion #1306
109110
- Allow insert with dio events but no e-series data #1318
110-
- Prompt user to verify compatibility between new insert and existing
111-
table entries # 1318
111+
- Prompt user to verify compatibility between new insert and existing table
112+
entries # 1318
113+
- Skip empty timeseries ingestion (`PositionSource`, `DioEvents`) #1347
112114
- Position
113115
- Allow population of missing `PositionIntervalMap` entries during population
114116
of `DLCPoseEstimation` #1208
@@ -129,14 +131,14 @@ ImportedLFP().drop()
129131
- Fix type compatibility of `time_slice` in
130132
`SortedSpikesGroup.fetch_spike_data` #1261
131133
- Update transaction and parallel make settings for `v0` and `v1`
132-
`SpikeSorting` tables #1270
134+
`SpikeSorting` tables #1270
133135
- Disable make transactionsfor `CuratedSpikeSorting` #1288
134136
- Refactor `SpikeSortingOutput.get_restricted_merge_ids` #1304
135137
- Add burst merge curation #1209
136138
- Reconcile spikeinterface value for `channel_id` when `channel_name` column
137-
present in nwb file electrodes table #1310, #1334
139+
present in nwb file electrodes table #1310, #1334
138140
- Ensure matching order of returned merge_ids and nwb files in
139-
`SortedSpikesGroup.fetch_spike_data` #1320
141+
`SortedSpikesGroup.fetch_spike_data` #1320
140142
- Behavior
141143
- Implement pipeline for keypoint-moseq extraction of behavior syllables #1056
142144
- LFP
@@ -148,6 +150,7 @@ ImportedLFP().drop()
148150
- Updating the LFPBandSelection logic with comprehensive validation and batch
149151
insertion for electrodes and references. #1280
150152
- Implement `ImportedLFP.make()` for ingestion from nwb files #1278, #1302
153+
- Skip empty timeseries ingestion for `ImportedLFP` #1347
151154

152155
## [0.5.4] (December 20, 2024)
153156

src/spyglass/common/common_behav.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def insert_from_nwbfile(cls, nwb_file_name, skip_duplicates=False) -> None:
8282
src_key = dict(**sess_key, source="imported", import_file_name="")
8383

8484
if all_pos is None:
85+
logger.info(f"No position data found in {nwb_file_name}. Skipping.")
8586
return
8687

8788
sources = []

src/spyglass/common/common_dio.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def make(self, key):
4545
return # See #849
4646

4747
# Times for these events correspond to the valid times for the raw data
48-
# If no raw data found, create a default interval list named "dio data valid times"
48+
# If no raw data found, create a default interval list named
49+
# "dio data valid times"
4950
if raw_query := (Raw() & {"nwb_file_name": nwb_file_name}):
5051
key["interval_list_name"] = (raw_query).fetch1("interval_list_name")
5152
else:
@@ -54,12 +55,17 @@ def make(self, key):
5455
dio_inserts = []
5556
time_range_list = []
5657
for event_series in behav_events.time_series.values():
58+
timestamps = event_series.get_timestamps()
59+
if len(timestamps) == 0: # Can be either np array or HDMF5 dataset
60+
logger.warning(
61+
f"No timestamps found for DIO event {event_series.name} "
62+
+ f"in {nwb_file_name}. Skipping."
63+
)
64+
continue
5765
key["dio_event_name"] = event_series.name
5866
key["dio_object_id"] = event_series.object_id
5967
dio_inserts.append(key.copy())
60-
time_range_list.extend(
61-
[event_series.timestamps[0], event_series.timestamps[-1]]
62-
)
68+
time_range_list.extend([timestamps[0], timestamps[-1]])
6369

6470
if key["interval_list_name"] == "dio data valid times":
6571
# insert a default interval list for DIO events if no raw data

src/spyglass/lfp/lfp_imported.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ def make(self, key):
5858
for i, es_object in enumerate(lfp_es_objects):
5959
if len(self & {"lfp_object_id": es_object.object_id}) > 0:
6060
logger.warning(
61-
f"Skipping {es_object.object_id} because it already exists in ImportedLFP."
61+
f"Skipping {es_object.object_id} because it already exists "
62+
+ "in ImportedLFP."
63+
)
64+
continue
65+
timestamps = es_object.get_timestamps()
66+
if len(timestamps) == 0:
67+
logger.warning(
68+
f"Skipping lfp without timestamps: {es_object.object_id}"
6269
)
6370
continue
6471
electrodes_df = es_object.electrodes.to_dataframe()
6572
electrode_ids = electrodes_df.index.values
6673

67-
# check if existing electrode group for this set of electrodes exists
74+
# check if existing group for this set of electrodes exists
6875
session_key = {
6976
"nwb_file_name": nwb_file_name,
7077
}
@@ -82,17 +89,14 @@ def make(self, key):
8289

8390
# estimate the sampling rate or read in if available
8491
sampling_rate = es_object.rate or estimate_sampling_rate(
85-
es_object.timestamps[: int(1e6)]
92+
timestamps[: int(1e6)]
8693
)
8794

8895
# create a new interval list for the valid times
8996
interval_key = {
9097
"nwb_file_name": nwb_file_name,
9198
"interval_list_name": f"imported lfp {i} valid times",
92-
"valid_times": get_valid_intervals(
93-
es_object.timestamps,
94-
sampling_rate,
95-
),
99+
"valid_times": get_valid_intervals(timestamps, sampling_rate),
96100
"pipeline": "imported_lfp",
97101
}
98102
IntervalList().insert1(interval_key)

0 commit comments

Comments
 (0)