https://github.com/RaymondLab/Code
Tip revision: 9f44957f9f0ed658a3db815890042989af1f673d authored by GracelessGhost on 11 June 2020, 21:49:00 UTC
Add a line to the demo
Add a line to the demo
Tip revision: 9f44957
Experiment_Default_Reversed_With_OKR.s2s
'--------------------------------------------------------------------------------
' IMPORT RIG-SPECIFIC PARAMETERS AND UNIVERSAL PARAMETERS
'--------------------------------------------------------------------------------
#include "C:\\Users\\Public\\RaymondLabCode\\Experiment Protocols\\RigChoice.s2s"
#include "C:\\Users\\Public\\RaymondLabCode\\Experiment Protocols\\Parameters_Universal.s2s"
'--------------------------------------------------------------------------------
' MAIN PROGRAM
'--------------------------------------------------------------------------------
var originalsinAmpChair := sinAmpChair;
ToolbarConfig();
var blockNum := 1;
var expmtIndx := 1;
' 0 = GAP A
' 1 = Gap B
' 2 = pre/post OKR
' 3 = test
' 4 = train
' 5 = Dark Resting
' 9 = quit experiment
const Order%[] := {0, 1, 2,
0, 1, 2,
0, 1, 3,
0, 1, 3,
0, 1, 3,
0, 1, 4, 3,
0, 1, 3,
0, 1, 3,
0, 1, 3,
0, 1, 2,
0, 1, 2,
0, 5,
0, 1, 3,
0, 9};
'--------------------------------------------------------------------------------
' Toolbar Callbacks
'--------------------------------------------------------------------------------
Func ToolbarIdle%()
'This function calls repeatedly whenever nothing else is happening
'if runExmpt=1, it is used to run a full expmt automatically. -HP
'expmtMode: 0=habit, 1=0x, 2=2x, 3=ipsi stim, 4=contra stim
'test: 0=wait, 1=test, 2=train
' Check a valid sampling view is running
var currView := ViewKind();
if currView <> 0 then
return 1;
endif;
' Keep sine wave from drifting
if MaxTime() > (prevTime + 1/sinHzChair) then
if driftFix = 1 then
driftFix%();
endif;
endif;
'If an experiment is running:
if runExpmt% = 1 then
'Check the time. Seconds is the current time - compare it to the goal time of each segment
if MaxTime() > goalTime then
docase
' GAP A
case Order%[expmtIndx] = 0 then
SampleKey("x");
goalTime := MaxTime() + 5;
ToolbarInit%(); Yield();
' GAP B
case Order%[expmtIndx] = 1 then
goalTime := MaxTime() + 5;
ToolbarInit%(); Yield();
runFlash(); Yield();
ToolbarInit%(); Yield();
' pre/post OKR
case Order%[expmtIndx] = 2 then
SampleKey("X");
goalTime := MaxTime() + testLength;
sinAmpChair := 0;
SetSequencerValues();
ToolbarLightOn%(); Yield();
ToolbarSineStart%();
' test
case Order%[expmtIndx] = 3 then
goalTime := MaxTime() + testLength;
if sineOn% then
SampleKey("x");
SampleKey("X");
ToolbarLightOff%();
else
SampleKey("X");
sinAmpChair := originalsinAmpChair;
SetSequencerValues(); Yield();
ToolbarSineStart%();
endif
' To keep variable test-train block amounts
if Order%[expmtIndx-1] = 4 then
blockNum := blockNum + 1;
if blockNum > nBlocks% then
else
expmtIndx := expmtIndx - 4;
endif
endif
' train
case Order%[expmtIndx] = 4 then
SampleKey("X");
goalTime := MaxTime() + runLength;
docase
'3 = ipsi, 4 = contra
case expmtMode = 3 or expmtMode = 4 then
ToolbarStimOn%();
'1 = x0, 2 = x2
case expmtMode = 1 or expmtMode = 2 then
ToolbarLightOn%();
'5 = step
case expmtMode = 5 then
ToolbarStepOff%(); Yield();
ToolbarLightOn%(); Yield();
ToolbarStepOn%();
endcase;
ToolbarSineStart%();
' Dark Resting
case Order%[expmtIndx] = 5 then
SampleKey("X");
goalTime := MaxTime() + (runLength - (testLength + testLength + 10 + 10));
case Order%[expmtIndx] = 9 then
ToolbarQuitExpmt%();
Return(1);
endcase;
expmtIndx := expmtIndx + 1;
endif;
endif;
Return(1);
End
'--------------------------------------------------------------------------------
'Configure expmt settings window
'--------------------------------------------------------------------------------
Func ToolbarConfigExpmt%()
DlgCreate("Experiment settings"); 'Start new dialog
DlgInteger(1,"Number of run-test blocks",0,100,0,0,1);
DlgInteger(2,"Number of tests per block",1,100,0,0,1); 'set to 0 if not using Chair
DlgReal(3,"Run length (s)",0,5000);
DlgReal(4,"Test length (s)",0,5000);
DlgList(5,"Expmt mode", "habit|x0|x2|ipsi|contra|steps");
DlgInteger(6,"Light flash on?)",0,1,0,0,"0|1");
DlgReal(7,"Test stim and bilat (0 or 1)",0,1);
DlgShow(nBlocks%, nTestreps%, runLength, testLength, expmtMode, flashon%, testStim);
docase
case expmtMode = 0 then 'habit
sinPhDrum := 90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 0;
case expmtMode = 1 then 'x0
sinPhDrum := 90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 2 then 'x2
sinPhDrum := -90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 3 then 'ipsi
sinPhChair := 90;
sinAmpDrum := 0;
case expmtMode = 4 then 'contra
sinPhChair := -90;
sinAmpDrum := 0;
case expmtMode = 5 then 'steps
StepConfigWindow%();
endcase;
if testStim > 0 then
ToolbarPulseConfig%()
endif;
SetSequencerValues();
Return(1);
End