pb_vVORExp.m 4.93 KB
Newer Older
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
1
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function pb_vVORExp(varargin)
% 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 <<');
   disp('   ...')

   cfn = 0;

   showexp     = pb_keyval('showexp',varargin,true);
   expfile     = pb_keyval('fname',varargin,'VOR.exp'); 
   datdir      = pb_keyval('datdir',varargin,'DEFAULT');
   cdir        = pb_keyval('cdir',varargin,userpath);
   
   cd(cdir);

   %% Vestibular blocks
   
   BD        = 60;                           % block duration in seconds
   
44
45
46
   %% 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
47
   
48
49
   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
50
   
51
52
   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
53
   
54
   %% Turnstop
Jesse Heckman's avatar
VOR EXP    
Jesse Heckman committed
55
   block(4).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
56
57
58
59
   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
60
61
62
   
   block(6).Horizontal  = struct('Amplitude', 0,  'Signal', 5, 'Duration',  BD,   'Frequency',.1);
   block(6).Vertical    = struct('Amplitude', 40, 'Signal', 5, 'Duration',  BD,   'Frequency',.1);
63
64
65
66
67
68
69
70
71
72
73
74
75
76
   
   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
77
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

   %% 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)                 %
%                                                           %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %