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_Jaydev_May2019_twoExperiments.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 ExpPart := 1;
ToolbarConfig();
nBlocks% := 3;
runLength := 600;
'--------------------------------------------------------------------------------
' Toolbar Callbacks
'--------------------------------------------------------------------------------
Func ToolbarIdle%()
' 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
if rep% = (nBlocks%+2) then 'all done
ToolbarQuitExpmt%(); ' All done
Return(1);
endif;
docase
' MISC GAP
case test% = 0 then
SampleKey("0");
goalTime := MaxTime() + 10;
ToolbarSineStop%(); Yield();
ToolbarLightOff%(); Yield();
ToolbarInit%(); Yield();
Yield(5);
runFlash();
test% := 4;
' Switch parameters
if ExpPart = 2 then
ExpPart := 3;
rep% := 0;
testrep% := 0;
sinPhDrum := -90;
sinAmpDrum := 10;
endif
' MISC TEST
case test% = 4 then
SampleKey("4");
goalTime := MaxTime() + testLength;
if prePostNum = 1 then
test% := 0;
prePostNum := prePostNum + 1;
else
test% := 1;
endif
ToolbarSineStart%();
' BLOCK: GAP
case test% = 1 then '
SampleKey("1");
prePostNum := 1;
goalTime := MaxTime() + 10; 'wait 10 seconds for init
ToolbarSineStop%(); Yield();
ToolbarLightOff%(); Yield();
ToolbarInit%(); Yield();
Yield(5);
runFlash();
test% := 2;
' BLOCK: TEST
case test% = 2 then 'FINISHED WAITING, TEST NOW
SampleKey("2");
goalTime := MaxTime() + testLength;
ToolbarSineStart%(); Yield();
testrep% := testrep% + 1;
if testrep% = nTestreps% then
test% := 3;
rep% := rep% + 1;
else
test% := 1;
endif;
' BLOCK: TRAIN
case test% = 3 then 'Finished test, run training
SampleKey("3");
goalTime := MaxTime() + runLength;
if rep% < (nBlocks%+1) then
if ExpPart = 1 then
docase
case expmtMode = 0 or expmtMode = 1 then 'Gain Up and Gain Down
ToolbarLightOn%();
case expmtMode = 2 then 'Vestibular Only
case expmtMode = 3 then 'Dark Resting
ToolbarSineStop%();
endcase;
else
ToolbarLightOn%();
endif
else
ToolbarSineStop%();
endif;
if rep% = nBlocks% then
test% := 0;
if ExpPart = 1 then
ExpPart := 2;
endif
else
test% := 1;
endif;
testrep% := 0;
endcase;
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", "x0|x2|Vestibular|Dark Resting");
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 'x0
sinPhDrum := 90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 1 then 'x2
sinPhDrum := -90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 2 then 'Vestibular
sinPhDrum := -90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
case expmtMode = 3 then 'Dark Resting
sinPhDrum := -90;
sinPhChair := 90;
sinAmpChair := 10;
sinAmpDrum := 10;
endcase;
if testStim > 0 then
ToolbarPulseConfig%()
endif;
SetSequencerValues();
Return(1);
End