millisecond timing precision


Author
Message
nrouhani
nrouhani
Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)
Group: Forum Members
Posts: 77, Visits: 251
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 89K
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

nrouhani
nrouhani
Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)
Group: Forum Members
Posts: 77, Visits: 251
Dave - 11/7/2022
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

as i have included in my example, i do include a timestamp on each trial's /ontrialbegin, it is however not in milliseconds and not as accurate as i need it to be (the timestamp is also not lining up with outside time measures) - is this my only solution?

i also included three other examples in my initial question about the 'elapsed time' measure that have gone unanswered (pasted below again) - i would appreciate your input on how to deal with them (especially when the elapsed time seems to stop after a response is recorded and not record the entire trial duration). thank you

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 89K
nrouhani - 11/7/2022
Dave - 11/7/2022
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

as i have included in my example, i do include a timestamp on each trial's /ontrialbegin, it is however not in milliseconds and not as accurate as i need it to be (the timestamp is also not lining up with outside time measures) - is this my only solution?

i also included three other examples in my initial question about the 'elapsed time' measure that have gone unanswered (pasted below again) - i would appreciate your input on how to deal with them (especially when the elapsed time seems to stop after a response is recorded and not record the entire trial duration). thank you

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

currenttime is not the timestamp I am referring to the trial's timestamp property.

https://www.millisecond.com/support/docs/v5/html/language/properties/timestamp.htm


nrouhani
nrouhani
Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)
Group: Forum Members
Posts: 77, Visits: 251
Dave - 11/7/2022
nrouhani - 11/7/2022
Dave - 11/7/2022
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

as i have included in my example, i do include a timestamp on each trial's /ontrialbegin, it is however not in milliseconds and not as accurate as i need it to be (the timestamp is also not lining up with outside time measures) - is this my only solution?

i also included three other examples in my initial question about the 'elapsed time' measure that have gone unanswered (pasted below again) - i would appreciate your input on how to deal with them (especially when the elapsed time seems to stop after a response is recorded and not record the entire trial duration). thank you

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

currenttime is not the timestamp I am referring to the trial's timestamp property.

https://www.millisecond.com/support/docs/v5/html/language/properties/timestamp.htm


thank you, that certainly helps!

one remaining question: is there any way to determine the exact timing of the start of the pretrial signal to the end of that trial (instead of also including the timing before the pretrial signal, example below)?

<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = trial.new_memBlock.timestamp]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 89K
nrouhani - 11/8/2022
Dave - 11/7/2022
nrouhani - 11/7/2022
Dave - 11/7/2022
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

as i have included in my example, i do include a timestamp on each trial's /ontrialbegin, it is however not in milliseconds and not as accurate as i need it to be (the timestamp is also not lining up with outside time measures) - is this my only solution?

i also included three other examples in my initial question about the 'elapsed time' measure that have gone unanswered (pasted below again) - i would appreciate your input on how to deal with them (especially when the elapsed time seems to stop after a response is recorded and not record the entire trial duration). thank you

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

currenttime is not the timestamp I am referring to the trial's timestamp property.

https://www.millisecond.com/support/docs/v5/html/language/properties/timestamp.htm


thank you, that certainly helps!

one remaining question: is there any way to determine the exact timing of the start of the pretrial signal to the end of that trial (instead of also including the timing before the pretrial signal, example below)?

<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = trial.new_memBlock.timestamp]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>



So what the /pretrialsignal delays is mainly the start of the stimulus presentation sequence, i.e. what you have in /stimulustimes. You can get close to the time the pretrialsignal occured by looking at the timestamp property of the stimulus presented at t0 in the stimulus presentation sequence. Subtract the trial's timestamp from the "blank" stimulus's timestamp and you have the approximate time the trial object spent waiting for the pretrialsignal.

If my goal were to get that trial to last as close to 6 seconds as possible, not considering time spent waiting for the pretrial signal, I would set it up along the following lines:

<values>
/trialtimestamp = 0
/trialelapsedtime = 0
/1st_stimtimestamp = 0
/waitperiodforpretrialsignal = 0
</values>

<block exampleblock>
/ trials = [1-4 = trial.new_memBlock]
</block>

<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = trial.new_memBlock.timestamp]
/ stimulustimes = [0=blank,cross; 5980=clearscreen]
/ posttrialpause = 20
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime;
    values.1st_stimtimestamp = shape.blank.timestamp;
    values.waitperiodforpretrialsignal = values.1st_stimtimestamp - values.trialtimestamp;]
</trial>

<shape blank>
/ shape = rectangle
/ color = white
/ size = (100%, 100%)
/ erase = false
</shape>

<text cross>
/ items = ("+")
/ erase = false
</text>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode response latency correct
    values.trialtimestamp values.1st_stimtimestamp values.waitperiodforpretrialsignal)
/ separatefiles = true
</data>


When you look at the data, you should see approx. 6000 ms elapsing between values.1st_stimtimestamp in trial N and values.trialtimestamp in trial N+1.

nrouhani
nrouhani
Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)Distinguished Member (2.6K reputation)
Group: Forum Members
Posts: 77, Visits: 251
Dave - 11/8/2022
nrouhani - 11/8/2022
Dave - 11/7/2022
nrouhani - 11/7/2022
Dave - 11/7/2022
nrouhani - 11/5/2022
hello, 

i am running an fMRI study that needs very precise timing information. i understand that the timestamps don't have mililseconds, and i've tried to use a combination of timestamps at the beginning of each trial and elapsed time during each trial to get more precise timing information. i'm noticing that the numbers aren't adding up, the difference in timestamps from start to finish do not match the sum of trial's elapsed time (and for many trials the elapsed time is below the minimum trial duration). below, i have listed 4 specific examples of what elapsed time measures i would like to be able to record. 

(1) how do i record elapsed time for the posttrialpause below? (i.e., would like elapsed time that reflects the below trial duration)
<openended estimate_nat>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ mask = positiveintegerorzero
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = 2000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.estimate_nat.elapsedtime]
/ branch = [
trial.outcome_nat
]

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
  values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
  values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000 
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

thank you so much, i understand this is tedious!!

/ontrialend logic is executed sometime during the posttrialpause, so taking elapsed time ontrialend it does not capture the duration of the posttrialpause and is not supposed to.

The most accurate measurement you can get is taking a trial N's timestamp /ontrialbegin, taking trial N+1's timestamp /ontrialbegin, and then calculating the difference. The result is the overall duration of trial N, including any posttrialpause and time "between" trials.

as i have included in my example, i do include a timestamp on each trial's /ontrialbegin, it is however not in milliseconds and not as accurate as i need it to be (the timestamp is also not lining up with outside time measures) - is this my only solution?

i also included three other examples in my initial question about the 'elapsed time' measure that have gone unanswered (pasted below again) - i would appreciate your input on how to deal with them (especially when the elapsed time seems to stop after a response is recorded and not record the entire trial duration). thank you

(2) relatedly, would it be possible to have elapsed timing information for the entire trial (reflecting trial duration) and not just after the response?
<trial memStims_art_A_y_T>
/ ontrialbegin = [
values.artSample = list.memList_imageSelect_art_A_y.nextvalue;
values.trialtimestamp = script.currenttime;
]
/ stimulustimes = [0=blank, artP; 3000=newOld, memScale, mem_leftHand, mem_rightHand]
/ validresponse = ("0","1","2","3","4","5","6","7","8","9")
/ beginresponsetime = 3000
/ trialduration = 5000
/ ontrialend = [values.trialelapsedtime = trial.memStims_art_A_y_T.elapsedtime]
/ branch = [
trial.mem_iti
]
</trial>

(3) this trial waits for a pretrial signal, i would like the elapsed time to reflect the time after the pretrialsignal is sent (it currently records time for the whole trial, including the time before the signal is detected).
<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = script.currenttime]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>

(4) is there a way to record elapsed time between trials?

currenttime is not the timestamp I am referring to the trial's timestamp property.

https://www.millisecond.com/support/docs/v5/html/language/properties/timestamp.htm


thank you, that certainly helps!

one remaining question: is there any way to determine the exact timing of the start of the pretrial signal to the end of that trial (instead of also including the timing before the pretrial signal, example below)?

<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = trial.new_memBlock.timestamp]
/ stimulustimes = [0=blank,cross]
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime]
</trial>



So what the /pretrialsignal delays is mainly the start of the stimulus presentation sequence, i.e. what you have in /stimulustimes. You can get close to the time the pretrialsignal occured by looking at the timestamp property of the stimulus presented at t0 in the stimulus presentation sequence. Subtract the trial's timestamp from the "blank" stimulus's timestamp and you have the approximate time the trial object spent waiting for the pretrialsignal.

If my goal were to get that trial to last as close to 6 seconds as possible, not considering time spent waiting for the pretrial signal, I would set it up along the following lines:

<values>
/trialtimestamp = 0
/trialelapsedtime = 0
/1st_stimtimestamp = 0
/waitperiodforpretrialsignal = 0
</values>

<block exampleblock>
/ trials = [1-4 = trial.new_memBlock]
</block>

<trial new_memBlock>
/ ontrialbegin = [values.trialtimestamp = trial.new_memBlock.timestamp]
/ stimulustimes = [0=blank,cross; 5980=clearscreen]
/ posttrialpause = 20
/ trialduration = 6000
/ validresponse = (noresponse)
/ pretrialsignal = (keyboard,13)
/ ontrialend = [values.trialelapsedtime = trial.new_memBlock.elapsedtime;
    values.1st_stimtimestamp = shape.blank.timestamp;
    values.waitperiodforpretrialsignal = values.1st_stimtimestamp - values.trialtimestamp;]
</trial>

<shape blank>
/ shape = rectangle
/ color = white
/ size = (100%, 100%)
/ erase = false
</shape>

<text cross>
/ items = ("+")
/ erase = false
</text>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode response latency correct
    values.trialtimestamp values.1st_stimtimestamp values.waitperiodforpretrialsignal)
/ separatefiles = true
</data>


When you look at the data, you should see approx. 6000 ms elapsing between values.1st_stimtimestamp in trial N and values.trialtimestamp in trial N+1.

thank you so much, this really helps!!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search