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 all commits
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
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
58 changes: 41 additions & 17 deletions src/components/PageSwitcher/components/EEGEduEvoked/sketchEvoked.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
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;
let newOnset = true;
let startTime = 0;
let targCount = 0;
let waitForStim = 0;


p.setup = function () {
p.createCanvas(300, 300);
p.frameRate(60);
p.frameRate(30);
p.noStroke();
};

Expand All @@ -21,59 +26,78 @@ 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 () {


if (p.keyIsPressed === true) {
window.responseMarker = p.keyCode;
} else {
window.responseMarker = 0;
}
p.background(255);
x = x+1;

// how lnog has it been since last target onset
ellapsedTime = p.millis()-startTime;

if (ellapsedTime < stimDuration) {
waitForStim = true;
} else {
waitForStim = false;
}

// 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) {
targCount++;
nextDelay = 500 + p.int(p.random() * 1000);
console.log(targCount, nextDelay)

// 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 {
isTarget = false;
}
}

// 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;
}

} else { // during time between targets
// all other times
} else {
p.fill(255, 255, 255);
window.marker = 0;
}

//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);
}

};