|
krmanning10
|
|
|
Group: Forum Members
Posts: 12,
Visits: 36
|
Hello,
How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back?
The relevant code:
<trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial>
|
|
|
|
|
krmanning10
|
|
|
Group: Forum Members
Posts: 12,
Visits: 36
|
+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you!
|
|
|
|
|
Dave
|
|
|
Group: Administrators
Posts: 13K,
Visits: 109K
|
+x+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you! I'm sorry, but the script is useless without the files. If you cannot upload them here, upload them somewhere else -- Dropbox or some other service -- and provide a download link. Also please provide an absolutely clear description of what you actually want. Your one sentence isn't very clear. And what you want cannot be inferred from non-working code. The logic you've added to the trial doesn't make obvious sense. And if you really want to make my life easier, make a stripped down version of the script that only contans the parts relevant to your question, and none of all the other things that have nothing to do with it.
|
|
|
|
|
krmanning10
|
|
|
Group: Forum Members
Posts: 12,
Visits: 36
|
+x+x+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you! I'm sorry, but the script is useless without the files. If you cannot upload them here, upload them somewhere else -- Dropbox or some other service -- and provide a download link. Also please provide an absolutely clear description of what you actually want. Your one sentence isn't very clear. And what you want cannot be inferred from non-working code. The logic you've added to the trial doesn't make obvious sense. And if you really want to make my life easier, make a stripped down version of the script that only contans the parts relevant to your question, and none of all the other things that have nothing to do with it. Hi! Sorry to return to this question from weeks ago. I attached a script with only the relevant code and I removed the unnecessary items that require a folder. It should be able to run now. As a reminder, my question is how I can have the rectangles labelled as line1p1, line2p1, etc. change from black to blue on a fixed clock. Right now, the script only changes the rectangles to blue when the participant presses the space bar, and beforehand when I tried to have a fixed clock by itself, it resets every time the participant pressed the spacebar. So how can I have the rectangles update on their own while still saving its progress? I generally want it to be close to on time with the participant space bar but not quite exact. Thank you again for your help.
|
|
|
|
|
Dave
|
|
|
Group: Administrators
Posts: 13K,
Visits: 109K
|
+x+x+x+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you! I'm sorry, but the script is useless without the files. If you cannot upload them here, upload them somewhere else -- Dropbox or some other service -- and provide a download link. Also please provide an absolutely clear description of what you actually want. Your one sentence isn't very clear. And what you want cannot be inferred from non-working code. The logic you've added to the trial doesn't make obvious sense. And if you really want to make my life easier, make a stripped down version of the script that only contans the parts relevant to your question, and none of all the other things that have nothing to do with it. Hi! Sorry to return to this question from weeks ago. I attached a script with only the relevant code and I removed the unnecessary items that require a folder. It should be able to run now. As a reminder, my question is how I can have the rectangles labelled as line1p1, line2p1, etc. change from black to blue on a fixed clock. Right now, the script only changes the rectangles to blue when the participant presses the space bar, and beforehand when I tried to have a fixed clock by itself, it resets every time the participant pressed the spacebar. So how can I have the rectangles update on their own while still saving its progress? I generally want it to be close to on time with the participant space bar but not quite exact. Thank you again for your help. I think what you are missing is that you are not running a single trial. Whenever a response occurs, the current instance of the trial ends and new one begins. So, much like it's done with the animation, you need to math things out regarding the coloring. For the animation, the time left and its position is recorded when the current trial ends and it resumes at that point for whatever time is left in the next instance of the trial. You need to do essentially the same thing for the rectangles. Look at how much time has already been elapsed and accordingly which rectangles have already turned blue. These need to be set to be blue in the next trials first frame already. Based on the time spent, you also need to calculate when the next rectangle should turn blue, and adust the timing of that and all the other remaining rectangles accordingly by using the insertstimulusTime() function. Suppose the 1st response occurs after 3200 mis, then you know that the first three rectangles have already turned blue and need to be displayed right from the start of the next instance of the trial. You also know that the 4th rectangle has to turn blue 800 ms into the next trial, the 5th 1800 ms, and so forth.
|
|
|
|
|
Dave
|
|
|
Group: Administrators
Posts: 13K,
Visits: 109K
|
+x+x+x+x+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you! I'm sorry, but the script is useless without the files. If you cannot upload them here, upload them somewhere else -- Dropbox or some other service -- and provide a download link. Also please provide an absolutely clear description of what you actually want. Your one sentence isn't very clear. And what you want cannot be inferred from non-working code. The logic you've added to the trial doesn't make obvious sense. And if you really want to make my life easier, make a stripped down version of the script that only contans the parts relevant to your question, and none of all the other things that have nothing to do with it. Hi! Sorry to return to this question from weeks ago. I attached a script with only the relevant code and I removed the unnecessary items that require a folder. It should be able to run now. As a reminder, my question is how I can have the rectangles labelled as line1p1, line2p1, etc. change from black to blue on a fixed clock. Right now, the script only changes the rectangles to blue when the participant presses the space bar, and beforehand when I tried to have a fixed clock by itself, it resets every time the participant pressed the spacebar. So how can I have the rectangles update on their own while still saving its progress? I generally want it to be close to on time with the participant space bar but not quite exact. Thank you again for your help. I think what you are missing is that you are not running a single trial. Whenever a response occurs, the current instance of the trial ends and new one begins. So, much like it's done with the animation, you need to math things out regarding the coloring. For the animation, the time left and its position is recorded when the current trial ends and it resumes at that point for whatever time is left in the next instance of the trial. You need to do essentially the same thing for the rectangles. Look at how much time has already been elapsed and accordingly which rectangles have already turned blue. These need to be set to be blue in the next trials first frame already. Based on the time spent, you also need to calculate when the next rectangle should turn blue, and adust the timing of that and all the other remaining rectangles accordingly by using the insertstimulusTime() function. Suppose the 1st response occurs after 3200 mis, then you know that the first three rectangles have already turned blue and need to be displayed right from the start of the next instance of the trial. You also know that the 4th rectangle has to turn blue 800 ms into the next trial, the 5th 1800 ms, and so forth. Also, that script you attached can still not run without the various other files it needs, which you have not provided. I would recommed you go back and revisti the previous threads regarding this, which cover the animation part. As I said, the blue rectangle part is conceptually not that different: You need to calculate the correct timings based on when responses occur and what has already happened by the time responses occur. The example code I gave you e.g. here https://forums.millisecond.com/Topic41599.aspx is self-contained. Take that and get it going for one set of timings. Once you have one worked out, it's easy to deal with the other timings.
|
|
|
|
|
Dave
|
|
|
Group: Administrators
Posts: 13K,
Visits: 109K
|
+x+x+x+x+x+xHello, How can I have these rectangles change from black to blue at certain time points in the trial without the participant input of the space bar resetting the colors back? The relevant code: <trial synchrony> / onTrialBegin = { // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 //if (values.xAtResponse < 15pct) if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) sound.noteC.skip = false if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) sound.noteC.skip = false; // if over line 3, 4, or 7 we enable note G if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) sound.noteG.skip = false; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) sound.noteG.skip = false; // if over line 5 or 6, we enable note A if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) sound.noteA.skip = false; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) sound.noteA.skip = false; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) sound.noteG.skip = false; if (values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) shape.line1p2.color = green; if (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct) shape.line2p2.color = green; if (values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) shape.line3p2.color = green; if (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) shape.line4p2.color = green; if (values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) shape.line5p2.color = green; if (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct) shape.line6p2.color = green; if (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct) shape.line7p2.color = green; //confederate if (trial.synchrony.elapsedTime >= 5) shape.line1p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 10) shape.line2p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 15) shape.line3p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 20) shape.line4p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 25) shape.line5p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 30) shape.line6p1.color = cornflowerBlue; if (trial.synchrony.elapsedTime >= 35) shape.line7p1.color = cornflowerBlue; } / stimulusTimes = [1=clearScreen, Participant_Avatar, Confederate_Avatar, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug, confederatename, participantname; 1000 = line1p1BLUE; 2000 = line2p1BLUE; 3000 = line3p1BLUE; 4000 = line4p1BLUE; 5000 = line5p1BLUE; 6000 = line6p1BLUE; 7000 = line7p1BLUE] / beginResponseTime = -1 / validResponse = (" ") / recordData = true / isValidResponse = { if (trial.synchrony.response== 57) values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response return true; } // onTrialEnd = { // if (values.musicLineDuration <= 0 || trial.synchrony.response == 0) // if trial times out, we reset everything // values.musicLineStartX = 5%; // back to the original start position //values.musicLineDuration = 7250; // back to original duration //values.xAtResponse = 0%; // we don't have any response yet // values.repCount += 1; // we increase the repetition count // } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } / timeout = values.musicLineDuration </trial> I also apologize for the lack of zip file. I tried to upload it but it wasn't letting me attach it. If there's another way I can provide it to make your job easier, let me know. Thank you! I'm sorry, but the script is useless without the files. If you cannot upload them here, upload them somewhere else -- Dropbox or some other service -- and provide a download link. Also please provide an absolutely clear description of what you actually want. Your one sentence isn't very clear. And what you want cannot be inferred from non-working code. The logic you've added to the trial doesn't make obvious sense. And if you really want to make my life easier, make a stripped down version of the script that only contans the parts relevant to your question, and none of all the other things that have nothing to do with it. Hi! Sorry to return to this question from weeks ago. I attached a script with only the relevant code and I removed the unnecessary items that require a folder. It should be able to run now. As a reminder, my question is how I can have the rectangles labelled as line1p1, line2p1, etc. change from black to blue on a fixed clock. Right now, the script only changes the rectangles to blue when the participant presses the space bar, and beforehand when I tried to have a fixed clock by itself, it resets every time the participant pressed the spacebar. So how can I have the rectangles update on their own while still saving its progress? I generally want it to be close to on time with the participant space bar but not quite exact. Thank you again for your help. I think what you are missing is that you are not running a single trial. Whenever a response occurs, the current instance of the trial ends and new one begins. So, much like it's done with the animation, you need to math things out regarding the coloring. For the animation, the time left and its position is recorded when the current trial ends and it resumes at that point for whatever time is left in the next instance of the trial. You need to do essentially the same thing for the rectangles. Look at how much time has already been elapsed and accordingly which rectangles have already turned blue. These need to be set to be blue in the next trials first frame already. Based on the time spent, you also need to calculate when the next rectangle should turn blue, and adust the timing of that and all the other remaining rectangles accordingly by using the insertstimulusTime() function. Suppose the 1st response occurs after 3200 mis, then you know that the first three rectangles have already turned blue and need to be displayed right from the start of the next instance of the trial. You also know that the 4th rectangle has to turn blue 800 ms into the next trial, the 5th 1800 ms, and so forth. Also, that script you attached can still not run without the various other files it needs, which you have not provided. I would recommed you go back and revisti the previous threads regarding this, which cover the animation part. As I said, the blue rectangle part is conceptually not that different: You need to calculate the correct timings based on when responses occur and what has already happened by the time responses occur. The example code I gave you e.g. here https://forums.millisecond.com/Topic41599.aspx is self-contained. Take that and get it going for one set of timings. Once you have one worked out, it's easy to deal with the other timings. Here's a self-contained example, based on the code in the referenced thread: <expt myExpt> / blocks = [1=task;] </expt>
<values> // repCount = 0 // not needed anymore / xAtResponse = 0 / musicLineStartX = 5% // start x coordinate of animation / musicLineEndX = 90% // end x coordinate of animation / musicLineDuration = 7250 // duration of full animation / cumLat = 0 // cumulative latency, used to calculate rectangle timings </values>
The bar that moves across the screen: <shape musicline> / shape = rectangle / color = crimson / size = (2%,100%) / animation = path(values.musicLineDuration, 1, values.musicLineStartX, 50%, values.musicLineEndX, 50%) // not doing any actual repetions, so 1, not -1 / erase = false </shape>
<block task> / trials = [1=synchrony] / onBlockBegin = { values.xAtResponse = 0; values.musicLineStartX = 5%; // start x coordinate of animation values.musicLineEndX = 90%; // end x coordinate of animation values.musicLineDuration = 7250; // duration of full animation values.cumLat = 0; // no time has elapsed yet } </block>
<trial synchrony> / onTrialBegin = { trial.synchrony.resetStimulusFrames(); // calculate timings for the blue rectangles var time = Math.max(0, (1000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line1p1BLUE, time); time = Math.max(0, (2000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line2p1BLUE, time); time = Math.max(0, (3000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line3p1BLUE, time); time = Math.max(0, (4000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line4p1BLUE, time); time = Math.max(0, (5000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line5p1BLUE, time); time = Math.max(0, (6000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line6p1BLUE, time); time = Math.max(0, (7000 - values.cumLat)); trial.synchrony.insertStimulusTime(shape.line7p1BLUE, time); // we start out playing no note, skipping all of them sound.noteA.skip = true; sound.noteC.skip = true; sound.noteD.skip = true; sound.noteE.skip = true; sound.noteF.skip = true; sound.noteG.skip = true; // if animation over line 1 or 2 at the time of response, we enable noteC. 19pct, 21pct, 29, 31 if ((values.xAtResponse >= 15pct && values.xAtResponse <= 24pct) || (values.xAtResponse >= 25pct && values.xAtResponse <= 34pct)) { sound.noteC.skip = false; }; // if over line 3, 4, or 7 we enable note G if ((values.xAtResponse >= 35pct && values.xAtResponse <= 44pct) || (values.xAtResponse >= 45pct && values.xAtResponse <= 54pct) || (values.xAtResponse >= 75pct && values.xAtResponse <= 84pct)) { sound.noteG.skip = false; }; // if over line 5 or 6, we enable note A if ((values.xAtResponse >= 55pct && values.xAtResponse <= 64pct) || (values.xAtResponse >= 65pct && values.xAtResponse <= 74pct)) { sound.noteA.skip = false; }; } / stimulusframes = [ 1=clearScreen, musicline, line1p1, line1p2, line2p1, line2p2, line3p1, line3p2, line4p1, line4p2, line5p1, line5p2, line6p1, line6p2, line7p1, line7p2, noteA, noteC, noteD, noteE, noteF, noteG, debug] / beginResponseTime = -1 / validResponse = (" ") / isValidResponse = { if (trial.synchrony.response== 57) { values.xAtResponse = shape.musicline.xPct; // store X coordinate of music line at time of response values.musicLineDuration -= trial.synchrony.latency; // calculate remaining animation duration values.musicLineStartX = values.xAtResponse; // set new start point, picking back up where we were at time of last response values.cumLat += trial.synchrony.latency; // cumulate latency return true; } } / branch = { if (!(values.musicLineDuration <= 0 || trial.synchrony.response == 0)) { // as long as animation / trial hasn't timed out, we keep running return trial.synchrony; } } / timeout = values.musicLineDuration </trial>
The sound files to play: <sound noteC> / items = ("Twinkle_Twinkle_Little_Star_C.mp3") / playThrough = false / erase = false </sound>
<sound noteG> / items = ("Twinkle_Twinkle_Little_Star_G.mp3") / playThrough = false / erase = false </sound>
<sound noteA> / items = ("Twinkle_Twinkle_Little_Star_A.mp3") / playThrough = false / erase = false </sound>
<sound noteF> / items = ("Twinkle_Twinkle_Little_Star_F.mp3") / playThrough = false / erase = false </sound>
<sound noteE> / items = ("Twinkle_Twinkle_Little_Star_E.mp3") / playThrough = false / erase = false </sound>
<sound noteD> / items = ("Twinkle_Twinkle_Little_Star_D.mp3") / playThrough = false / erase = false </sound>
7 shapes that the bar will pass over: <shape line1p1> / shape = rectangle / color = black / size = (2%,25%) / position = (20%, 25%) / erase = false </shape>
<shape line1p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (20%, 25%) / erase = false </shape>
<shape line1p2> / shape = rectangle / color = black / size = (2%,25%) / position = (20%, 75%) / erase = false </shape>
<shape line2p1> / shape = rectangle / color = black / size = (2%,25%) / position = (30%, 25%) / erase = false </shape>
<shape line2p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (30%, 25%) / erase = false </shape>
<shape line2p2> / shape = rectangle / color = black / size = (2%,25%) / position = (30%, 75%) / erase = false </shape>
<shape line3p1> / shape = rectangle / color = black / size = (2%,25%) / position = (40%, 25%) / erase = false </shape>
<shape line3p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (40%, 25%) / erase = false </shape>
<shape line3p2> / shape = rectangle / color = black / size = (2%,25%) / position = (40%, 75%) / erase = false </shape>
<shape line4p1> / shape = rectangle / color = black / size = (2%,25%) / position = (50%, 25%) / erase = false </shape>
<shape line4p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (50%, 25%) / erase = false </shape>
<shape line4p2> / shape = rectangle / color = black / size = (2%,25%) / position = (50%, 75%) / erase = false </shape>
<shape line5p1> / shape = rectangle / color = black / size = (2%,25%) / position = (60%, 25%) / erase = false </shape>
<shape line5p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (60%, 25%) / erase = false </shape>
<shape line5p2> / shape = rectangle / color = black / size = (2%,25%) / position = (60%, 75%) / erase = false </shape>
<shape line6p1> / shape = rectangle / color = black / size = (2%,25%) / position = (70%, 25%) / erase = false </shape>
<shape line6p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (70%, 25%) / erase = false </shape>
<shape line6p2> / shape = rectangle / color = black / size = (2%,25%) / position = (70%, 75%) / erase = false </shape>
<shape line7p1> / shape = rectangle / color = black / size = (2%,25%) / position = (80%, 25%) / erase = false </shape>
<shape line7p1BLUE> / shape = rectangle / color = cornflowerBlue / size = (2%,25%) / position = (80%, 25%) / erase = false </shape>
<shape line7p2> / shape = rectangle / color = black / size = (2%,25%) / position = (80%, 75%) / erase = false </shape>
<text debug> / items = ("X position at time of response: <%values.xAtResponse%> | Remaining duration: <%values.musicLineDuration%>") / position = (50%, 10%) / erase = false </text> Please work through this until you fully understand what it does, how it works and why. The math is not complicated.
|
|
|
|