Acceleration of presentation times

Ask questions and discuss programming issues around Tatool Java.
Locked
a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Acceleration of presentation times

Post by a.rey-mermet » Tue Jan 20, 2015 3:33 am

Hi!

I'm programming a negative priming task with shapes as stimuli. The trial structure is relatively complex because it consists of:
1. fixation cross: 500 ms
2. stimulus: 300 ms
3. mask: 100 ms
4. blank 1: 1600 ms
5. feedback (only for practice): 500 ms
6. blank 2: 500 ms

The response window starts from the stimulus presentation until the end of the blank 1. When a response occurs during the stimulus presentation, the stimulus presentation is stopped. When a response occurs during the mask presentation, the mask presentation is stopped. Similarly, when a response occurs during the blank 1 presentation, the blank 1 presentation is stopped. In all three cases, after a presentation is stopped, the feedback or the blank 2 is presented.
To do this, I created a variable "helpSeq" which is adjusted for each element presentation (i.e., helpSeq = 1 when the stimulus is presented, helpSeq = 2 when the mask is presented, and helpSeq = 3 when the blank 1 is presented). In the actionTriggered method, I created an if-loop to stop the presentation of the right display.

Code: Select all

if (helpSeq == 1){
	displayStimulusTask.cancel(); //stop the presentation of the stimulus
} else if ( helpSeq == 2){
	displayMaskTask.cancel(); //stop the presentation of the mask
} else if ( helpSeq == 3){
	displayBlank1Task.cancel(); //stop the presentation of the blank 1
}
In some trials by some participants, I have the problem that the presentation of the elements (i.e., stimulus, mask and blank 1) is accelerated. Until now, I do not succeed to replicate the problem myself and I do no see where the problem comes from. Any idea?

Here is the whole java file:
ShapeNegativePriming.java
Thanks in advance for any help!
Alodie
You do not have the required permissions to view the files attached to this post.

alocher
Posts: 259
Joined: Tue Apr 24, 2012 12:56 pm
Institution: Tatool

Re: Acceleration of presentation times

Post by alocher » Thu Jan 22, 2015 9:07 pm

I had a look at your code and have a few suggestions/ideas. It's of course hard to identify the problem without being able to run the code, but as you said yourself, you can't reproduce the error yourself. An accelerated presentation time is usually caused by timers overlapping each other or not being cancelled properly. In your code you take care of cancelling the timers depending on the current position (helpSeq), but there's still a chance that you're cancelling too late.

1. As a first step, make sure you only activate the actionPanel at the point where a response can be given. I guess in your code that's already the case and if not this is where you can start.

2. Even though you take care of for example cancelling the displayStimulusTask if you're inside the initStimulus() method and a user presses a key, you could still be cancelling the task too late (i.e. it's already running at the time you call the cancel method which will not cancel it but just make sure to not run it if it's only scheduled yet). In order to make sure the following method (displayMask()) doesn't start, you'll have to set some kind of flag (boolean variable) at the time of actionTriggered(). This variable can then be used in an if clause in the following method to only do something if the flag is not set. That way you make sure that no other code is executed once actionTriggered is called. The same should of course be done for the following timerTasks.

Code: Select all

private void displayMask() {
	if (!flag) {
		// only do stuff if flag is not set
	}
}
3. The order of actions within the actionTriggered() method should always follow this priority:

Code: Select all

public void actionTriggered(ActionPanel source, Object actionValue) {

		// 1. disable actionPanel to avoid this method from triggering again
		
		// 2. get the end time to be as close as possible to the actual key/mouse press
				
		// 3. cancel any possibly still scheduled timer tasks
	
		// 4. everything else is not time critical anymore (e.g. respone processing)
		
		...

a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Re: Acceleration of presentation times

Post by a.rey-mermet » Mon Jan 26, 2015 6:50 am

Thanks for the response. Points 1 and 3 are clear. I have further questions for Point 2.
If I understand you correctly, I first have to define a boolean variable in the class ShapeNegativePriming at the beginning of the file, such as:

Code: Select all

// to ensure timing properties
	boolean flag;
Second, I have to set the flag variable in actionTriggered. But how exactly can I do that? Is it something like this?

Code: Select all

flag = givenResponse !=0;
Third, in the displayMask, I have to put all elements in the if clause, such as in your example. This is also includes the displayMaskTask, or not?

Finally, I use the same flag variable for the displayBlank1. Is it correct?

cheers,
Alodie

alocher
Posts: 259
Joined: Tue Apr 24, 2012 12:56 pm
Institution: Tatool

Re: Acceleration of presentation times

Post by alocher » Sat Jan 31, 2015 4:35 pm

Sounds about right. But I think you can just set the flag to true as it doesn't depend on your givenResponse. Anytime your code gets into the actionTriggered method the task will be stopped, therefore nothing else should run.

Code: Select all

flag = true;

Locked

Who is online

Users browsing this forum: No registered users and 1 guest