Skip to content

Commit

Permalink
fix state
Browse files Browse the repository at this point in the history
  • Loading branch information
weiglszonja committed Oct 9, 2024
1 parent 97b0d50 commit c628ade
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,24 @@ def create_states_table(
states_table = StatesTable(description=states_table_metadata["description"], state_types_table=state_types)

trials_data = self._bpod_struct["RawEvents"]["Trial"]
for state_name in trials_data[0]["States"]:
num_trials = self._bpod_struct["nTrials"]

# make it iterable if only one trial
if num_trials == 1:
trials_data = [trials_data]
trial_start_times = [trial_start_times]

unique_state_names = set()
for trial_index in range(num_trials):
unique_state_names.update(trials_data[trial_index]["States"])
for state_name in unique_state_names:
if state_name not in state_types_metadata:
raise ValueError(
f"State '{state_name}' not found in metadata. Please provide in metadata['Behavior']['StateTypesTable']."
f"State '{state_name}' not in metadata. State type should be defined in metadata['Behavior']['StateTypesTable']."
)

state_type = state_types_metadata[state_name]["name"]
state_types.add_row(
state_name=state_types_metadata[state_name]["name"],
state_name=state_type,
check_ragged=False,
)

Expand Down

0 comments on commit c628ade

Please sign in to comment.