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_HyunGeun_Jan2020_TheFanning.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();
var segIndex := 0;
var nSegs := 10;
var segLength := 45;
var ExpmtType;
var prevExpmtType;
var indx := 1;
'--------------------------------------------------------------------------------
' 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();
segIndex := segIndex + 1;
if segIndex > nSegs then
test% := 9;
else
test% := 1;
endif
' GAP B
case test% = 1 then
goalTime := MaxTime() + 5;
ToolbarInit%(); Yield();
runFlash(); Yield();
ToolbarInit%(); Yield();
test% := 2;
' Block
case test% = 2 then
SampleKey("X");
goalTime := MaxTime() + segLength;
' Get random Number
if indx = 3 then
prevExpmtType := ExpmtType;
while prevExpmtType = ExpmtType do
ExpmtType := Floor(Rand(4, 0));
wend
indx := 1;
endif
indx := indx + 1;
docase
' VORD
case ExpmtType = 0 then
SampleKey("0");
sinAmpChair := 10;
sinAmpDrum := 0;
sinPhDrum := 90;
sinPhChair := 90;
SetSequencerValues();
ToolbarSineStart%();
' OKR
case ExpmtType = 1 then
SampleKey("1");
sinAmpChair := 0;
sinAmpDrum := 10;
sinPhDrum := 90;
sinPhChair := 90;
SetSequencerValues();
ToolbarLightOn%(); Yield();
ToolbarSineStart%();
' x0
case ExpmtType = 2 then
SampleKey("2");
sinAmpChair := 10;
sinAmpDrum := 10;
sinPhDrum := 90;
sinPhChair := 90;
SetSequencerValues();
ToolbarLightOn%(); Yield();
ToolbarSineStart%();
' x2
case ExpmtType = 3 then
SampleKey("3");
sinAmpChair := 10;
sinAmpDrum := 10;
sinPhDrum := -90;
sinPhChair := 90;
SetSequencerValues();
ToolbarLightOn%(); Yield();
ToolbarSineStart%();
endcase
test% := 0;
' Quit Experiment'
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 Segments",0,100,0,0,1);
DlgReal(2,"Segment Length (s)",0,5000);
DlgInteger(3,"Light flash on?",0,1,0,0,"0|1");
DlgShow(nSegs, segLength, flashon%);
SetSequencerValues();
Return(1);
End