https://github.com/RaymondLab/Code
Tip revision: f562b26a59ee1fe18ddbdd35eb072e822e4e0f63 authored by Katie Li on 14 November 2022, 22:02:35 UTC
Matlab files on D241B setup
Matlab files on D241B setup
Tip revision: f562b26
Experiment_Amin_Jan2020_AlternatingStim.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
'--------------------------------------------------------------------------------
ToolbarConfig();
'--------------------------------------------------------------------------------
' 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 test% = 0 then
SampleKey("x");
goalTime := MaxTime() + 5;
ToolbarInit%(); Yield();
test% := 7;
' GAP B
case test% = 7 then
goalTime := MaxTime() + 5;
ToolbarInit%(); Yield();
' Go to Pre/Post or Train/Test Section
docase
' PRE & POST Tests
case expmtLoc% = 1 then
test% := 1;
' TEST/TRAIN Blocks
case expmtLoc% = 2 then
test% := 2;
' If you have already done the test/train blocks, quit instead.
if rep% = (nBlocks%+1) then
ToolbarQuitExpmt%();
Return(1);
endif
endcase
runFlash(); Yield();
ToolbarInit%(); Yield();
' PRE AND POST TEST
case test% = 1 then
SampleKey("1");
SampleKey("X");
goalTime := MaxTime() + testLength;
test% := 0;
' Keep track of how many PRE/POST tests that you've run
prePostNum := prePostNum + 1;
if prePostNum > 3 then
expmtLoc% := 2;
' This check is for the 'T-35' test
if rep% < nBlocks% then
prePostNum := 1;
endif
else
expmtLoc% := 1;
endif
ToolbarSineStart%();
' BLOCK: TRAIN
case test% = 2 then
SampleKey("X");
goalTime := MaxTime() + runLength;
if rep% < (nBlocks%+1) then
ToolbarLightOn%();
SampleKey("N");
endif;
if rep% = (nBlocks%) then
ToolbarLightOff%();
ToolbarSineStop%();
expmtLoc% := 1;
endif;
test% := 3;
' BLOCK: TEST
case test% = 3 then
SampleKey("p");
SampleKey("x");
SampleKey("X");
goalTime := MaxTime() + testLength;
testrep% := testrep% + 1;
ToolbarLightOff%(); Yield();
if testrep% = nTestreps% then
rep% := rep% + 1;
testrep% := 0;
endif;
if rep% = (nBlocks%) then
expmtLoc% := 1;
endif
if rep% = (nBlocks% + 1) then
ToolbarSineStart%();
test% := 9;
else
test% := 0;
endif
case test% = 9 then
ToolbarQuitExpmt%();
Return(1);
endcase;
endif;
endif;
Return(1);
End
'--------------------------------------------------------------------------------
'Configure expmt settings window
'--------------------------------------------------------------------------------
Func ToolbarConfigExpmt%()
DlgCreate("Experiment settings"); 'Start new dialog
DlgInteger(1,"Number of tests per block",1,100,0,0,1); 'set to 0 if not using Chair
DlgReal(2,"Run length (s)",0,5000);
DlgReal(3,"Test length (s)",0,5000);
DlgList(4,"Expmt mode", "x0|x2");
DlgShow(nBlocks%, runLength, testLength, expmtMode);
docase
case expmtMode = 0 then 'x0
sinPhDrum := 90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 1 then 'x2
sinPhDrum := -90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
endcase;
SetSequencerValues();
Return(1);
End