Hello,
I am trying to code a luminance threshold detection experiment. In the code below, for some reason, it does not give me the luminance level at the time of the keypress. Furthermore, it won’t even execute the print statements that give information about the threshold after the keypress (i.e. threshold=img.contrast
print(‘th’,threshold)). Can anyone help me understand why? How can I fix this issue?
The code can be found below:
if dim==‘yes’:
if np.all(img.pos == (7.5, 7.5)):
core.wait(dimming_onset)
staircase_clock=core.Clock()
for i in range(6):
times+=1
img.contrast-=increment
print(‘img.contrast:’,img.contrast)
img.draw()
win.flip()
keys = event.getKeys(keyList=[ ‘3’])
if ‘3’ in keys:
resp=1
seq_n_Down+=1
seq_n_Up-=1
keyResp = ‘3’
react = staircase_clock.getTime()
threshold=img.contrast
print(‘th’,threshold)
core.wait(after_dim_duration)
keys = event.getKeys(keyList=[ '3'])
if keys:
print('times',times)
resp=1
seq_n_Down+=1
seq_n_Up-=1
keyResp = '3'
react = staircase_clock.getTime()
threshold=img.contrast
print('th',threshold)
trial_data.append({'Participant Num': participant_no, 'Date': date, 'Trial_Type': trial_type, 'threshold':threshold,
'Block Name': block_name, 'Response': resp, 'RT': react,'keyPressed':keyResp,'step_Size':seq_step_size,'stepType':'lin',
'dimmed_to':seq_intensity,'min_Val':min_val,'max_Val':max_val,'n_Down':seq_n_Down,'n_Up':seq_n_Up,'dim':'yes','trial_dur':trial_clock.getTime()})