pb_vVestExp.m 4.95 KB
Newer Older
1
function pb_vVestExp(varargin)
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% PB_VGENVISEXP
%
% PB_VGENVISEXP(varargin) will generate an EXP-file for a default localization experiment. 
% EXP-files are used for the psychophysical experiments at the
% Biophysics Department of the Donders Institute for Brain, Cognition and
% Behavior of the Radboud University Nijmegen, the Netherlands.
%
% VESTIBULAR STIMULATION PARAMETERS:
%
% Vestibular signals:      1) none, 
%                          2) predict sine, 
%                          3) noise, 
%                          4) turn, 
%                          5) VOR-turnstop.
%
% Azimuth rotation:        VER
% Elevation rotation:      HOR
%
% See also WRITESND, WRITELED, WRITETRG, GENWAV_DEFAULT, etc

% PBToolbox (2018): JJH: j.heckman@donders.ru.nl

   %% Initialization
   %  Clear, empty, default imputs 

   pb_clean;
   disp('>> GENERATING VC EXPERIMENT <<');
29
   pause(.4)
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
30
31
32
33
34
   disp('   ...')

   cfn = 0;

   showexp     = pb_keyval('showexp',varargin,true);
35
36
   expfile     = pb_keyval('fname',varargin,'vestDiracExp.exp'); 
   datdir      = pb_keyval('datdir',varargin,'JJH');
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
37
38
39
40
41
42
43
44
   cdir        = pb_keyval('cdir',varargin,userpath);
   
   cd(cdir);

   %% Vestibular blocks
   
   BD        = 60;                           % block duration in seconds
   
45
46
47
   %% Sine
   block(1).Horizontal  = struct('Amplitude', 0,  'Signal', 2, 'Duration',  BD,   'Frequency',.1);
   block(1).Vertical    = struct('Amplitude', 13, 'Signal', 2, 'Duration',  BD,   'Frequency',.3);
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
48
   
49
50
   block(2).Horizontal  = struct('Amplitude', 0,  'Signal', 2, 'Duration',  BD,   'Frequency',.0);
   block(2).Vertical    = struct('Amplitude', 20, 'Signal', 2, 'Duration',  BD,   'Frequency',.2);
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
51
   
52
53
   block(3).Horizontal  = struct('Amplitude', 0,  'Signal', 2, 'Duration',  BD,   'Frequency',.1);
   block(3).Vertical    = struct('Amplitude', 40, 'Signal', 2, 'Duration',  BD,   'Frequency',.1);
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
54
   
55
   %% Turnstop
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
56
   block(4).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
57
58
59
60
   block(4).Vertical    = struct('Amplitude', 20, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);

   block(5).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   block(5).Vertical    = struct('Amplitude', 30, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
61
62
63
   
   block(6).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   block(6).Vertical    = struct('Amplitude', 40, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);
64
65
66
67
68
69
70
71
72
73
74
75
76
77
   
   block(7).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   block(7).Vertical    = struct('Amplitude', 50, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   
   %% Noise
   
   block(8).Horizontal  = struct('Amplitude', 0,  'Signal', 3, 'Duration',  BD,   'Frequency',.1);
   block(8).Vertical    = struct('Amplitude', 20, 'Signal', 3, 'Duration',  BD,   'Frequency',.1);   

   block(9).Horizontal  = struct('Amplitude', 0,  'Signal', 3, 'Duration',  BD,   'Frequency',.1);
   block(9).Vertical    = struct('Amplitude', 30, 'Signal', 3, 'Duration',  BD,   'Frequency',.1);
   
   block(10).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   block(10).Vertical    = struct('Amplitude', 40, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

   %% Save data somewhere
   writeexp(expfile,datdir,block); 
   % see below, these are helper functions to write an exp-file line by line / stimulus by stimulus

   %% Show the exp-file in Wordpad
   % for PCs
   if showexp
      if ispc
         dos(['"C:\Program Files\Windows NT\Accessories\wordpad.exe" ' expfile ' &']);
      elseif ismac
         system(['open -a TextWrangler ' cd filesep expfile]);
      end
   end
end

function writeexp(expfile,datdir,block)
% Save known trial-configurations in exp-file
%
%  WRITEEXP WRITEEXP(FNAME,DATDIR,THETA,PHI,ID,LEDON)
%
%  WRITEEXP(FNAME,THETA,PHI,ID,LEDON)
%
%  Write exp-file with file-name FNAME.

   expfile		= fcheckext(expfile,'.exp');  % check whether the extension exp is included
   fid         = fopen(expfile,'wt+');         % this is the way to write date to a new file
   
   blocksz     = length(block);     % xnumber of blocks
   
   ITI			= [0 0];    % useless, but required in header
   Rep			= 1;        % we have 0 repetitions, so insert 1...
   Rnd			= 0;        % we randomized ourselves already
   Mtr			= 'n';      % the motor should be on

   pb_vWriteHeader(fid,datdir,ITI,blocksz,0,Rep,Rnd,Mtr,'Lab',5); % helper-function
   
   for iBlock = 1:blocksz
      %  Write blocks
      
      pb_vWriteBlock(fid,iBlock);
      pb_vWriteSignal(fid,block(iBlock));
   end
   fclose(fid);
end
 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
%                                                           %
%       Part of Programmeer Beer Toolbox (PBToolbox)        %
%       Written by: Jesse J. Heckman (2018)                 %
%                                                           %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %