Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stimuli and delays will be longer to help saveToCSV save triggers pro… #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
modified code to clean up but same functionality
  • Loading branch information
kylemath committed Jan 17, 2020
commit 2813a0cc76c696610966abf724893f4cc11e0ac0
2 changes: 1 addition & 1 deletion src/components/PageSwitcher/PageSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function PageSwitcher() {
const [status, setStatus] = useState(generalTranslations.connect);

// for picking a new module
const [selected, setSelected] = useState(intro);
const [selected, setSelected] = useState(evoked);
const handleSelectChange = useCallback(value => {
setSelected(value);

Expand Down
117 changes: 62 additions & 55 deletions src/components/PageSwitcher/components/EEGEduEvoked/sketchEvoked.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export default function sketchEvoked (p) {

let x = 0;
const targProp = 0.25;
const stimDuration = 500;
const minISI = 1500;
const maxISI = 2500;

let thisRand = 0.5; //for random choice of target type
let targProp = 0.25;
let isTarget = false;
let ellapsedTime = 0;
let nextDelay = 1000;
Expand All @@ -11,6 +14,7 @@ export default function sketchEvoked (p) {
let targCount = 0;
let waitForStim = 0;


p.setup = function () {
p.createCanvas(300, 300);
p.frameRate(30);
Expand All @@ -22,12 +26,12 @@ export default function sketchEvoked (p) {
}

p.touchStarted = function() {
if (window.touchMarker === 0) {
window.touchMarker = 255;
} else {
window.touchMarker = 0;
if (window.touchMarker === 0) {
window.touchMarker = 255;
} else {
window.touchMarker = 0;
}
}
}

p.draw = function () {

Expand All @@ -37,60 +41,63 @@ export default function sketchEvoked (p) {
window.responseMarker = 0;
}

x = x+1;

if (waitForStim == 1){
if (p.millis() - startTime > 500){
waitForStim = 0;
p.background(255);
ellapsedTime = p.millis()-startTime;
p.fill(255, 255, 255);
window.marker = 0;
p.ellipse(p.width/2, p.height/2, 300);
p.fill(255,0,0);
p.text("+", p.width/2, p.height/2);
}
// how lnog has it been since last target onset
ellapsedTime = p.millis()-startTime;

if (ellapsedTime < stimDuration) {
waitForStim = true;
} else {
p.background(255);
ellapsedTime = p.millis()-startTime;
waitForStim = false;
}

if (ellapsedTime > nextDelay) {
newOnset = true;
// If time to present next stimulus
if (ellapsedTime > nextDelay) {
newOnset = true;
} else {
newOnset = false;
}

// if this draw is the start of a new target onset
if (newOnset) {

// pick a new delay for next trial(1500-2500 ms)
nextDelay = minISI + p.int(p.random() * (maxISI-minISI));
// timer for interstimulus interval
startTime = p.millis();

// log for testing
targCount++;
console.log(targCount, nextDelay)

// Decide if target or standard
thisRand = p.random();
if (thisRand < targProp) { // targets 20% of the time
isTarget = true;
} else {
newOnset = false;
isTarget = false;
}
}

if (newOnset) {
targCount++;
nextDelay = 1500 + p.int(p.random() * 1000);
//console.log(targCount, nextDelay)

startTime = p.millis();
waitForStim = 1;

thisRand = p.random();
if (thisRand < targProp) { // targets 20% of the time
isTarget = true;
} else {
isTarget = false;
}

if (isTarget) {
p.fill(250, 150, 150);
window.marker = 20;
} else {
p.fill(150,150,250);
window.marker = 10;
}

} else { // during time between targets
p.fill(255, 255, 255);
window.marker = 0;
// pick colour and assign marker number
// if stim just came on or staying on
if (waitForStim) {
if (isTarget) {
p.fill(250, 150, 150);
window.marker = 20;
} else {
p.fill(150,150,250);
window.marker = 10;
}
// all other times
} else {
p.fill(255, 255, 255);
window.marker = 0;
}

p.ellipse(p.width/2, p.height/2, 300);
p.fill(255,0,0);
p.text("+", p.width/2, p.height/2);
}.
//actually draw the circle or blank, then fixation
p.background(255);
p.ellipse(p.width/2, p.height/2, 300);
p.fill(255,0,0);
p.text("+", p.width/2, p.height/2);
}
};