Logging data
how to collect and examine experimental data
- Reading a PennController results file.
- Comparing timestamps to calculate response time.
Some h2
By default, PennController logs only when a trial starts and when it ends. Use the log
command to collect any other information.
The log
command adds lines to the results
file in the experiment project page’s Results folder. The information that is added depends on the element type that the log
command is called on. To learn what information is added by calling log
on a specific element type, visit that element type’s reference page under Elements.
- Uncomment the
DebugOff
command, since we are now ready to collect data. - Call the
log
command on the"side-by_side"
Canvas
to log when the images are printed to the screen. - Call the
log
command on the"keypress"
Key
to log information about the participant’s keypress.
@// Type code below this line.
@
@// Remove command prefix
@PennController.ResetPrefix(null)
@
@// Turn off debugger
!DebugOff()
@
@// Instructions
@// code omitted in interest of space
@
@// Experimental trial
@newTrial("experimental-trial",
@ newAudio("fish-audio", "2fishRoundTank.mp3")
@ .play()
@ ,
@ newText("fish-sentence", "The fish swim in a tank which is perfectly round.")
@ .center()
@ .unfold(2676)
@ ,
@ newImage("fish-plural", "2fishRoundTank.png")
@ .size(200, 200)
@ ,
@ newImage("fish-singular", "1fishSquareTank.png")
@ .size(200, 200)
@ ,
@ newCanvas("side-by-side", 450,200)
@ .add( 0, 0, getImage("fish-plural"))
@ .add(250, 0, getImage("fish-singular"))
@ .center()
@ .print()
+ .log()
@ ,
@ newKey("keypress", "FJ")
+ .log()
@ .wait()
@ ,
@ getAudio("fish-audio")
@ .wait("first")
@)
Collecting data
Run the experiment to log data and look at the logged data:
- Save and close the
main.js
file. - In the Results folder, delete any existing files.
- Click the link at the top of the experiment project page to run the experiment.
- Complete the experiment.
- Click the Results folder refresh icon.
- Open the
results
file:- Click on results to open the
results
file as a pop-up window in the experiment project page; or - Click on the eye icon under results to open the
results
file in a new tab; or - Right-click on the eye icon, click Save Link As…, enter
"results.csv"
in the “Save As:” field, and click Save to save theresults
file as a comma-separated value (CSV) file.
- Click on results to open the
Examining experimental results
The results
file should look like the following:
#
# Results on...
# USER...
# Design number...
#
# Columns below this comment are as follows:
# 1. Time results were received.
# 2. MD5 hash of participant's IP address.
# 3. Controller name.
# 4. Item number.
# 5. Element number.
# 6. Type.
# 7. Group.
# 8. PennElementType.
# 9. PennElementName.
# 10. Parameter.
# 11. Value.
# 12. EventTime.
# 13. Comments.
1603390913,SOME_MD5_HASH,PennController,0,0,instructions,NULL,PennController,0,_Trial_,Start,1603390891064,NULL
1603390913,SOME_MD5_HASH,PennController,0,0,instructions,NULL,PennController,0,_Trial_,End,1603390892111,NULL
1603390913,SOME_MD5_HASH,PennController,1,0,experimental-trial,NULL,PennController,1,_Trial_,Start,1603390892115,NULL
1603390913,SOME_MD5_HASH,PennController,1,0,experimental-trial,NULL,Canvas,side-by-side,Print,NA,1603390892122,NULL
1603390913,SOME_MD5_HASH,PennController,1,0,experimental-trial,NULL,Key,keypress,PressedKey,F,1603390893835,Wait success
1603390913,SOME_MD5_HASH,PennController,1,0,experimental-trial,NULL,PennController,1,_Trial_,End,1603390894815,NULL
Rows that begin with the pound symbol #
are either:
- Comments that either provide logging meta-information; or
- Column names for the comma-separated values.
Rows that do not begin with the pound symbol are logged information.
Relevant information contained in the five rows at the bottom:
"instructions"
trial: started at the timestamp1603390891064
."instructions"
trial: ended at the timestamp1603390892111
."experimental-trial"
trial: started at the timetamp1603390892115
."side-by-side"
Canvas
was printed at the timestamp1603390892122
."keypress"
Key
: the participant pressed theF
key at the timestamp1603390893835
."experimental-trial"
trial: ended at the timestamp1603390894815
.
The timestamps are Unix timestamps in milliseconds, in other words the number of milliseconds since 00:00:00 UTC on January 1, 1970.
Calculating response times
You can compare timestamps to determine response times or event duration. For example, subtract the canvas timestamp from the keypress timestamp to determine how long it took for the participant to press a valid key: 1603390893835
-1603390892122
=1713
means that the participant took 2753ms to press the F
key.
We recommend using the canvas and keypress timestamps to calculate response time, instead of using the trial start and keypress timestamp. We’ll add a one-second delay trial delay in the Advanced Tutorial, meaning that using the trial start timestamp would artificially inflate the response time by at least 1000ms.