Skip to content

Commit

Permalink
BUG: update situation column and append to source_beh
Browse files Browse the repository at this point in the history
  • Loading branch information
jungheejung committed Aug 26, 2024
1 parent b99ff2a commit c7344ce
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions spacetop_prep/events/bidsify_narratives_ENH.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,24 @@ def narrative_format2bids(sub, ses, run, taskname, beh_inputdir, bids_dir):
trial_num = len(source_beh)
situation = [None] * trial_num
context = [None] * trial_num

r = int(run.split('-')[1]) - 1 # Adjust the run number to be zero-based
for t in range(trial_num): # each trial

# Situation and context
r = int(run.split('-')[1]) - 1 # Adjust the run number to be zero-based

# Situation and context
if t < 9:
situation_chunk = DesignTable['Situation'][DesignTable['Narrative'] == narratives[r][t % 2]]
context_chunk = DesignTable['Context'][DesignTable['Narrative'] == narratives[r][t % 2]]
situation_chunk = DesignTable.Situation[DesignTable.Narrative == narratives[r][t % 2]]
situation[t] = situation_chunk.iloc[t]
context_chunk = DesignTable.Context[DesignTable.Narrative == narratives[r][t % 2]]
context[t] = context_chunk.iloc[t]
else:
situation_chunk = DesignTable['Situation'][DesignTable['Narrative'] == narratives[r][1 - (t % 2)]]
context_chunk = DesignTable['Context'][DesignTable['Narrative'] == narratives[r][1 - (t % 2)]]

situation[t] = situation_chunk.iloc[t % len(situation_chunk)]
context[t] = context_chunk.iloc[t % len(context_chunk)]

situation_chunk = DesignTable.Situation[DesignTable.Narrative == narratives[r][1 - (t % 2)]]
situation[t] = situation_chunk.iloc[t - 9]
context_chunk = DesignTable.Context[DesignTable.Narrative == narratives[r][1 - (t % 2)]]
context[t] = context_chunk.iloc[t - 9]
source_beh['situation'] = situation
source_beh['context'] = context

for t in range(trial_num): # each trial
# Event 1. narrative presentation
onset = source_beh.loc[t, 'event02_administer_onset'] - t_run_start
duration = source_beh.loc[t, 'event03_feel_displayonset'] - source_beh.loc[t, 'event02_administer_onset']
Expand Down

0 comments on commit c7344ce

Please sign in to comment.