Line repetition in CSV output file

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

Line repetition in CSV output file

Post by a.rey-mermet » Wed Jul 22, 2015 12:17 pm

Hi!

I have the problem that in the output CSV files of some (but not all) participants, a line was written twice. I have surrounded the two relevant lines in red:
example file.xlsx
The stimulus (i.e., $$) is repeated even if the input CSV file includes no stimulus repetition. All other elements are repeated (incl. RT), expect that the response was correct in the first line, but not in the second line (see the digits in blue). As we used a tracking procedure based on accuracy (i.e., 17 ms were added in the stimulus duration in case of a correct response, but 51 ms were removed in case of an error), this had an impact on the stimulus duration because it added some time even if the participant responded correctly (see the digits in yellow). I don't think that the stimulus was presented twice because the RT was similar in both lines and it is relatively unlikely that the participant would have responsded correctly the first time, but not in the repetition).

Do you see any reason why the line has repeated? I have attached the code if it can help.
NumberStroop.java
Thanks in advance for any help!

cheers,
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: Line repetition in CSV output file

Post by alocher » Wed Jul 22, 2015 7:25 pm

The scenario you're describing matches our observations of your other issues. Somehow the timing was so close that your task ended up calling the endTask() method twice, once from the actionTriggered method after user input and once from your displayStimulusTask object which is called when the stimulus expires. If you check the durationTime (the time it took the user to respond: 451) and the stimulusDuration (the time it takes for the stimulus to expire: 447) you can see that the durationTime is slighty bigger which indicates the user pressed the key very close to your stimulusDuration expiration time. As you know there are lots of factors introducing lag (device input, refreh rates, etc.) which is why this is possible the smaller your durations are.

The export contains a default trial.id column which indicates which trial was added first and should be unique (I didn't find the column in your export). The lower id was added first and if it's the trial with a response you know that this was the actual response and the other one is the stimulus expiration. In order to mitigate the risk of this happening I could imagine setting a flag (userResponse is true) as a first step in the actionTriggered method which you can check in your displayStimulusTask and stop it from doing anything if it's set to true.

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

Re: Line repetition in CSV output file

Post by a.rey-mermet » Tue Sep 01, 2015 7:59 am

Hi André,

Sorry for my very late response. Do you mean such a flag?

Code: Select all



public class ArrowFlanker extends BlockingAWTExecutable implements
		ActionPanelListener, ExecutionPhaseListener, DescriptivePropertyHolder {

	Logger logger = LoggerFactory.getLogger(ArrowFlanker.class);

	... 
	
	// to ensure timing properties - define the variable
	boolean flag;

	...	
		
	private void displayCross() {
		...
		
		// set the helper variable
		flag = false;
		
		...
		
		// timer
		displayCrossTask = new TimerTask() {
			public void run() {
				SwingUtilities.invokeLater(new Runnable() {
					public void run() {
						regionsContainer.setRegionContentVisibility(
							Region.CENTER, false);
						regionsContainer.removeRegionContent(Region.CENTER);

						// init data
						initStimulus();
					}
				});
			}
		};
		timer.schedule(displayCrossTask, crossDuration);
	}
	
	
	// Generates the stimuli
	private void initStimulus() {
		if (!flag){
			
			...
					
			//display stimuli only for a given time
			displayStimulusTask = new TimerTask() {
				public void run() {
					SwingUtilities.invokeLater(new Runnable() {
						public void run() {							
							// disable action panel
							actionPanel.disableActionPanel();
							
							// value for givenResponse when no response
							givenResponse = 0;
							
							// store the data and stop the execution
							endTask();						
						}
					});
				}
			};
			timer.schedule(displayStimulusTask, stimulusDuration);	
		}	
	}
		
	//Called when action panel listener receives an event
	public void actionTriggered(ActionPanel source, Object actionValue) {
		// to ensure timing properties
		flag = true;
		
		...
				
		// store the data and stop the execution
		endTask();	
			
	}	
}	
cheers,
Alodie

N.B. Please find attached the complete file if necessary
ArrowFlanker.java
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: Line repetition in CSV output file

Post by alocher » Fri Sep 04, 2015 4:29 pm

The check flag should happen within the displayStimulusTask as that's where the second call to endTask() is. The initStimulus() method represents the start of your trial at which time the ActionPanel isn't enabled yet and is therefore not the issue.

Code: Select all

//display stimuli only for a given time
displayStimulusTask = new TimerTask() {
	public void run() {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {	
			
				// this Timer Task might get called at the same time a user presses a key,
				// so we want to make sure that we only run this if the user hasn't already pressed a key
				if (!flag) {
				
					// disable action panel
					actionPanel.disableActionPanel();
							
					// value for givenResponse when no response
					givenResponse = 0;
							
					// store the data and stop the execution
					endTask();	
					
				}										
			}
		});
	}
};
timer.schedule(displayStimulusTask, stimulusDuration);
			

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

Re: Line repetition in CSV output file

Post by a.rey-mermet » Sun Sep 06, 2015 1:17 pm

Thank you!

cheers,
Alodie

Locked

Who is online

Users browsing this forum: No registered users and 1 guest