FLICKERING PROBLEM
Good Morning,
I'm Arianna and I'm developing an experiment by using Expyriment and the LEAP motion device. In this study each trial is made up of four stimuli: a forward mask lasting 49 ms, a prime lasting 83 ms, a backward mask lasting 49 ms and a target lasting until response. I manipulated the SOA between the prime and the target: the prime can appear 100 ms before, 50 ms before or 0 ms before the target. When the SOA is 100 everything works, instead when the SOA is either 50 or 0 the result is a flickering stimulation.
Below you can find the lines of the script referred to the chronological presentation of the stimuli:
pic = target
screen_pic = stimuli.BlankScreen()
pic.plot(screen_pic)
screen_pic.preload()
screen_pic_prime = stimuli.BlankScreen()
pic.plot(screen_pic_prime)
stimuli.TextLine(text=str(prime), text_size=46).plot(screen_pic_prime)
screen_pic_prime.preload()
prime_screen = stimuli.TextLine(text=str(prime), text_size=46)
prime_screen.preload()
screen_mask = mask
screen_mask.preload()
screen_pic_mask = stimuli.BlankScreen()
mask.plot(screen_pic_mask)
pic.plot(screen_pic_mask)
screen_pic_mask.preload()
if SOA == 0:
screen_mask.present()
exp.clock.wait(t_mask)
screen_pic_prime.present()
exp.clock.reset_stopwatch() # IMPORTANT: this is now the point in time that your "correctRT" starts counting!
exp.clock.wait(t_prime)
pic.present(clear=True)
mask.present(clear=True)
screen_pic_mask.present()
exp.clock.wait(t_mask)
screen_pic.present() # a problem here is that during all this time, the program doesn't check for keyups
else:
screen_mask.present() # mask appears
exp.clock.wait(t_mask) # for 49 ms
prime_screen.present() # prime appears
if SOA == 50:
exp.clock.wait(SOA) # for 50 ms, that is, the prime needs 33 ms more
screen_pic_prime.present() # target appears
exp.clock.reset_stopwatch()
exp.clock.wait(t_prime - SOA) # for 33ms
pic.present(clear=True)
mask.present(clear=True)
screen_pic_mask.present() # backmask appears (with pic present)
exp.clock.wait(t_mask) # for backmask time = 49 ms
elif SOA == 100:
exp.clock.wait(t_prime) # for 83 ms
screen_mask.present() # backmask appears
exp.clock.wait(SOA - t_prime) # for the rest of the SOA-time (17 ms)
screen_pic_mask.present() # picture appears
exp.clock.reset_stopwatch()
exp.clock.wait(t_mask - (SOA - t_prime)) # for the rest of the mask-time (32ms)
screen_pic.present() # only pic
Waiting for your feedback, I thank you in advance!
Arianna F.
Comments
Dear Arianna,
What is your screen refresh rate? I am asking, because you use timings (49ms) that do not seem to fall at multiples of common refresh rates (e.g. 60Hz, 100Hz, 120Hz).
From what I understand, you script does the following if SOA is 50:
You hence present 6 stimuli in rapid succession, from which two will be so quick (only one frame) that they will not be visible.
Is this what you intend to do?
Florian Krause (Developer)
http://www.expyriment.org
Dear prof. Krause,
thank you for your fast answer and help!
The refresh rate is 60 Hz.
My script doesn't work with both SOA = 50 and SOA = 0
Maybe due to the fact that in those case, with respect to the SOA= 100, the mask should appear in place of the prime on the target (pic).
The target consists of a big picture, the mask and the prime should alternate at the center of it.
As you correctly understood I want the mask to appear in a subliminal way, the prime in a conscious way but impossible to react to and the target until the participant's response.
Given the refresh rate of 60Hz, here is what your script does in case SOA is 50:
Hence, all of these six stimuli are probably not consciously perceived.
Make sure to always use the test suite to check that your computer and graphics card report accurate timings of visual presentations (http://docs.expyriment.org/Testsuite.html).
Florian Krause (Developer)
http://www.expyriment.org
What now I see with SOA= 50 is that when the mask replaces the prime, the result is a flickering stimulation.
If I cut the following lines:
pic.present(clear=True)
mask.present(clear=True)
I see that the prime appears as last event in place of the backward mask.
It is not clear to me what your goal is. I understand that your code apparently does not do what you want it to do, but I don't understand what it is you want it to do.
You first mentioned that each trial consists of 4 stimuli, but you present 6 stimuli in the script.
Given your initial description of what a trial should look like, the code would simply be this:
The manipulation of the SOA between prime and target, however, is not clear to me, since there is another stimulus in between.
Florian Krause (Developer)
http://www.expyriment.org
I understood the point of our misunderstanding: by "stimuli" I meant the single items that make up a trial (mask, prime, mask and target) not the screens displayed. Now I explain you more in detail:
With SOA=50
1° blank screen with mask (NOTE forward mask and backward mask are the same stimulus)
2° after 50 ms on the blank screen the mask disappears and the prime appears for 50 (=SOA)
3° after 50 ms (=SOA) the target appears and the prime remains (on the target) for other 33 ms (83-SOA)
4° after 33 ms while the target is still present, the prime disappears and the mask appears (on the target) again lasting 50 ms
5° after 50 ms the mask disappears and the target keeps on staying on the screen until the response
Prepare the following stimuli before stimulus presentation:
mask = expyriment.stimuli.Picture("...")
prime = expyriment.stimuli.Picture("...")
target = expyriment.stimuli.Picture("...")
As well as:
prime_on_target = target.copy(); prime.plot(prime_on_target)
mask_on_target = target.copy(); mask.plot(mask_on_target)
Then simply do:
Florian Krause (Developer)
http://www.expyriment.org
Thank you for all your clear teachings!
I''ve just implemented the modifications you suggested on my script.
Since the prime is a digit and not a picture, what can I use in place of "plot"?
plot will work with all visual stimuli
Florian Krause (Developer)
http://www.expyriment.org
I receive an error message telling me that "prime" object has no attribute plot
Then
prime
is not of any of the Expyriment (visual) stimulus types.Florian Krause (Developer)
http://www.expyriment.org
"prime" is a digit ranging from 1 to 10
should I use another code (e.g., overlapping)?
I thought prime is a stimulus you want to show on the screen?
Florian Krause (Developer)
http://www.expyriment.org
"#"= forward mask lasting 49 (now 50 ms)
"1" = digit meaning the prime lasting 83 ms
"#" = backward mask lasting 49 (now 50 ms)
picture of two hands = target stimulus on the screen
with SOA = 50 the digit should appear on the blank screen 50 ms before the picture, after 50 ms the target appears and the digit should stay on the picture for other 33 ms before being replaced by the backward mask
Then I don't understand what the problem is.
This should just work:
Florian Krause (Developer)
http://www.expyriment.org
SOA = trial.get_factor("t_SOA")
it keeps on giving me the following error message:
prime.plot(prime_on_pic)
AttributeError: 'int' has no attribute 'plot'"
NOTE I used pic instead of target
Well, yes, of course. An integer is a built in Python data type representing a number, not an Expyriment stimulus.
You first need to create a stimulus. Please see my example above.
Florian Krause (Developer)
http://www.expyriment.org
these lines give me "invalid syntax" error
All of them? That is very strange.
It is in general very difficult to judge errors without seeing the entire script. Could you provide the entire script?
Florian Krause (Developer)
http://www.expyriment.org
yes all of them, I tried to delete each of them and the errors passed to the second line. Now I attach the whole script
I apologize, since I don't menage to attach the file I have to copy and paste the script.
-- coding: cp1252 --
import Leap, cv2, math, ctypes, sys, thread, time, ctypes, os
from expyriment import misc, design, control, stimuli, io
import numpy as np
control.set_develop_mode(False)
design
exp = design.Experiment(name="PostureProduction",
background_colour=misc.constants.C_BLACK,
foreground_colour=misc.constants.C_WHITE)
trials_per_block = 81
Block_Anzahl = 2 #only 1 block. the second block is for the training.
posturetype = "count" #"mont" here for the other version
control.initialize(exp)
block = design.Block(name="Experiment")
for t_SOA in [100, 50, 0]:
for digit in range(1, 10):
trial = design.Trial()
trial.set_factor("digit", digit)
trial.set_factor("t_SOA", t_SOA)
trial.set_factor("fingers", 0)
trial.set_factor("catch", 1)
block.add_trial(trial, copies=1)
for distance in [-2, 0, 2]:
for posturetype in ["count", "count"]:
trial.set_factor("count", posturetype)
exp.add_block(block, copies=Block_Anzahl)
for block in exp.blocks:
block.shuffle_trials()
exp.shuffle_blocks()
exp.data_variable_names = ["block_cnt", "trial_cnt", "t_fixdot", "catch_trial",
"smallhand", "posturetype",
"target", "distance", "prime", "t_SOA",
"first_button_released", "RT_1", "second_button_released", "RT_2", "RT_1_plus_2",
"falsePostures", "FirstFalseRT", "SecondFalseRT", "ThirdFalseRT", "FourthFalseRT",
"LeapRT", "Execution_times",
"First_back_button", "Post_RT_1", "Second_back_button", "Post_RT_2", "Post_RT_1_plus_2",
"LeftHandFingers", "RightHandFingers", "correct"]
ITI = 300
block_cnt = 0
trial_cnt = 0
cnt = 0
t_fixdot = [600, 1200]
t_prime = 83.333333333335
t_mask = 50.000000000001
mouse = io.Mouse(show_cursor=False)
Prepare and preload some stimuli
blankscreen = stimuli.BlankScreen()
blankscreen.preload()
fixdot = stimuli.Dot(radius=5, colour=misc.constants.C_GREEN)
fixdot.preload()
fixdot_white = stimuli.Dot(radius=5, colour=misc.constants.C_WHITE)
fixdot_white.preload()
mask = stimuli.TextLine(text="#", text_size=46)
control.start(exp)
controller = Leap.Controller()
controller.set_policy_flags(Leap.Controller.POLICY_IMAGES)
finger_names = ['Thumb', 'Index', 'Middle', 'Ring', 'Pinky']
def convert(image, width, height):
#wrap image data in numpy array
i_address = int(image.data_pointer)
ctype_array_def = ctypes.c_ubyte * image.height * image.width
# as ctypes array
as_ctype_array = ctype_array_def.from_address(i_address)
# as numpy array
as_numpy_array = np.ctypeslib.as_array(as_ctype_array)
img = np.reshape(as_numpy_array, (image.height, image.width))
define a trial
def do_block(cnt, block, experiment):
block.shuffle_trials()
# training_list = []
if trial.get_factor("fingers") == 0:
pic = stimuli.Picture("mask.JPG")
prime = trial.get_factor("digit")
else:
pic = stimuli.Picture("{}fingers_{}_{}small.JPG".format(trial.get_factor("fingers"), posturetype, trial.get_factor("smallhand"))) #MODIFIED
prime = trial.get_factor("fingers") + trial.get_factor("distance")
blankscreen.present()
stimuli.TextLine(text="{}---{}".format(whichFingersLeft, whichFingersRight)).present()
block_cnt = 0
trial_cnt = 0
stimuli.TextScreen("Instructions", """In the experiment, pictures showing two hands are presented to you. You should imitate the configurations with your fingers.\n\n
Please note:\n
\nQuestions?""").present()
exp.keyboard.wait()
stimuli.TextScreen("Suggestion", """The Leap Motion does not react perfectly.\n
If the LEAP Motion does not recognize you correctly for too long of a time after releasing the buttons, a feedback will be dispayed before the white dot.\n
This can be due to the fact that you showed the wrong number of fingers or you were out of the "viewing area".\n
Please try to make your finger poses recognizable. Thank you!\n
\nQuestions?""").present()
exp.keyboard.wait()
path = "taskExact_vp{}".format(str(exp.subject))
os.mkdir(path, 0755)
for cnt, block in enumerate(exp.blocks, 0):
if cnt == 0:
stimuli.TextScreen("Training", "").present()
exp.keyboard.wait()
else:
stimuli.TextScreen("Experiment", "Attention, let¥s start now!").present()
exp.keyboard.wait()
blankscreen.present()
exp.clock.wait(500)
do_block(cnt, block, cnt)
control.end(goodbye_text="Many Thanks!", goodbye_delay=3000)
I am afraid that due to automatic formatting in the forum, a lot of information is lost.
You can embedd code here in the forum within three backticks on either side (Markdown syntax).
Alternatively, you can upload your code to gist.github.com.
Florian Krause (Developer)
http://www.expyriment.org
Could I send it to you by e-mail?
yes. florian@expyriment.org
Florian Krause (Developer)
http://www.expyriment.org