Skip to content

Commit

Permalink
Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Feb 6, 2024
1 parent 7989feb commit f0294d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [
"npc-sync>=0.1.3",
"npc-session>=0.1.33",
]
version = "0.1.2"
version = "0.1.3"
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
Expand Down
16 changes: 11 additions & 5 deletions src/npc_stim/stim.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def safe_index(
return result.item()
return result


def validate(
*stim_paths: StimPathOrDataset,
sync: npc_sync.SyncPathOrDataset,
Expand All @@ -408,25 +409,29 @@ def validate(
Check that the stim files can be opened and have valid data that corresponds
to the sync file. Raises an AssertionError if any of the stim files fail to
open or can't be identified on sync.
- validation of other properties (trial starts, display times, etc.) is
specific to the type of stim and file format
>>> good_stim_1 = 's3://aind-ephys-data/ecephys_670248_2023-08-02_11-30-53/behavior/Spontaneous_670248_20230802_114611.hdf5'
>>> good_stim_2 = 's3://aind-ephys-data/ecephys_670248_2023-08-02_11-30-53/behavior/SpontaneousRewards_670248_20230802_130736.hdf5'
>>> sync = 's3://aind-ephys-data/ecephys_670248_2023-08-02_11-30-53/behavior/20230802T113053.h5'
>>> validate(good_stim_1, good_stim_2, sync=sync)
# stim file that doesn't open or has bad data:
# stim file that doesn't open or has bad data:
>>> bad_stim = 's3://aind-ephys-data/ecephys_670248_2023-08-02_11-30-53/behavior/DynamicRouting1_670248_20230802_120703.hdf5'
>>> validate(bad_stim, sync=sync)
Traceback (most recent call last):
...
AssertionError: Failed to validate stim_path = 's3://aind-ephys-data/ecephys_670248_2023-08-02_11-30-53/behavior/DynamicRouting1_670248_20230802_120703.hdf5'
"""

def validate_single_stim(stim_path, sync=sync) -> None:
for v in get_stim_frame_times(stim_path, sync=sync).values(): # should be only one entry
for v in get_stim_frame_times(
stim_path, sync=sync
).values(): # should be only one entry
assert_stim_times(v)

logger.info(f"Validating {len(stim_paths)} stim files with sync data")
for stim_path in stim_paths:
logger.debug(f"Validating {stim_path = }")
Expand All @@ -436,6 +441,7 @@ def validate_single_stim(stim_path, sync=sync) -> None:
raise AssertionError(f"Failed to validate {stim_path = }") from exc
logger.info(f"Validated {stim_path = }")


if __name__ == "__main__":
from npc_stim import testmod

Expand Down

0 comments on commit f0294d4

Please sign in to comment.