Skip to content
Merged

Caro #60

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ stimuli/strange_stories/clips
stimuli/strange_stories/orig
stimuli/liking/clips

.idea/

659 changes: 524 additions & 135 deletions MultiTaskBattery/task_blocks.py

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions MultiTaskBattery/task_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1861,3 +1861,160 @@ def make_task_file(self,

return trial_info


class FingerRhythmic(TaskFile):
def __init__(self, const):
super().__init__(const)
self.name = 'finger_rhythmic'

def make_task_file(self,
hand='right',
responses=[1],
run_number= None,
task_dur = 70,
trial_dur=35, # 2 sec trial start text, 27.95 sec tone train, ~5 sec buffer
iti_dur=0,
file_name=None):

# count number of trials
n_trials = int(np.floor(task_dur / (trial_dur + iti_dur)))
trial_info = []
t = 0

for n in range(n_trials):
trial = {}
trial['key_one'] = responses[0]
trial['trial_num'] = n
trial['hand'] = hand
trial['trial_dur'] = trial_dur
trial['iti_dur'] = iti_dur
trial['stim'] = 'generated'
trial['display_trial_feedback'] = False
trial['start_time'] = t
trial['end_time'] = t + trial_dur + iti_dur
trial_info.append(trial)
# Update for next trial:
t = trial['end_time']

trial_info = pd.DataFrame(trial_info)
if file_name is not None:
ut.dircheck(self.task_dir / self.name)
trial_info.to_csv(self.task_dir / self.name / file_name, sep='\t', index=False)

return trial_info

class TimePerception(TaskFile):
def __init__(self, const):
super().__init__(const)
self.name = 'time_perception' # folder: stimuli/perception/, tasks/perception/

def make_task_file(self,
modality='time', # 'time' or 'volume'
responses=[1, 2], # code 1 = left option, 2 = right option
n_trials= 30, # must be even
trial_dur=4, # tone + question window duration
iti_dur=1.0,
question_dur=2.0,
display_feedback= True,
run_number=None,
file_name=None,
**unused):

# sides per modality
if modality == 'time':
left_label, right_label = 'shorter', 'longer'
elif modality == 'volume':
left_label, right_label = 'quieter', 'louder'

sides = [left_label] * (n_trials // 2) + [right_label] * (n_trials // 2)
np.random.default_rng(run_number).shuffle(sides)

rows, t = [], 0.0
for i, side in enumerate(sides):
rows.append(dict(
trial_num=i,
modality=modality, # drives Task branching
side=side, # shorter/longer or softer/louder
key_one=int(responses[0]), # instruction mapping only
key_two=int(responses[1]),
trial_type=1 if side in (left_label,) else 2, # correct code
question_dur=float(question_dur),
trial_dur=float(trial_dur),
iti_dur=float(iti_dur),
display_trial_feedback= display_feedback,

# runtime logs (filled in Task)
comparison_ms=np.nan,
comparison_dba=np.nan,

start_time=float(t),
end_time=float(t + trial_dur + iti_dur),
))
t = rows[-1]['end_time']

df = pd.DataFrame(rows)
if file_name:
ut.dircheck(self.task_dir / self.name)
df.to_csv(self.task_dir / self.name / file_name, sep='\t', index=False)
return df

class SensMotControl(TaskFile):
def __init__(self, const):
super().__init__(const)
self.name = 'sensmot_control'

def make_task_file(self,
hand='right',
responses=[1, 2],
run_number=None,
task_dur=300,
trial_dur=3,
question_dur=2,
iti_dur= 1,
file_name=None,
stim_file = None,
condition=None):

# count number of trials
n_trials = int(np.floor(task_dur / (trial_dur + iti_dur)))
trial_info = []
t = 0

if stim_file:
stim = pd.read_csv(self.stim_dir / self.name / stim_file, sep='\t')
else:
stim = pd.read_csv(self.stim_dir / self.name / f'{self.name}_block1.csv', sep='\t')

if condition:
stim = stim[stim['condition'] == condition]
else:
stim = stim.loc[~stim['condition'].str.contains('practice', na=False)]

start_row = (run_number - 1) * n_trials
end_row = run_number * n_trials - 1
stim = stim.iloc[start_row:end_row + 1].reset_index(drop=True)

for n in range(n_trials):
trial = {}
trial['key_one'] = responses[0]
trial['key_two'] = responses[1]
trial['trial_num'] = n
trial['hand'] = hand
trial['trial_dur'] = trial_dur
trial['question_dur'] = question_dur
trial['iti_dur'] = iti_dur
trial['trial_type'] = stim['corr_resp'][n]
trial['stim'] = stim['color'][n]
trial['condition'] = stim['condition'][n]
trial['display_trial_feedback'] = True
trial['start_time'] = t
trial['end_time'] = t + trial_dur + iti_dur
trial_info.append(trial)

# Update for next trial:
t = trial['end_time']

trial_info = pd.DataFrame(trial_info)
if file_name is not None:
trial_info.to_csv(self.task_dir / self.name / file_name, sep='\t', index=False)
return trial_info
3 changes: 3 additions & 0 deletions MultiTaskBattery/task_table.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ frith_happe FrithHappe triangle frith_happe "video clips of triangle animations,
liking Liking meeting liking "video clips of people interacting, participants must determine if the interaction was positive or negative" "Heerey, E.A. and Gilder, T.S.E. (2019) ‘The subjective value of a smile alters social behaviour’, PLoS ONE, 14(12), pp. 1–19. Available at: https://doi.org/10.1371/journal.pone.0225284." "like,dislike"
pong Pong pong pong pong game NA
affective Affective affective affect 2 choice is the image pleasant or unpleasant NA
finger_rhythmic FingerRhythmic finger_rhythmic fingrhytm Assess the precision of internal timing mechanisms through a rhythmic tapping production task. Participants are instructed to produce a regular series of taps at a prescribed target interval. Ivry, R. B., & Keele, S. W. (1989). Timing Functions of the Cerebellum. Journal of Cognitive Neuroscience, 1(2), 136-152. self-paced tapping
time_perception TimePerception time_perception timeperc Assess the precision of internal timing mechanisms by measuring participants’ perceptual acuity in discriminating short auditory intervals. Participants are presented with sequences of tones and must decide whether a comparison interval is longer or shorter than a standard reference interval. Ivry, R. B., & Keele, S. W. (1989). Timing Functions of the Cerebellum. Journal of Cognitive Neuroscience, 1(2), 136–152. time interval
sensmot_control SensMotControl sensmot_control sensmotcontrol Assess basic sensorimotor control. Measure reaction time and response accuracy to evaluate low-level perceptual and motor processing. Part 1 is a Go/No-Go. Part 2 is a 2AFC : Koechlin, E., & Summerfield, C. (2007). An information theoretical approach to prefrontal executive function. Trends in cognitive sciences, 11(6), 229-235.Koechlin 2007 Go/No-Go 2AFC.
Loading