Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
suri

Junior Member
Registered:
Posts: 12
Reply with quote  #1 
Hi there, 
I have a scene that shows an image for 500ms and requires the animal to hold a button and fixate. I would like to add to this scene a time counter for the button, so that the time counter will begin when the image is displayed and the scene will end when the time reaches tc.Duration or the button is released. I seem to be unable to do it all in one scene (consequently I cannot lock the start of the counter to the beginning of the image display). currently my code reads:

scene 1:
btn = singlebutton(button_)
btn.button=1
fix = singletarget(eye_)
fix.target = image
fix.threshold = hold_radius
and = AndAdapter(btn)
and.add(fix)
wth = waitthenhold(and)
wth.waittime = 0 (I already have fix from a previous scene)
wth.holdtime = image_time
scene1 = create_scene(wth, [fixation_point image])

scene2
btn2=singlebutton(button_)
btn2.button=1
fta2=fixtimeanalyzer(btn2)
tc2=timecounter (fta2)
tc2.duration =900
scene2 = create_scene(tc2)

any idea?

thank you!
0
Jaewon

Administrator
Registered:
Posts: 953
Reply with quote  #2 
Your description doesn't look complete. According to the code you posted, it appears that there is one previous scene which checks button hold and eye fixation. Then an image is presented for image_time (500 ms?) while button hold and eye fixation are maintained (scene 1 you posted). Finally, nothing is presented but the button should not be released for another 900 ms (your scene 2).

My questions are:
1) Is it correct that button hold and eye fixation occur before your scene1?
2) Don't you want the image to stay on the screen from the beginning of scene 1 to the end of scene 2? The code doesn't work in that way, but your description sounds like you want to combine scene 1 & 2 and show the image for the entire duration.
3) What happens if eye fixation is broken in scene 2? Do you not care whether the fixation is maintained or not?

0
suri

Junior Member
Registered:
Posts: 12
Reply with quote  #3 
1) yes you are correct, there is a previous scene that acquire both button hold and fixation on a fixation point (not on the image yet, just of a fixation point) and it holds it for 400msec BEFORE the beginning of what I named scene 1 in the previous post.

2) you are also correct that ideally I would combine scene 1 and 2 to obtain the following sequence of events: button hold and fixation were acquired in previous scene not mentioned in the original post -> an image appears, fixation on the image and button hold are acquired AND TC related to the button hold starts -> TC continues and image remains on the screen until a total of 900 msec have passed OR until the button press is broken. The reason I want TC to start with the image onset is that I want to acquire the time interval between image onset and the break of the button press.

3) During this 'combined' scene (I realized the code doesn't combine these input in a single scene hence my question) I would not care that fixation is maintained as long as it is acquired. To answer your question, no in the code that I wrote in the previous post scene 2 does not require fixation purposefully   
0
Jaewon

Administrator
Registered:
Posts: 953
Reply with quote  #4 
When the previous scene (let's call it scene 0) is successfully finished, you know both button press and eye fixation are acquired. There is no need to check them again in scene 1. So the behaviors you need to check in scene 1 are just whether the button is released and whether 900 ms is up. Please see the code below.

----- Beginning of the code -----
fixation_point = 1;  % TaskObject #1
image = 2;           % TaskObject #2

% scene 0: wait for button press and eye fixation
fix1 = SingleTarget(eye_);
fix1.Target = fixation_point;
fix1.Threshold = 3;
btn1 = SingleButton(button_);
btn1.Button = 1;  % Button #1
and1 = AndAdapter(fix1);
and1.add(btn1);
wth1 = WaitThenHold(and1);
wth1.WaitTime = 5000;
wth1.HoldTime = 400;
scene1 = create_scene(wth1,fixation_point);

% sceen 1: wait for button release or time up
btn2 = SingleButton(button_);
btn2.Button = 1;
not2 = NotAdapter(btn2);  % make SingleButton work for button release, instead of press
tc2 = TimeCounter(null_);
tc2.Duration = 900;
or2 = OrAdapter(not2);
or2.add(tc2);
scene2 = create_scene(or2,[fixation_point image]);

error_type = 0;
button_release = 0;

run_scene(scene1,10);
if ~wth1.Success
    if wth1.Waiting
        if fix1.Success
            error_type = 1;  % no button response
        else
            error_type = 4;  % no fixation
        end
    else
        if fix1.Success
            error_type = 7;  % button release
        else
            error_type = 3;  % fixation break
        end
    end
end

if 0==error_type
    image_on = run_scene(scene2,20);
    if not2.Success  % ~tc2.Success may not rule out the possibility that button release and time-up occur in the same frame
        button_release = btn2.Time - image_on;  % time of button release from image onset
        error_type = 5;  % early button release
    end
end

idle(0);

trialerror(error_type);

----- End of the code -----

0
suri

Junior Member
Registered:
Posts: 12
Reply with quote  #5 
Thank you, it makes it so much easier... I am trying it on now, just a clarification:

in the code you wrote tc2.Success = hold until the end of duration, or releasing before the end of Duration? I got confused because of the use of the NotAdapter, but it seems you mean tc2.Success is hold until the end of Duration
0
Jaewon

Administrator
Registered:
Posts: 953
Reply with quote  #6 
NotAdapter is there to make SingleButton become success for button release, instead of press.

SingleButton: success on press
SingleButton + NotAdapter: success on release

OrAdapter terminates the scene, whichever between (SingleButton + NotAdapter) and TimeCounter succeeds first. So the success of tc2 means that (SingleButton + NotAdapter) did not succeed yet (i.e., the button has not been released). But now I think checking the state of NotAdapter is a better option, since it is possible that they succeed at the same time. I am fixing the code.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.