diff -r b51bf546ca3f -r 1a502830d462 Help and reference data/MAP 1_14 DEVELOPMENT log.doc
Binary file Help and reference data/MAP 1_14 DEVELOPMENT log.doc has changed
diff -r b51bf546ca3f -r 1a502830d462 MAP/MAP1_14.m
--- a/MAP/MAP1_14.m
+++ b/MAP/MAP1_14.m
@@ -313,15 +313,15 @@
 % Fiber types are specified in terms of tauCa
 nANfiberTypes= length(IHCpreSynapseParams.tauCa);
 tauCas= IHCpreSynapseParams.tauCa;
-nChannels= nANfiberTypes*nBFs;
-synapticCa= zeros(nChannels,segmentLength);
+nANchannels= nANfiberTypes*nBFs;
+synapticCa= zeros(nANchannels,segmentLength);
 
 % Calcium control (more calcium, greater release rate)
 ECa=IHCpreSynapseParams.ECa;
 gamma=IHCpreSynapseParams.gamma;
 beta=IHCpreSynapseParams.beta;
 tauM=IHCpreSynapseParams.tauM;
-mICa=zeros(nChannels,segmentLength);
+mICa=zeros(nANchannels,segmentLength);
 GmaxCa=IHCpreSynapseParams.GmaxCa;
 synapse_z= IHCpreSynapseParams.z;
 synapse_power=IHCpreSynapseParams.power;
@@ -329,9 +329,9 @@
 % tauCa vector is established across channels to allow vectorization
 %  (one tauCa per channel). Do not confuse with tauCas (one pre fiber type)
 tauCa=repmat(tauCas, nBFs,1);
-tauCa=reshape(tauCa, nChannels, 1);
+tauCa=reshape(tauCa, nANchannels, 1);
 
-% presynapse startup values (vectors, length:nChannels)
+% presynapse startup values (vectors, length:nANchannels)
 % proportion (0 - 1) of Ca channels open at IHCrestingV
 mICaCurrent=((1+beta^-1 * exp(-gamma*IHCrestingV))^-1)...
     *ones(nBFs*nANfiberTypes,1);
@@ -349,7 +349,7 @@
 % The results computed either for probabiities *or* for spikes (not both)
 % Spikes are necessary if CN and IC are to be computed
 nFibersPerChannel= AN_IHCsynapseParams.numFibers;
-nANfibers= nChannels*nFibersPerChannel;
+nANfibers= nANchannels*nFibersPerChannel;
 AN_refractory_period= AN_IHCsynapseParams.refractory_period;
 
 y=AN_IHCsynapseParams.y;
@@ -359,10 +359,10 @@
 M=round(AN_IHCsynapseParams.M);
 
 % probability            (NB initial 'P' on everything)
-PAN_ydt = repmat(AN_IHCsynapseParams.y*dt, nChannels,1);
-PAN_ldt = repmat(AN_IHCsynapseParams.l*dt, nChannels,1);
-PAN_xdt = repmat(AN_IHCsynapseParams.x*dt, nChannels,1);
-PAN_rdt = repmat(AN_IHCsynapseParams.r*dt, nChannels,1);
+PAN_ydt = repmat(AN_IHCsynapseParams.y*dt, nANchannels,1);
+PAN_ldt = repmat(AN_IHCsynapseParams.l*dt, nANchannels,1);
+PAN_xdt = repmat(AN_IHCsynapseParams.x*dt, nANchannels,1);
+PAN_rdt = repmat(AN_IHCsynapseParams.r*dt, nANchannels,1);
 PAN_rdt_plus_ldt = PAN_rdt + PAN_ldt;
 PAN_M=round(AN_IHCsynapseParams.M);
 
@@ -371,12 +371,12 @@
 Pavailable    = Pcleft*(l+r)./kt0;
 Preprocess    = Pcleft*r/x; % canbe fractional
 
-ANprobability=zeros(nChannels,segmentLength);
-ANprobRateOutput=zeros(nChannels,signalLength);
+ANprobability=zeros(nANchannels,segmentLength);
+ANprobRateOutput=zeros(nANchannels,signalLength);
 lengthAbsRefractoryP= round(AN_refractory_period/dt);
 % special variables for monitoring synaptic cleft (specialists only)
-savePavailableSeg=zeros(nChannels,segmentLength);
-savePavailable=zeros(nChannels,signalLength);
+savePavailableSeg=zeros(nANchannels,segmentLength);
+savePavailable=zeros(nANchannels,signalLength);
 
 % spikes     % !  !  !    ! !        !   !  !
 lengthAbsRefractory= round(AN_refractory_period/ANdt);
@@ -406,27 +406,39 @@
 %% CN (first brain stem nucleus - could be any subdivision of CN)
 % Input to a CN neuorn is a random selection of AN fibers within a channel
 %  The number of AN fibers used is ANfibersFanInToCN
-ANfibersFanInToCN=MacGregorMultiParams.fibersPerNeuron;
-nCNneuronsPerChannel=MacGregorMultiParams.nNeuronsPerBF;
 % CNtauGk (Potassium time constant) determines the rate of firing of
 %  the unit when driven hard by a DC input (not normally >350 sp/s)
-CNtauGk=MacGregorMultiParams.tauGk;
+% If there is more than one value, everything is replicated accordingly
+
 ANavailableFibersPerChan=AN_IHCsynapseParams.numFibers;
-nCNneurons=nCNneuronsPerChannel*nChannels;
-% nCNneuronsPerFiberType= nCNneurons/nANfiberTypes;
+ANfibersFanInToCN=MacGregorMultiParams.fibersPerNeuron;
 
+CNtauGk=MacGregorMultiParams.tauGk; % row vector of CN types (by tauGk)
+nCNtauGk=length(CNtauGk);
+
+% the total number of 'channels' is now greater
+nCNchannels=nANchannels*nCNtauGk;
+
+nCNneuronsPerChannel=MacGregorMultiParams.nNeuronsPerBF;
+tauGk=repmat(CNtauGk, nCNneuronsPerChannel,1);
+tauGk=reshape(tauGk,nCNneuronsPerChannel*nCNtauGk,1);
+
+% Now the number of neurons has been increased
+nCNneurons=nCNneuronsPerChannel*nCNchannels;
 CNmembranePotential=zeros(nCNneurons,reducedSegmentLength);
 
 % establish which ANfibers (by name) feed into which CN nuerons
-CNinputfiberLists=zeros(nChannels*nCNneuronsPerChannel, ANfibersFanInToCN);
+CNinputfiberLists=zeros(nANchannels*nCNneuronsPerChannel, ANfibersFanInToCN);
 unitNo=1;
-for ch=1:nChannels
+for ch=1:nANchannels
     % Each channel contains a number of units =length(listOfFanInValues)
     for idx=1:nCNneuronsPerChannel
-        fibersUsed=(ch-1)*ANavailableFibersPerChan + ...
-            ceil(rand(1,ANfibersFanInToCN)* ANavailableFibersPerChan);
-        CNinputfiberLists(unitNo,:)=fibersUsed;
-        unitNo=unitNo+1;
+        for idx2=1:nCNtauGk
+            fibersUsed=(ch-1)*ANavailableFibersPerChan + ...
+                ceil(rand(1,ANfibersFanInToCN)* ANavailableFibersPerChan);
+            CNinputfiberLists(unitNo,:)=fibersUsed;
+            unitNo=unitNo+1;
+        end
     end
 end
 
@@ -468,14 +480,14 @@
 CNtimeSinceLastSpike=zeros(nCNneurons,1);
 % tauGk is the main distinction between neurons
 %  in fact they are all the same in the standard model
-tauGk=repmat(CNtauGk,nChannels*nCNneuronsPerChannel,1);
+tauGk=repmat(tauGk,nANchannels,1);
 
-CN_PSTH=zeros(nChannels,reducedSegmentLength);
 CNoutput=false(nCNneurons,reducedSignalLength);
 
 
 %% MacGregor (IC - second nucleus) --------
-nICcells=nChannels;  % one cell per channel
+nICcells=nANchannels*nCNtauGk;  % one cell per channel
+CN_PSTH=zeros(nICcells ,reducedSegmentLength);
 
 ICspikeWidth=0.00015;   % this may need revisiting
 epochsPerSpike=round(ICspikeWidth/ANdt);
@@ -515,7 +527,7 @@
 ICtrailingAlphas=zeros(nICcells, length(IC_CNalphaFunction));
 
 ICfiberTypeRates=zeros(nANfiberTypes,reducedSignalLength);
-ICoutput=false(nChannels,reducedSignalLength);
+ICoutput=false(nICcells,reducedSignalLength);
 
 ICmembranePotential=zeros(nICcells,reducedSegmentLength);
 ICmembraneOutput=zeros(nICcells,signalLength);
@@ -799,7 +811,7 @@
                 % releaseProb is the release probability per channel
                 %  but each channel has many synapses
                 releaseProb=repmat(releaseProb',nFibersPerChannel,1);
-                releaseProb=reshape(releaseProb, nFibersPerChannel*nChannels,1);
+                releaseProb=reshape(releaseProb, nFibersPerChannel*nANchannels,1);
 
                 % AN_available=round(AN_available); % vesicles must be integer, (?needed)
                 M_q=AN_M- AN_available;     % number of missing vesicles
@@ -883,7 +895,7 @@
             % Create the dendritic current for that neuron
             % First get input spikes to this neuron
             synapseNo=1;
-            for ch=1:nChannels
+            for ch=1:nCNchannels
                 for idx=1:nCNneuronsPerChannel
                     % determine candidate fibers for this unit
                     fibersUsed=CNinputfiberLists(synapseNo,:);
@@ -992,7 +1004,8 @@
             %% IC ----------------------------------------------
                 %  MacGregor or some other second order neurons
 
-                % combine CN neurons in same channel, i.e. same BF & same tauCa
+                % combine CN neurons in same channel, 
+                %  i.e. same BF & same tauCa
                 %  to generate inputs to single IC unit
                 channelNo=0;
                 for idx=1:nCNneuronsPerChannel:nCNneurons-nCNneuronsPerChannel+1;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/expGUI_MT.m
--- a/multithreshold 1.46/expGUI_MT.m	
+++ b/multithreshold 1.46/expGUI_MT.m	
@@ -85,38 +85,37 @@
 % Get default command line output from handles structure
 initializeGUI(handles)
 varargout{1} = handles.output;
-setLocationOfGUIs(handles)
 
-function setLocationOfGUIs(handles)
-global checkForPreviousGUI  % holds screen positioning across repeated calls
-scrnsize=get(0,'screensize');
-checkForPreviousGUI=[];
-% if isstruct(checkForPreviousGUI)...
-%         && checkForPreviousGUI.GUIalreadyStarted==1 ...
-%         && isfield(checkForPreviousGUI,'GUIposition')
-%     set(handles.figure1,'position',checkForPreviousGUI.GUIposition)
-% else
-%     % relocate the GUI only if this is the first time of use
-%     set(0, 'units','pixels')
-%     % occupies top to bottom of screen but only 60% width
-%     % [left bottom width height]
-%     firstPos=[0.01*scrnsize(4) 0.03*scrnsize(3) 0.6*scrnsize(3) 0.92*scrnsize(4)];
-%     firstPos=[4 0.045*scrnsize(4) 0.6*scrnsize(3) 0.93*scrnsize(4)];
-%     set(handles.figure1, 'units','pixels')
-%     set(handles.figure1,'position',firstPos)
-%     checkForPreviousGUI.GUIalreadyStarted=1;
-%     checkForPreviousGUI.GUIposition=firstPos;
-% end
-set(handles.figure1,'color',[.871 .961 .996])
-set(handles.figure1,'name', pwd)
-
-% MAP model figure; sits alongside GUI if requested
-figure(99)
-% [left bottom width height]
-MAPpos=[0.615*scrnsize(3) 0.05*scrnsize(4) 0.15*scrnsize(3) 0.85*scrnsize(4)];
-% visible only on request.
-set(gcf,'position',MAPpos , 'visible','off')
-
+% function setLocationOfGUIs(handles)
+% global checkForPreviousGUI  % holds screen positioning across repeated calls
+% scrnsize=get(0,'screensize');
+% checkForPreviousGUI=[];
+% % if isstruct(checkForPreviousGUI)...
+% %         && checkForPreviousGUI.GUIalreadyStarted==1 ...
+% %         && isfield(checkForPreviousGUI,'GUIposition')
+% %     set(handles.figure1,'position',checkForPreviousGUI.GUIposition)
+% % else
+% %     % relocate the GUI only if this is the first time of use
+% %     set(0, 'units','pixels')
+% %     % occupies top to bottom of screen but only 60% width
+% %     % [left bottom width height]
+% %     firstPos=[0.01*scrnsize(4) 0.03*scrnsize(3) 0.6*scrnsize(3) 0.92*scrnsize(4)];
+% %     firstPos=[4 0.045*scrnsize(4) 0.6*scrnsize(3) 0.93*scrnsize(4)];
+% %     set(handles.figure1, 'units','pixels')
+% %     set(handles.figure1,'position',firstPos)
+% %     checkForPreviousGUI.GUIalreadyStarted=1;
+% %     checkForPreviousGUI.GUIposition=firstPos;
+% % end
+% set(handles.figure1,'color',[.871 .961 .996])
+% set(handles.figure1,'name', pwd)
+% 
+% % MAP model figure; sits alongside GUI if requested
+% figure(99)
+% % [left bottom width height]
+% MAPpos=[0.615*scrnsize(3) 0.05*scrnsize(4) 0.15*scrnsize(3) 0.85*scrnsize(4)];
+% % visible only on request.
+% set(gcf,'position',MAPpos , 'visible','off')
+% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -128,19 +127,12 @@
 global targetTypes maskerTypes backgroundTypes
 global variableNames paradigmNames threshEstNames  cueNames
 
-% dbstop if error         % allow for debugging and user error reporting
-% dbstop if warning
-
-% specify structure fields for pretty automatic printing
-% It also initialises some simple variables
+% Specify order of fields in main structures
+% identify as empty values or empty strings only
 orderGlobals
 
-addpath ('paradigms')   % preset paradigm informations is stored here
-% filesep is usd to be compatible with other operating systems
-% addpath (['..' filesep 'modules'], ['..' filesep 'utilities'], ...
-%     ['..' filesep 'parameterStore'],  ['..' filesep 'wavFileStore'],...
-%     ['..' filesep 'testPrograms'])
-addpath (['..' filesep 'testPrograms'])
+addpath ('paradigms')   %paradigm informations is stored here
+addpath (['..' filesep 'testPrograms']) % model physiology tests
 
 % specify all variables that  need to be set on the GUI
 variableNames={'stimulusDelay','maskerDuration','maskerLevel',...
@@ -149,20 +141,14 @@
     'cueTestDifference', 'WRVstartValues', 'WRVsteps', 'WRVlimits'};
 
 % Variable variables
-% (specifies paradigm paramaters that can changed on a 'between runs' basis)
-% make them options in the two between runs variable menus
-% NB 'numOHIOtones' is used only to solve a problem; it should not be
-% selected manually
+%  (names of variable that can changed between runs)
 betweenRunsVariables={'stimulusDelay','maskerDuration','maskerLevel',...
     'maskerRelativeFrequency','targetFrequency', 'gapDuration',...
     'targetDuration','targetLevel','numOHIOtones'};
+% populate the 'between runs variable' menus
 set(handles.popupmenuVaryParameter1,'string',betweenRunsVariables)
 set(handles.popupmenuVaryParameter2,'string',betweenRunsVariables)
 
-% NB 'Warning: popupmenu control requires a scalar Value'
-% indicates that an inappropriate 'value' is being set.
-% when testing for this, always clear the GUI before running
-
 % Trial presentation order - randomize at startup
 presentationOrderNames={'randomize within blocks', 'fixed sequence', ...
     'randomize across blocks'};
@@ -184,13 +170,14 @@
     '16TalkerBabble','8TalkerBabble','4TalkerBabble',...
     '4TalkerReversedBabble','2TalkerBabble','1TalkerBabble'};
 set(handles.popupmenuBackgroundType, 'string', backgroundTypes);
-set(handles.editBackgroundLevel,'string',...
-    num2str(stimulusParameters.backgroundLevel))
+set(handles.editBackgroundLevel,'string', '0')
 
 % Establish available paradigms by scanning paradigms folder
 paradigmNames= what('paradigms');
-paradigmNames=paradigmNames.m;       % m files only
-for i=1:length(paradigmNames), paradigmNames{i}=paradigmNames{i}(10:end-2); end
+paradigmNames= paradigmNames.m; % select m files only
+for i=1:length(paradigmNames)   % strip off file extension
+    paradigmNames{i}=paradigmNames{i}(10:end-2); 
+end
 set(handles.popupmenuParadigm,'string', paradigmNames)
 
 % startup paradigm, 'training' (could be anywhere on the list)
@@ -199,7 +186,7 @@
 if ~isempty(idx)
     set(handles.popupmenuParadigm,'value', idx)
 else
-    % training paradigm is always the startup paradigm
+    % training paradigm must exist
     error(['expGUI_MT\initializeGUI: No ' startupParadigm...
         ' paradigm found in paradigms folder'])
 end
@@ -213,13 +200,15 @@
 set(handles.popupmenuEar,'value', defaultOption)    % 'left' is deafult
 set(handles.pushbuttonSingleShot, 'visible', 'off') % use only for MAP
 
-% masker phase box- value must be set in paradigm
+% phase
 phaseOptions={'sin','cos','alt','rand'};
 set(handles.popupmenuPhase,'string', phaseOptions)
+set(handles.popupmenuPhase,'value', 1)
 
 % Cue
 cueNames={'cued', 'noCue'};
 set(handles.popupmenuCueNoCue, 'string', cueNames);
+set(handles.popupmenuCueNoCue, 'value', 1);
 
 % threshold assessment method - value must be set in paradigm
 threshEstNames={'oneIntervalUpDown', 'MaxLikelihood', ...
@@ -265,7 +254,7 @@
 
 % message box
 set(handles.textMSG,'backgroundcolor', 'w', 'ForegroundColor', 'b', 'string', '')
-set(handles.editMsgFont,'string','7')
+set(handles.editMsgFont,'string','10')
 set(handles.editSubjectFont,'string','14')
 
 % default psychometric bin size and logistic slopes
@@ -328,14 +317,17 @@
 end
 rmpath ('paradigms')
 
-switch experiment.paradigm
-    % identify masker free paradigms
-    case {'training', 'discomfort','absThreshold', 'absThreshold_8',...
-            'absThreshold_16','TENtest', 'threshold_duration','SRT'...
-            'paradigm_thr_IFMC'}
-        experiment.maskerInUse=0;
-    otherwise
-        experiment.maskerInUse=1;
+if ~isfield(experiment,'maskerInUse')
+    error('selected paradigm does not specify if masker is used')
+end
+
+
+if ~experiment.maskerInUse
+    stimulusParameters.maskerType='tone';
+    stimulusParameters.maskerPhase='sin';
+    stimulusParameters.maskerDuration=0.0;
+    stimulusParameters.maskerLevel= -50;
+    stimulusParameters.maskerRelativeFrequency= 1 ;
 end
 
 % if a variable is subject to change, specify list of values here
@@ -348,8 +340,15 @@
 eval (cmd);
 
 % establish popup menus on the basis of the paradigm file
-set(handles.popupmenuRandomize,'value', betweenRuns.randomizeSequence)
-set(handles.popupmenuPhase,'string', stimulusParameters.maskerPhase)
+% set(handles.popupmenuRandomize,'value', betweenRuns.randomizeSequence)
+sequenceOptions=get(handles.popupmenuRandomize,'string');
+idx=find(strcmp(betweenRuns.randomizeSequence, sequenceOptions)==1);
+set(handles.popupmenuRandomize,'value', idx)
+
+phaseOptions=get(handles.popupmenuPhase,'string');
+idx=find(strcmp(stimulusParameters.maskerPhase, phaseOptions)==1);
+set(handles.popupmenuPhase,'value', idx)
+
 if stimulusParameters.includeCue
     set(handles.popupmenuCueNoCue,'value', 1)
 else
@@ -614,6 +613,8 @@
 global experiment betweenRuns paradigmNames errormsg
 checkForPreviousGUI.GUIposition=get(handles.figure1,'position');
 experiment.singleShot=0;
+experiment.stop=0;
+
 switch experiment.paradigm
     case 'profile'
         %% special option for two successive and linked measurements
@@ -784,6 +785,8 @@
             'MAPmodelSingleCh', 'MAPmodelListen'}
         % MAPmodel writes forced parameter settings to the screen
         %  so that they can be read from there
+        % {'randomize within blocks', 'fixed sequence',...
+        %  'randomize across blocks'}
         set(handles.popupmenuRandomize,'value',2)       % fixed sequence
         set(handles.editstimulusDelay,'string','0.01')  % no stimulus delay
         stimulusParameters.includeCue=0;                % no cue for MAP
@@ -1301,8 +1304,8 @@
 experiment.threshEstMethod=	'';
 experiment.functionEstMethod=	'';
 experiment.psyBinWidth=	[];
-experiment.maxLogisticK=2;
-experiment.numPossLogisticK=100;
+experiment.maxLogisticK=[];
+experiment.numPossLogisticK=[];
 experiment.possLogSlopes=	[];
 experiment.meanSearchStep=	[];
 experiment.psyFunSlope=	[];
@@ -1311,7 +1314,7 @@
 experiment.buttonBoxType=	'';
 experiment.buttonBoxStatus=	'';
 experiment.status=	'';
-experiment.stop=	0;
+experiment.stop=	[];
 experiment.pleaseRepeat=	[];
 experiment.justInitialized=[];
 
@@ -1334,8 +1337,6 @@
 betweenRuns.randomizeSequence=[];
 betweenRuns.timeNow=	[];
 betweenRuns.runNumber=	[];
-% betweenRuns.variableCount1=	[];
-% betweenRuns.variableCount2=	[];
 betweenRuns.thresholds=	[];
 betweenRuns.forceThresholds=	[];
 betweenRuns.observationCount=	[];
@@ -1357,8 +1358,8 @@
 
 withinRuns=[];
 withinRuns.trialNumber=[];
-withinRuns.nowInPhase2=0;
-withinRuns.beginningOfPhase2=0;
+withinRuns.nowInPhase2=[];
+withinRuns.beginningOfPhase2=[];
 withinRuns.variableValue=[];
 withinRuns.direction='';
 withinRuns.peaks=[];
@@ -1375,7 +1376,7 @@
 withinRuns.caughtOut=[];
 withinRuns.catchTrialCount=[];
 withinRuns.wrongButton=	[];
-withinRuns.babblePlaying=0;
+withinRuns.babblePlaying=[];
 
 % --- Executes on selection change in popupmenuBackgroundType.
 function popupmenuBackgroundType_Callback(hObject, eventdata, handles)
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/nextStimulus.m
--- a/multithreshold 1.46/nextStimulus.m	
+++ b/multithreshold 1.46/nextStimulus.m	
@@ -560,7 +560,7 @@
 duration(3)=precedingSilence+maskerDuration+ terminalSilence;
 globalStimParams.overallDuration=max(duration);
 globalStimParams.nSignalPoints=...
-    round(globalStimParams.overallDuration/globalStimParams.dt);
+    round(globalStimParams.overallDuration*globalStimParams.FS);
 
 %           ----------------------------------------------cue stimulus
 % cue masker
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_GOM.m
--- a/multithreshold 1.46/paradigms/paradigm_GOM.m	
+++ b/multithreshold 1.46/paradigms/paradigm_GOM.m	
@@ -16,8 +16,8 @@
 betweenRuns.variableList1=25: 5: 70;
 betweenRuns.variableName2='maskerRelativeFrequency';
 betweenRuns.variableList2=[1 0.5];
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
+experiment.maskerInUse=1;
 stimulusParameters.maskerType='tone';
 stimulusParameters.maskerPhase='sin';
 stimulusParameters.maskerDuration=0.104;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_IFMC.m
--- a/multithreshold 1.46/paradigms/paradigm_IFMC.m	
+++ b/multithreshold 1.46/paradigms/paradigm_IFMC.m	
@@ -16,8 +16,10 @@
 betweenRuns.variableName2='targetFrequency';
 % keep old list of target frequencies
 betweenRuns.variableList2=str2num(get(handles.edittargetFrequency,'string'));
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
+experiment.maskerInUse=1;
+stimulusParameters.maskerType='tone';
+stimulusParameters.maskerPhase='sin';
 stimulusParameters.maskerDuration=0.108;
 stimulusParameters.maskerLevel=stimulusParameters.WRVstartValues(1);
 stimulusParameters.maskerRelativeFrequency=betweenRuns.variableList1;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_SRT.m
--- a/multithreshold 1.46/paradigms/paradigm_SRT.m	
+++ b/multithreshold 1.46/paradigms/paradigm_SRT.m	
@@ -28,20 +28,12 @@
 betweenRuns.variableList1=1000;
 betweenRuns.variableName2='maskerDuration';
 betweenRuns.variableList2=0.1 ;
-% 1='fixed sequence', 2='randomize within blocks', 3='randomize across
-% blocks'
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
 % delay > masker > gap > target
-
 stimulusParameters.stimulusDelay=0.3;
 
 % maskerTypes={'tone','noise', 'pinkNoise','TEN','whiteNoise'};
-stimulusParameters.maskerType='tone';
-stimulusParameters.maskerPhase='sin';
-stimulusParameters.maskerDuration=0.0;
-stimulusParameters.maskerLevel= -50;
-stimulusParameters.maskerRelativeFrequency= 1 ;  % not used
+experiment.maskerInUse=0;
 
 stimulusParameters.gapDuration=0.0;
 
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_TENtest.m
--- a/multithreshold 1.46/paradigms/paradigm_TENtest.m	
+++ b/multithreshold 1.46/paradigms/paradigm_TENtest.m	
@@ -12,7 +12,8 @@
 betweenRuns.variableList1=[250 500 1000 2000 4000 8000 ];
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2= 0.25;
-betweenRuns.randomizeSequence=1; % 'random sequence'
+
+experiment.maskerInUse=0;
 
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_TMC.m
--- a/multithreshold 1.46/paradigms/paradigm_TMC.m	
+++ b/multithreshold 1.46/paradigms/paradigm_TMC.m	
@@ -17,8 +17,8 @@
 betweenRuns.variableName2='targetFrequency';
 % retain existing targetFrequencies
 betweenRuns.variableList2=str2num(get(handles.edittargetFrequency,'string'));
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
+experiment.maskerInUse=1;
 stimulusParameters.maskerType='tone';
 stimulusParameters.maskerPhase='sin';
 stimulusParameters.maskerDuration=0.108;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_absThreshold.m
--- a/multithreshold 1.46/paradigms/paradigm_absThreshold.m	
+++ b/multithreshold 1.46/paradigms/paradigm_absThreshold.m	
@@ -8,6 +8,8 @@
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2= 0.25;
 
+experiment.maskerInUse=0;
+
 stimulusParameters.targetFrequency=betweenRuns.variableList1;
 stimulusParameters.targetDuration=betweenRuns.variableList2;
 stimulusParameters.targetLevel=stimulusParameters.WRVstartValues(1);
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_absThreshold_16.m
--- a/multithreshold 1.46/paradigms/paradigm_absThreshold_16.m	
+++ b/multithreshold 1.46/paradigms/paradigm_absThreshold_16.m	
@@ -8,10 +8,8 @@
 betweenRuns.variableList1=str2num(get(handles.edittargetFrequency,'string'));
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2=0.016;
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
-% delay > masker > gap > target
-
+experiment.maskerInUse=0;
 
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_discomfort.m
--- a/multithreshold 1.46/paradigms/paradigm_discomfort.m	
+++ b/multithreshold 1.46/paradigms/paradigm_discomfort.m	
@@ -12,10 +12,13 @@
 betweenRuns.variableList1=[1000];
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2=0.5 ;
-betweenRuns.randomizeSequence=2; % 'fixed sequence'
+% 'randomize within blocks', 'fixed sequence', 'randomize across blocks'
+betweenRuns.randomizeSequence='fixed sequence'; 
 
 stimulusParameters.stimulusDelay=0;
 
+experiment.maskerInUse=0;
+
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
 stimulusParameters.targetFrequency=1000;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_forwardMasking.m
--- a/multithreshold 1.46/paradigms/paradigm_forwardMasking.m	
+++ b/multithreshold 1.46/paradigms/paradigm_forwardMasking.m	
@@ -11,13 +11,13 @@
 betweenRuns.variableName1='gapDuration';
 betweenRuns.variableList1=[.005 0.01 0.02 0.04];
 betweenRuns.variableName2='maskerLevel';
-betweenRuns.variableList2=[20 40 60 80];
-betweenRuns.randomizeSequence=1; % 'random sequence'
+betweenRuns.variableList2=[80 60 40 20];
 
+experiment.maskerInUse=1;
 stimulusParameters.maskerType='tone';
-stimulusParameters.maskerPhase='sin';
+stimulusParameters.maskerPhase='cos';
 stimulusParameters.maskerDuration=0.108;
-stimulusParameters.maskerLevel=betweenRuns.variableList2;
+stimulusParameters.maskerLevel=20;
 stimulusParameters.maskerRelativeFrequency=1;
 
 stimulusParameters.gapDuration=betweenRuns.variableList1;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_overShoot.m
--- a/multithreshold 1.46/paradigms/paradigm_overShoot.m	
+++ b/multithreshold 1.46/paradigms/paradigm_overShoot.m	
@@ -1,5 +1,5 @@
 function paradigm_overShoot(handles)
-global stimulusParameters  betweenRuns
+global stimulusParameters  betweenRuns experiment
 
 paradigm_training(handles) % default
 
@@ -14,11 +14,11 @@
 % betweenRuns.variableList1=[-.350 -.238 -.213 -.180 -.160 -.100 -.040 -.020 0 .010 .040 .140];
 betweenRuns.variableName2='maskerLevel';
 betweenRuns.variableList2=50;
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
 % delay > masker > gap > target
 stimulusParameters.stimulusDelay=0.3;
 
+experiment.maskerInUse=1;
 stimulusParameters.maskerType='tone';
 stimulusParameters.maskerPhase='sin';
 stimulusParameters.maskerDuration=0.4;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_profile.m
--- a/multithreshold 1.46/paradigms/paradigm_profile.m	
+++ b/multithreshold 1.46/paradigms/paradigm_profile.m	
@@ -7,10 +7,6 @@
 betweenRuns.variableList1=[250 500 1000 2000 4000 8000 ];
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2=0.016;
-betweenRuns.randomizeSequence=1; % 'random sequence'
-
-% delay > masker > gap > target
-
 
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_psychometric.m
--- a/multithreshold 1.46/paradigms/paradigm_psychometric.m	
+++ b/multithreshold 1.46/paradigms/paradigm_psychometric.m	
@@ -15,7 +15,8 @@
 betweenRuns.variableList1=1000.01:0.01:1000.05;
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2=0.1 ;
-betweenRuns.randomizeSequence=1; % 'random sequence'
+
+experiment.maskerInUse=0;
 
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_threshold_duration.m
--- a/multithreshold 1.46/paradigms/paradigm_threshold_duration.m	
+++ b/multithreshold 1.46/paradigms/paradigm_threshold_duration.m	
@@ -12,7 +12,8 @@
 betweenRuns.variableList1=[ .016 .032 .064 .128 .256 .512];
 betweenRuns.variableName2='targetFrequency';
 betweenRuns.variableList2=1000;
-betweenRuns.randomizeSequence=1; % 'random sequence'
+
+experiment.maskerInUse=0;
 
 stimulusParameters.targetType='tone';
 stimulusParameters.targetPhase='sin';
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_training.m
--- a/multithreshold 1.46/paradigms/paradigm_training.m	
+++ b/multithreshold 1.46/paradigms/paradigm_training.m	
@@ -30,26 +30,26 @@
 betweenRuns.variableList1=1000;
 betweenRuns.variableName2='targetDuration';
 betweenRuns.variableList2=0.1 ;
-% 1='fixed sequence', 2='randomize within blocks', 3='randomize across
-% blocks'
-betweenRuns.randomizeSequence=1; % 'random sequence'
+% 'randomize within blocks', 'fixed sequence', 'randomize across blocks'
+betweenRuns.randomizeSequence='randomize within blocks'; 
 
 % delay > masker > gap > target
 
 stimulusParameters.stimulusDelay=0.3;
 
 % maskerTypes={'tone','noise', 'pinkNoise','TEN','whiteNoise'};
+experiment.maskerInUse=0;
 stimulusParameters.maskerType='tone';
-stimulusParameters.maskerPhase='sin';
+stimulusParameters.maskerPhase='cos';
 stimulusParameters.maskerDuration=0.0;
 stimulusParameters.maskerLevel= -50;
-stimulusParameters.maskerRelativeFrequency= 1 ;  % not used
+stimulusParameters.maskerRelativeFrequency= 1 ; 
 
 stimulusParameters.gapDuration=0.0;
 
 % targetTypes={'tone','noise', 'pinkNoise','whiteNoise','OHIO'};
 stimulusParameters.targetType='tone';
-stimulusParameters.targetPhase='sin';
+stimulusParameters.targetPhase='cos'; %{'sin','cos','alt','rand'}
 stimulusParameters.targetFrequency=1000;
 stimulusParameters.targetDuration=0.1;
 stimulusParameters.targetLevel=stimulusParameters.WRVstartValues(1);
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/paradigms/paradigm_trainingIFMC.m
--- a/multithreshold 1.46/paradigms/paradigm_trainingIFMC.m	
+++ b/multithreshold 1.46/paradigms/paradigm_trainingIFMC.m	
@@ -17,8 +17,8 @@
 betweenRuns.variableName2='targetFrequency';
 % keep old list of target frequencies
 betweenRuns.variableList2=str2num(get(handles.edittargetFrequency,'string'));
-betweenRuns.randomizeSequence=1; % 'random sequence'
 
+experiment.maskerInUse=1;
 stimulusParameters.maskerType='tone';
 stimulusParameters.maskerPhase='sin';
 stimulusParameters.maskerDuration=0.108;
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/profile.mat
Binary file multithreshold 1.46/profile.mat has changed
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/savedData/mostRecentResults.mat
Binary file multithreshold 1.46/savedData/mostRecentResults.mat has changed
diff -r b51bf546ca3f -r 1a502830d462 multithreshold 1.46/subjGUI_MT.m
--- a/multithreshold 1.46/subjGUI_MT.m	
+++ b/multithreshold 1.46/subjGUI_MT.m	
@@ -200,6 +200,8 @@
 % Create two sequence vectors to represent the sequence of var1 and var2
 % values. 'var1' changes most rapidly.
 switch betweenRuns.randomizeSequence
+    % {'randomize within blocks', 'fixed sequence',...
+    %  'randomize across blocks'}
     case 'fixed sequence'
         var1Sequence=repmat(betweenRuns.variableList1, 1,nVar2);
         var2Sequence=reshape(repmat(betweenRuns.variableList2, ...
diff -r b51bf546ca3f -r 1a502830d462 parameterStore/MAPparamsNormalIC.m
--- /dev/null
+++ b/parameterStore/MAPparamsNormalIC.m
@@ -0,0 +1,302 @@
+function method=MAPparamsNormalIC ...
+    (BFlist, sampleRate, showParams, paramChanges)
+% MAPparams<> establishes a complete set of MAP parameters
+% Parameter file names must be of the form <MAPparams> <name>
+%
+% input arguments
+%  BFlist     (optional) specifies the desired list of channel BFs
+%    otherwise defaults set below
+%  sampleRate (optional), default is 50000.
+%  showParams (optional) =1 prints out the complete set of parameters
+% output argument
+%  method passes a miscelleny of values
+
+global inputStimulusParams OMEParams DRNLParams IHC_cilia_RPParams
+global IHC_VResp_VivoParams IHCpreSynapseParams  AN_IHCsynapseParams
+global MacGregorParams MacGregorMultiParams  filteredSACFParams
+global experiment % used by calls from multiThreshold only
+
+
+currentFile=mfilename;                      % i.e. the name of this mfile
+method.parameterSource=currentFile(10:end); % for the record
+
+efferentDelay=0.010;
+method.segmentDuration=efferentDelay;
+
+if nargin<3, showParams=0; end
+if nargin<2, sampleRate=50000; end
+if nargin<1 || BFlist(1)<0 % if BFlist= -1, set BFlist to default
+    lowestBF=250; 	highestBF= 8000; 	numChannels=21;
+    % 21 chs (250-8k)includes BFs at 250 500 1000 2000 4000 8000
+    BFlist=round(logspace(log10(lowestBF),log10(highestBF),numChannels));
+end
+% BFlist=1000;
+
+% preserve for backward campatibility
+method.nonlinCF=BFlist; 
+method.dt=1/sampleRate; 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% set  model parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%  #1 inputStimulus
+inputStimulusParams=[];
+inputStimulusParams.sampleRate= sampleRate; 
+
+%%  #2 outerMiddleEar
+OMEParams=[];  % clear the structure first
+% outer ear resonances band pass filter  [gain lp order  hp]
+OMEParams.externalResonanceFilters=      [ 10 1 1000 4000];
+                                       
+% highpass stapes filter  
+%  Huber gives 2e-9 m at 80 dB and 1 kHz (2e-13 at 0 dB SPL)
+OMEParams.OMEstapesLPcutoff= 1000;
+OMEParams.stapesScalar=	     45e-9;
+
+% Acoustic reflex: maximum attenuation should be around 25 dB Price (1966)
+% i.e. a minimum ratio of 0.056.
+% 'spikes' model: AR based on brainstem spiking activity (LSR)
+OMEParams.rateToAttenuationFactor=0.006;   % * N(all ICspikes)
+% OMEParams.rateToAttenuationFactor=0;   % * N(all ICspikes)
+
+% 'probability model': Ar based on AN firing probabilities (LSR)
+OMEParams.rateToAttenuationFactorProb=0.01;% * N(all ANrates)
+% OMEParams.rateToAttenuationFactorProb=0;% * N(all ANrates)
+
+% asymptote should be around 100-200 ms
+OMEParams.ARtau=.05; % AR smoothing function
+% delay must be longer than the segment length
+OMEParams.ARdelay=efferentDelay;  %Moss gives 8.5 ms latency
+OMEParams.ARrateThreshold=0;
+
+%%  #3 DRNL
+DRNLParams=[];  % clear the structure first
+DRNLParams.BFlist=BFlist;
+
+% DRNL nonlinear path
+DRNLParams.a=5e4;     % DRNL.a=0 means no OHCs (no nonlinear path)
+DRNLParams.a=2e4;     % DRNL.a=0 means no OHCs (no nonlinear path)
+
+DRNLParams.b=8e-6;    % *compression threshold raised compression
+% DRNLParams.b=1;    % b=1 means no compression
+
+DRNLParams.c=0.2;     % compression exponent
+% nonlinear filters
+DRNLParams.nonlinCFs=BFlist;
+DRNLParams.nonlinOrder=	3;           % order of nonlinear gammatone filters
+p=0.2895;   q=170;  % human  (% p=0.14;   q=366;  % cat)
+DRNLParams.nlBWs=  p * BFlist + q;
+DRNLParams.p=p;   DRNLParams.q=q;   % save p and q for printing only
+
+% DRNL linear path:
+DRNLParams.g=100;     % linear path gain factor
+% linCF is not necessarily the same as nonlinCF
+minLinCF=153.13; coeffLinCF=0.7341;   % linCF>nonlinBF for BF < 1 kHz
+DRNLParams.linCFs=minLinCF+coeffLinCF*BFlist;
+DRNLParams.linOrder=	3;           % order of linear gammatone filters
+minLinBW=100; coeffLinBW=0.6531;
+DRNLParams.linBWs=minLinBW + coeffLinBW*BFlist; % bandwidths of linear  filters
+
+% DRNL MOC efferents
+DRNLParams.MOCdelay = efferentDelay;            % must be < segment length!
+
+% 'spikes' model: MOC based on brainstem spiking activity (HSR)
+DRNLParams.rateToAttenuationFactor = .01;  % strength of MOC
+%      DRNLParams.rateToAttenuationFactor = 0;  % strength of MOC
+% 'probability' model: MOC based on AN spiking activity (HSR)
+DRNLParams.rateToAttenuationFactorProb = .0055;  % strength of MOC
+% DRNLParams.rateToAttenuationFactorProb = .0;  % strength of MOC
+DRNLParams.MOCrateThresholdProb =70;                % spikes/s probability only
+
+DRNLParams.MOCtau =.1;                         % smoothing for MOC
+
+
+%% #4 IHC_cilia_RPParams
+
+IHC_cilia_RPParams.tc=	0.0003;   % 0.0003 filter time simulates viscocity
+% IHC_cilia_RPParams.tc=	0.0005;   % 0.0003 filter time simulates viscocity
+IHC_cilia_RPParams.C=	0.03;      % 0.1 scalar (C_cilia ) 
+IHC_cilia_RPParams.u0=	5e-9;       
+IHC_cilia_RPParams.s0=	30e-9;
+IHC_cilia_RPParams.u1=	1e-9;
+IHC_cilia_RPParams.s1=	1e-9;
+
+IHC_cilia_RPParams.Gmax= 6e-9;    % 2.5e-9 maximum conductance (Siemens)
+IHC_cilia_RPParams.Ga=	1e-9;  % 4.3e-9 fixed apical membrane conductance
+IHC_cilia_RPParams.Ga=	.8e-9;  % 4.3e-9 fixed apical membrane conductance
+
+%  #5 IHC_RP
+IHC_cilia_RPParams.Cab=	4e-012;         % IHC capacitance (F)
+% IHC_cilia_RPParams.Cab=	1e-012;         % IHC capacitance (F)
+IHC_cilia_RPParams.Et=	0.100;          % endocochlear potential (V)
+
+IHC_cilia_RPParams.Gk=	2e-008;         % 1e-8 potassium conductance (S)
+IHC_cilia_RPParams.Ek=	-0.08;          % -0.084 K equilibrium potential
+IHC_cilia_RPParams.Rpc=	0.04;           % combined resistances
+
+
+%%  #5 IHCpreSynapse
+IHCpreSynapseParams=[];
+IHCpreSynapseParams.GmaxCa=	14e-9;% maximum calcium conductance
+IHCpreSynapseParams.GmaxCa=	12e-9;% maximum calcium conductance
+IHCpreSynapseParams.ECa=	0.066;  % calcium equilibrium potential
+IHCpreSynapseParams.beta=	400;	% determine Ca channel opening
+IHCpreSynapseParams.gamma=	100;	% determine Ca channel opening
+IHCpreSynapseParams.tauM=	0.00005;	% membrane time constant ?0.1ms
+IHCpreSynapseParams.power=	3;
+% reminder: changing z has a strong effect on HF thresholds (like Et)
+IHCpreSynapseParams.z=	    2e42;   % scalar Ca -> vesicle release rate
+
+LSRtauCa=35e-6;            HSRtauCa=85e-6;            % seconds
+% LSRtauCa=35e-6;            HSRtauCa=70e-6;            % seconds
+IHCpreSynapseParams.tauCa= [ HSRtauCa]; %LSR and HSR fiber
+
+%%  #6 AN_IHCsynapse
+% c=kym/(y(l+r)+kl)	(spontaneous rate)
+% c=(approx)  ym/l  (saturated rate)
+AN_IHCsynapseParams=[];             % clear the structure first
+AN_IHCsynapseParams.M=	12;         % maximum vesicles at synapse
+AN_IHCsynapseParams.y=	4;          % depleted vesicle replacement rate
+AN_IHCsynapseParams.y=	6;          % depleted vesicle replacement rate
+
+AN_IHCsynapseParams.x=	30;         % replenishment from re-uptake store
+AN_IHCsynapseParams.x=	60;         % replenishment from re-uptake store
+
+% reduce l to increase saturated rate
+AN_IHCsynapseParams.l=	100; % *loss rate of vesicles from the cleft
+AN_IHCsynapseParams.l=	250; % *loss rate of vesicles from the cleft
+
+AN_IHCsynapseParams.r=	500; % *reuptake rate from cleft into cell
+% AN_IHCsynapseParams.r=	300; % *reuptake rate from cleft into cell
+
+AN_IHCsynapseParams.refractory_period=	0.00075;
+% number of AN fibers at each BF (used only for spike generation)
+AN_IHCsynapseParams.numFibers=	100; 
+AN_IHCsynapseParams.TWdelay=0.004;  % ?delay before stimulus first spike
+
+AN_IHCsynapseParams.ANspeedUpFactor=5; % longer epochs for computing spikes.
+
+%%  #7 MacGregorMulti (first order brainstem neurons)
+MacGregorMultiParams=[];
+MacGregorMultiType='chopper'; % MacGregorMultiType='primary-like'; %choose
+switch MacGregorMultiType
+    case 'primary-like'
+        MacGregorMultiParams.nNeuronsPerBF=	10;   % N neurons per BF
+        MacGregorMultiParams.type = 'primary-like cell';
+        MacGregorMultiParams.fibersPerNeuron=4;   % N input fibers
+        MacGregorMultiParams.dendriteLPfreq=200;  % dendritic filter
+        MacGregorMultiParams.currentPerSpike=0.11e-6; % (A) per spike
+        MacGregorMultiParams.Cap=4.55e-9;   % cell capacitance (Siemens)
+        MacGregorMultiParams.tauM=5e-4;     % membrane time constant (s)
+        MacGregorMultiParams.Ek=-0.01;      % K+ eq. potential (V)
+        MacGregorMultiParams.dGkSpike=3.64e-5; % K+ cond.shift on spike,S
+        MacGregorMultiParams.tauGk=	0.0012; % K+ conductance tau (s)
+        MacGregorMultiParams.Th0=	0.01;   % equilibrium threshold (V)
+        MacGregorMultiParams.c=	0.01;       % threshold shift on spike, (V)
+        MacGregorMultiParams.tauTh=	0.015;  % variable threshold tau
+        MacGregorMultiParams.Er=-0.06;      % resting potential (V)
+        MacGregorMultiParams.Eb=0.06;       % spike height (V)
+
+    case 'chopper'
+        MacGregorMultiParams.nNeuronsPerBF=	10;   % N neurons per BF
+        MacGregorMultiParams.type = 'chopper cell';
+        MacGregorMultiParams.fibersPerNeuron=10;  % N input fibers
+%         MacGregorMultiParams.fibersPerNeuron=6;  % N input fibers
+
+        MacGregorMultiParams.dendriteLPfreq=50;   % dendritic filter
+        MacGregorMultiParams.currentPerSpike=35e-9; % *per spike
+%         MacGregorMultiParams.currentPerSpike=30e-9; % *per spike
+        
+        MacGregorMultiParams.Cap=1.67e-8; % ??cell capacitance (Siemens)
+        MacGregorMultiParams.tauM=0.002;  % membrane time constant (s)
+        MacGregorMultiParams.Ek=-0.01;    % K+ eq. potential (V)
+        MacGregorMultiParams.dGkSpike=1.33e-4; % K+ cond.shift on spike,S
+        MacGregorMultiParams.tauGk=	[0.001 0.0005];% K+ conductance tau (s)
+        MacGregorMultiParams.Th0=	0.01; % equilibrium threshold (V)
+        MacGregorMultiParams.c=	0;        % threshold shift on spike, (V)
+        MacGregorMultiParams.tauTh=	0.02; % variable threshold tau
+        MacGregorMultiParams.Er=-0.06;    % resting potential (V)
+        MacGregorMultiParams.Eb=0.06;     % spike height (V)
+        MacGregorMultiParams.PSTHbinWidth=	1e-4;
+end
+
+%%  #8 MacGregor (second-order neuron). Only one per channel
+MacGregorParams=[];                 % clear the structure first
+MacGregorParams.type = 'chopper cell';
+MacGregorParams.fibersPerNeuron=10; % N input fibers
+MacGregorParams.dendriteLPfreq=100; % dendritic filter
+MacGregorParams.currentPerSpike=120e-9;% *(A) per spike
+MacGregorParams.currentPerSpike=40e-9;% *(A) per spike
+
+MacGregorParams.Cap=16.7e-9;        % cell capacitance (Siemens)
+MacGregorParams.tauM=0.002;         % membrane time constant (s)
+MacGregorParams.Ek=-0.01;           % K+ eq. potential (V)
+MacGregorParams.dGkSpike=1.33e-4;   % K+ cond.shift on spike,S
+MacGregorParams.tauGk=	0.0005;     % K+ conductance tau (s)
+MacGregorParams.Th0=	0.01;       % equilibrium threshold (V)
+MacGregorParams.c=	0;              % threshold shift on spike, (V)
+MacGregorParams.tauTh=	0.02;       % variable threshold tau
+MacGregorParams.Er=-0.06;           % resting potential (V)
+MacGregorParams.Eb=0.06;            % spike height (V)
+MacGregorParams.debugging=0;        % (special)
+% wideband accepts input from all channels (of same fiber type)
+% use wideband to create inhibitory units
+MacGregorParams.wideband=0;         % special for wideband units
+% MacGregorParams.saveAllData=0;
+
+%%  #9 filteredSACF
+minPitch=	300; maxPitch=	3000; numPitches=60;    % specify lags
+pitches=100*log10(logspace(minPitch/100, maxPitch/100, numPitches));
+filteredSACFParams.lags=1./pitches;     % autocorrelation lags vector
+filteredSACFParams.acfTau=	.003;       % time constant of running ACF
+filteredSACFParams.lambda=	0.12;       % slower filter to smooth ACF
+filteredSACFParams.plotFilteredSACF=1;  % 0 plots unfiltered ACFs
+filteredSACFParams.plotACFs=0;          % special plot (see code)
+%  filteredSACFParams.usePressnitzer=0; % attenuates ACF at  long lags
+filteredSACFParams.lagsProcedure=  'useAllLags';
+% filteredSACFParams.lagsProcedure=  'useBernsteinLagWeights';
+% filteredSACFParams.lagsProcedure=  'omitShortLags';
+filteredSACFParams.criterionForOmittingLags=3;
+
+% checks
+if AN_IHCsynapseParams.numFibers<MacGregorMultiParams.fibersPerNeuron
+    error('MacGregorMulti: too few input fibers for input to MacG unit')
+end
+
+
+%% now accept last minute parameter changes required by the calling program
+% paramChanges
+if nargin>3 && ~isempty(paramChanges)
+    nChanges=length(paramChanges);
+    for idx=1:nChanges
+        eval(paramChanges{idx})
+    end
+end
+
+
+%% write all parameters to the command window
+% showParams is currently set at the top of htis function
+if showParams
+    fprintf('\n %%%%%%%%\n')
+    fprintf('\n%s\n', method.parameterSource)
+    fprintf('\n')
+    nm=UTIL_paramsList(whos);
+    for i=1:length(nm)
+        %         eval(['UTIL_showStruct(' nm{i} ', ''' nm{i} ''')'])
+        if ~strcmp(nm(i), 'method')
+            eval(['UTIL_showStructureSummary(' nm{i} ', ''' nm{i} ''', 10)'])
+        end
+    end
+
+    % highlight parameter changes made locally
+    if nargin>3 && ~isempty(paramChanges)
+        fprintf('\n Local parameter changes:\n')
+        for i=1:length(paramChanges)
+            disp(paramChanges{i})
+        end
+    end
+end
+
+% for backward compatibility
+experiment.comparisonData=[];
diff -r b51bf546ca3f -r 1a502830d462 testPrograms/test_MAP1_14x.m
--- /dev/null
+++ b/testPrograms/test_MAP1_14x.m
@@ -0,0 +1,190 @@
+function test_MAP1_14x
+% 'x' is a trial file
+% test_MAP1_14 is a general purpose test routine that can be adjusted to
+% test a number of different applications of MAP1_14
+%
+% A range of options are supplied in the early part of the program
+%
+% One use of the function is to create demonstrations; filenames <demoxx>
+%  to illustrate particular features
+%
+% #1
+% Identify the file (in 'MAPparamsName') containing the model parameters
+%
+% #2
+% Identify the kind of model required (in 'AN_spikesOrProbability').
+%  A full brainstem model (spikes) can be computed or a shorter model
+%  (probability) that computes only so far as the auditory nerve
+%
+% #3
+% Choose between a tone signal or file input (in 'signalType')
+%
+% #4
+% Set the signal rms level (in leveldBSPL)
+%
+% #5
+% Identify the channels in terms of their best frequencies in the vector
+%  BFlist.
+%
+% Last minute changes to the parameters fetched earlier can be made using
+%  the cell array of strings 'paramChanges'.
+%  Each string must have the same format as the corresponding line in the
+%  file identified in 'MAPparamsName'
+%
+% When the demonstration is satisfactory, freeze it by renaming it <demoxx>
+
+dbstop if error
+restorePath=path;
+addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'], ...
+    ['..' filesep 'utilities'])
+
+%%  #1 parameter file name
+MAPparamsName='NormalIC';
+
+
+%% #2 probability (fast) or spikes (slow) representation
+AN_spikesOrProbability='spikes';
+
+% or
+% NB probabilities are not corrected for refractory effects
+% AN_spikesOrProbability='probability';
+
+
+%% #3 pure tone, harmonic sequence or speech file input
+signalType= 'tones';
+sampleRate= 50000;
+duration=0.250;                 % seconds
+toneFrequency= 250:250:8000;    % harmonic sequence (Hz)
+% toneFrequency= 1000;            % or a pure tone (Hz8
+rampDuration=.005;              % seconds
+
+% or
+
+% signalType= 'file';
+% fileName='twister_44kHz';
+
+
+%% #4 rms level
+% signal details
+leveldBSPL= 30;                  % dB SPL
+
+
+%% #5 number of channels in the model
+%   21-channel model (log spacing)
+numChannels=21;
+lowestBF=250; 	highestBF= 8000;
+BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
+
+%   or specify your own channel BFs
+% numChannels=1;
+% BFlist=toneFrequency;
+
+
+%% #6 change model parameters
+paramChanges=[];
+
+% or
+% Parameter changes can be used to change one or more model parameters
+%  *after* the MAPparams file has been read
+% This example declares only one fiber type with a calcium clearance time
+% constant of 80e-6 s (HSR fiber) when the probability option is selected.
+
+% paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
+%     'IHCpreSynapseParams.tauCa=86e-6;'};
+
+% paramChanges={'DRNLParams.rateToAttenuationFactorProb = 0;'};
+
+% paramChanges={'IHCpreSynapseParams.tauCa=86e-6;',
+%     'AN_IHCsynapseParams.numFibers=	1000;'};
+
+% fixed MOC attenuation(using negative factor)
+paramChanges={'DRNLParams.rateToAttenuationFactorProb=-0.005;'};
+
+%% delare 'showMap' options to control graphical output
+
+showMapOptions.printModelParameters=1;   % prints all parameters
+showMapOptions.showModelOutput=1;       % plot of all stages
+showMapOptions.printFiringRates=1;      % prints stage activity levels
+showMapOptions.showACF=0;               % shows SACF (probability only)
+showMapOptions.showEfferent=1;          % tracks of AR and MOC
+showMapOptions.surfProbability=1;       % 2D plot of HSR response 
+showMapOptions.surfSpikes=1;            % 2D plot of spikes histogram
+
+% disable certain silly options
+if strcmp(AN_spikesOrProbability, 'spikes')
+    % avoid nonsensical options
+    showMapOptions.surfProbability=0;
+    showMapOptions.showACF=0;
+else
+    showMapOptions.surfSpikes=0;
+end
+if strcmp(signalType, 'file')
+    % needed for labeling plot
+    showMapOptions.fileName=fileName;
+else
+    showMapOptions.fileName=[];
+end
+
+%% Generate stimuli
+
+switch signalType
+    case 'tones'
+        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
+            leveldBSPL, duration, rampDuration);
+
+    case 'file'
+        %% file input simple or mixed
+        [inputSignal sampleRate]=wavread(fileName);
+        dt=1/sampleRate;
+        inputSignal=inputSignal(:,1);
+        targetRMS=20e-6*10^(leveldBSPL/20);
+        rms=(mean(inputSignal.^2))^0.5;
+        amp=targetRMS/rms;
+        inputSignal=inputSignal*amp;
+        silence= zeros(1,round(0.1/dt));
+        inputSignal= [silence inputSignal' silence];
+end
+
+
+%% run the model
+tic
+
+fprintf('\n')
+disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
+disp([num2str(numChannels) ' channel model'])
+disp('Computing ...')
+
+MAP1_14(inputSignal, sampleRate, BFlist, ...
+    MAPparamsName, AN_spikesOrProbability, paramChanges);
+
+
+% the model run is now complete. Now display the results
+UTIL_showMAP(showMapOptions, paramChanges)
+
+toc
+path(restorePath)
+
+
+function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
+    leveldBSPL, duration, rampDuration)
+% Create pure tone stimulus
+dt=1/sampleRate; % seconds
+time=dt: dt: duration;
+inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
+amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
+inputSignal=amp*inputSignal;
+
+% apply ramps
+% catch rampTime error
+if rampDuration>0.5*duration, rampDuration=duration/2; end
+rampTime=dt:dt:rampDuration;
+ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
+    ones(1,length(time)-length(rampTime))];
+inputSignal=inputSignal.*ramp;
+ramp=fliplr(ramp);
+inputSignal=inputSignal.*ramp;
+
+% add 10 ms silence
+silence= zeros(1,round(0.05/dt));
+inputSignal= [silence inputSignal silence];
+
diff -r b51bf546ca3f -r 1a502830d462 utilities/stimulusCreate.m
--- a/utilities/stimulusCreate.m
+++ b/utilities/stimulusCreate.m
@@ -1471,7 +1471,8 @@
 
 
 %--------------------------------------------------------------------checkDescriptors
-function [globalStimParams, stimComponents]=checkDescriptors(globalStimParams, stimComponents);
+function [globalStimParams, stimComponents]=...
+    checkDescriptors(globalStimParams, stimComponents)
 
 try
     % if FS exists, it takes priority
@@ -1481,7 +1482,10 @@
     globalStimParams.FS=1/globalStimParams.dt;
 end
 
-globalStimParams.nSignalPoints=round(globalStimParams.overallDuration/globalStimParams.dt);
+sampleRate=globalStimParams.FS;
+
+globalStimParams.nSignalPoints=...
+    round(globalStimParams.overallDuration* sampleRate);
 
 % optional field (ears)
 try
@@ -1514,8 +1518,6 @@
     globalStimParams.doPlot=0;
 end
 
-
-
 [ears nComponentSounds]=size(stimComponents);
 
 for ear=1:2 % 1=left/ 2=right
@@ -1567,16 +1569,17 @@
 
         % end silence is measured to fit into the global duration
         if stimComponents(ear,componentNo).endSilence==-1,
-            endSilenceNpoints=...
-                globalStimParams.nSignalPoints ...
-                -round(stimComponents(ear,componentNo).beginSilence*globalStimParams.FS)...
-                -round(stimComponents(ear,componentNo).toneDuration*globalStimParams.FS);
-            stimComponents(ear,componentNo).endSilence=endSilenceNpoints/globalStimParams.FS;
-            % if endSilence < 0, we have a problem
-            if stimComponents(ear,componentNo).endSilence<0
-                globalStimParams
-                descriptorError( 'component durations greater than overallDuration', stimComponents, ear, componentNo)
-            end
+            stimComponents(ear,componentNo).endSilence=...
+                globalStimParams.overallDuration-...
+                stimComponents(ear,componentNo).beginSilence -...
+                stimComponents(ear,componentNo).toneDuration;
+            
+            endSilenceNpoints=stimComponents(ear,componentNo).endSilence...
+                *sampleRate;
+        end
+        if stimComponents(ear,componentNo).endSilence<0
+            globalStimParams
+            descriptorError( 'component durations greater than overallDuration', stimComponents, ear, componentNo)
         end
 
         % check overall duration of this component against global duration
@@ -1590,26 +1593,12 @@
             globalStimParams.overallDuration= totalDuration;
         end
 
-
-        if round(totalDuration*globalStimParams.FS)>round(globalStimParams.overallDuration*globalStimParams.FS)
-            globalStimParams
-            descriptorError( 'Component durations greater than overallDuration', stimComponents, ear, componentNo)
-        end
-
         % check total duration
-        totalSignalPoints= round((stimComponents(ear,componentNo).beginSilence+ stimComponents(ear,componentNo).toneDuration+...
-            stimComponents(ear,componentNo).endSilence)/globalStimParams.dt);
+        totalSignalPoints= round(totalDuration* sampleRate);
         if totalSignalPoints  >globalStimParams.nSignalPoints
             descriptorError( 'Signal component duration does not match overall duration ', stimComponents, ear, componentNo)
         end
 
-        % no ramps for clicks please!
-        %         if strcmp(stimComponents(ear,componentNo).type, 'clicks') & stimComponents(ear,componentNo).clickRepeatFrequency==-1
-        %         if strcmp(stimComponents(ear,componentNo).type, 'clicks')
-        %             stimComponents(ear,componentNo).rampOnDur=0;
-        %             stimComponents(ear,componentNo).rampOffDur=0;
-        %         end
-
         if isfield(stimComponents(ear,componentNo), 'filter')
             if ~isequal(length(stimComponents(ear,componentNo).filter), 3)
                 descriptorError( 'Filter parameter must have three elements ', stimComponents, ear, componentNo)
