Mercurial > hg > map
comparison multithreshold 1.46/nextStimulus.m @ 38:c2204b18f4a2 tip
End nov big change
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 28 Nov 2011 13:34:28 +0000 |
parents | 3ea506487b3b |
children |
comparison
equal
deleted
inserted
replaced
37:771a643d5c29 | 38:c2204b18f4a2 |
---|---|
1 function errormsg=nextStimulus(handles) | 1 function errormsg=nextStimulus(handles) |
2 % Handles everything concerned with the stimulus presentation | 2 % Handles everything concerned with the stimulus presentation |
3 % called from startNewRun in subjGUI | 3 % called from startNewRun in subjGUI |
4 | 4 |
5 global experiment stimulusParameters withinRuns | 5 global experiment stimulusParameters withinRuns betweenRuns |
6 experiment.status='presentingStimulus'; | 6 experiment.status='presentingStimulus'; |
7 errormsg=''; | 7 errormsg=''; |
8 | 8 |
9 % interrupt by 'stop' button | 9 % interrupt by 'stop' button |
10 % if experiment.stop | 10 % if experiment.stop |
232 switch experiment.paradigm | 232 switch experiment.paradigm |
233 % cue target is more audible | 233 % cue target is more audible |
234 case {'training','absThreshold', 'absThreshold_8', ... | 234 case {'training','absThreshold', 'absThreshold_8', ... |
235 'TENtest', 'threshold_duration','discomfort',... | 235 'TENtest', 'threshold_duration','discomfort',... |
236 'overShoot','overShootB','overShootMB1', ... | 236 'overShoot','overShootB','overShootMB1', ... |
237 'overShootMB2', 'OHIO','OHIOabs','OHIOspect'} | 237 'overShootMB2', 'OHIO','OHIOabs','OHIOspect'... |
238 'OHIOrand', 'OHIOtemp', 'OHIOspectemp'} | |
238 cueTargetLevel=targetLevel+cueTestDifference; | 239 cueTargetLevel=targetLevel+cueTestDifference; |
239 | 240 |
240 case {'forwardMasking','forwardMaskingD','trainingIFMC', ... | 241 case {'forwardMasking','forwardMaskingD','trainingIFMC', ... |
241 'TMC','TMC_16ms', 'TMC - ELP', 'IFMC','IFMC_8ms', 'FMreProbe'} | 242 'TMC','TMC_16ms', 'TMC - ELP', 'IFMC','IFMC_8ms', ... |
243 'FMreProbe'} | |
242 % cue masker is weaker to make target more audible | 244 % cue masker is weaker to make target more audible |
243 cueMaskerLevel=maskerLevel-cueTestDifference; | 245 cueMaskerLevel=maskerLevel-cueTestDifference; |
246 end | |
247 end | |
248 | |
249 % thresholds (in dB SPL) of the single tone with 12 frequencies: | |
250 % 1 2 3 4 5 6 7 8 9 10 11 12 | |
251 % 494, 663, 870, 1125, 1442, 1838, 2338, 2957, 3725, 4689, 5866, 7334 | |
252 | |
253 % 2. ‘OHIOtemp’ is for measuring thresholds for temporally integrated | |
254 % combinations of 2, 4, 8, and 12 tones presented simultaneously. | |
255 % In our experiment, we used 4680Hz frequency. | |
256 | |
257 % 3. ‘OHIOspec’ is for measuring thresholds for spectrally integrated | |
258 % combinations of 2(7335 and 5866Hz), 4(7334, 5866, 4680, and 3725Hz), | |
259 % 8(7334, 5866, 4680, 3725, 2957, 2338, 1838, and | |
260 % 1442Hz), and | |
261 % 12(all 12 frequencies) tones presented simultaneously. | |
262 | |
263 % 4. ‘OHIOspectemp’ is for measuring thresholds for patterned signals | |
264 % differing in both the spectral and temporal domains. | |
265 % The frequency conditions are the same as that of ‘OHIOspec’. | |
266 | |
267 % 5. ‘OHIOrand’ is for measuring thresholds for spectrotemporally varying | |
268 % signals with random frequency presentation. | |
269 | |
270 switch experiment.paradigm(1:3) | |
271 case 'OHI' | |
272 targetType='OHIO'; | |
273 OHIOtype=experiment.paradigm; | |
274 % 1. ‘OHIOabs’ paradigm is a baseline procedure for measuring absolute | |
275 | |
276 nTones=betweenRuns.var1Sequence(betweenRuns.runNumber); | |
277 allFreqs=[494, 663, 870, 1125, 1442, 1838, 2338, 2957, 3725, 4689, 5866, 7334]; | |
278 toneLevelBoost= ... | |
279 [1 0 0 1 1 4 8 12 12 14 17 19 ]; | |
280 | |
281 | |
282 % for nTones=nTonesList | |
283 switch experiment.paradigm | |
284 % case ' OHIOabs' | |
285 % % one tone frequency at a time | |
286 % stim.frequencies=allFreqs(1); | |
287 % stim.amplitudesdB=0; | |
288 | |
289 case 'OHIOrand' | |
290 % chose nTones frequencies at random | |
291 x=rand(1,12); | |
292 [sorted idx]=sort(x); | |
293 cueTargetFrequency=allFreqs(idx(1:nTones)); | |
294 cueTargetLevel=toneLevelBoost(idx)+... | |
295 targetLevel + cueTestDifference; | |
296 targetFrequency=allFreqs(idx(1:nTones)); | |
297 targetLevel=targetLevel + toneLevelBoost(idx); | |
298 | |
299 case 'OHIOtemp' | |
300 % 4680 Hz repeated nTones times | |
301 cueTargetFrequency=4680*ones(1,nTones); | |
302 cueTargetLevel=repmat(toneLevelBoost(10),1,nTones)+... | |
303 targetLevel + cueTestDifference; | |
304 targetFrequency=4680*ones(1,nTones); | |
305 targetLevel= targetLevel+repmat(toneLevelBoost(10),1,nTones); | |
306 | |
307 case {'OHIOspect', 'OHIOspectemp'} | |
308 % nTones frequencies either simulataneously or sequentially | |
309 switch nTones | |
310 case 2 | |
311 cueTargetFrequency=[7335 5866]; | |
312 targetFrequency=[7335 5866]; | |
313 idx=[12 11]; | |
314 cueTargetLevel=targetLevel + toneLevelBoost(idx)+cueTestDifference; | |
315 targetLevel=targetLevel + toneLevelBoost(idx); | |
316 case 4 | |
317 cueTargetFrequency=[7334, 5866, 4680, 3725]; | |
318 targetFrequency=[7334, 5866, 4680, 3725]; | |
319 idx=[12:-1:9 ]; | |
320 cueTargetLevel=targetLevel + toneLevelBoost(idx)+cueTestDifference; | |
321 targetLevel=targetLevel + toneLevelBoost(idx); | |
322 case 8 | |
323 cueTargetFrequency=... | |
324 [7334, 5866, 4680, 3725, 2957, 2338, 1838, 1442]; | |
325 targetFrequency=... | |
326 [7334, 5866, 4680, 3725, 2957, 2338, 1838, 1442]; | |
327 idx=[12:-1:5 ]; | |
328 cueTargetLevel=targetLevel + toneLevelBoost(idx)+cueTestDifference; | |
329 targetLevel=targetLevel + toneLevelBoost(idx); | |
330 case 12 | |
331 cueTargetFrequency=allFreqs; | |
332 targetFrequency=allFreqs; | |
333 cueTargetLevel=targetLevel + toneLevelBoost(1:12)+cueTestDifference; | |
334 targetLevel=targetLevel + toneLevelBoost(1:12); | |
335 end | |
336 end | |
337 | |
338 otherwise | |
339 OHIOtype='none'; | |
340 end | |
341 | |
342 switch experiment.paradigm(1:3) | |
343 case 'OHI' | |
344 | |
345 switch experiment.threshEstMethod | |
346 case {'2I2AFC++', '2I2AFC+++'} | |
347 % the cue stimulus (masker + probe) is the 'no' window | |
348 % the target stimulus (masker+probe) is the 'yes' window | |
349 % the order of presentation is decided at the last minute. | |
350 cueTargetLevel=-100; | |
351 end | |
352 | |
353 | |
354 switch experiment.paradigm | |
355 case {'OHIOabs', 'OHIOspect'} | |
356 OHIOtoneDuration=.02+stimulusParameters.stimulusDelay; | |
357 globalStimParams.overallDuration=OHIOtoneDuration; | |
358 otherwise | |
359 OHIOtoneDuration=nTones*0.02+stimulusParameters.stimulusDelay; | |
360 globalStimParams.overallDuration=OHIOtoneDuration; | |
244 end | 361 end |
245 end | 362 end |
246 | 363 |
247 % ----------------------------- catch trial | 364 % ----------------------------- catch trial |
248 if withinRuns.catchTrial | 365 if withinRuns.catchTrial |
368 withinRuns.forceThreshold=stimulusParameters.WRVlimits(1); | 485 withinRuns.forceThreshold=stimulusParameters.WRVlimits(1); |
369 withinRuns.forceThreshold=NaN; | 486 withinRuns.forceThreshold=NaN; |
370 return | 487 return |
371 end | 488 end |
372 | 489 |
490 case 'gapDuration' | |
373 % legacy programming | 491 % legacy programming |
374 case 'gapDuration' | |
375 if gapDuration<0 | 492 if gapDuration<0 |
376 errormsg=['gapDuration (' num2str(gapDuration) ... | 493 errormsg=['gapDuration (' num2str(gapDuration) ... |
377 ') is less than zero ***']; | 494 ') is less than zero ***']; |
378 return | 495 return |
379 end | 496 end |
495 duration(3)=precedingSilence+maskerDuration+ terminalSilence; | 612 duration(3)=precedingSilence+maskerDuration+ terminalSilence; |
496 globalStimParams.overallDuration=max(duration); | 613 globalStimParams.overallDuration=max(duration); |
497 globalStimParams.nSignalPoints=... | 614 globalStimParams.nSignalPoints=... |
498 round(globalStimParams.overallDuration*globalStimParams.FS); | 615 round(globalStimParams.overallDuration*globalStimParams.FS); |
499 | 616 |
617 % special case | |
618 switch experiment.paradigm(1:3) | |
619 case 'OHI' | |
620 switch experiment.paradigm | |
621 case {'OHIOabs', 'OHIOspect'} | |
622 OHIOtoneDuration=.02+stimulusParameters.stimulusDelay; | |
623 globalStimParams.overallDuration=OHIOtoneDuration; | |
624 otherwise | |
625 OHIOtoneDuration=nTones*0.02+stimulusParameters.stimulusDelay; | |
626 globalStimParams.overallDuration=OHIOtoneDuration; | |
627 end | |
628 end | |
629 | |
630 | |
500 % ----------------------------------------------cue stimulus | 631 % ----------------------------------------------cue stimulus |
501 % cue masker | 632 % cue masker |
502 componentNo=1; | 633 componentNo=1; |
503 precedingSilence=stimulusParameters.stimulusDelay; | 634 precedingSilence=stimulusParameters.stimulusDelay; |
504 stimComponents(maskerEar,componentNo).type=maskerType; | 635 stimComponents(maskerEar,componentNo).type=maskerType; |
525 | 656 |
526 % cue target | 657 % cue target |
527 componentNo=2; | 658 componentNo=2; |
528 precedingSilence=precedingSilence + maskerDuration+cueGapDuration; | 659 precedingSilence=precedingSilence + maskerDuration+cueGapDuration; |
529 stimComponents(targetEar,componentNo).type=targetType; | 660 stimComponents(targetEar,componentNo).type=targetType; |
661 stimComponents(targetEar,componentNo).OHIOtype=OHIOtype; | |
530 stimComponents(targetEar,componentNo).toneDuration=targetDuration; | 662 stimComponents(targetEar,componentNo).toneDuration=targetDuration; |
531 stimComponents(targetEar,componentNo).frequencies=cueTargetFrequency; | 663 stimComponents(targetEar,componentNo).frequencies=cueTargetFrequency; |
532 stimComponents(targetEar,componentNo).amplitudesdB=cueTargetLevel; | 664 stimComponents(targetEar,componentNo).amplitudesdB=cueTargetLevel; |
533 stimComponents(targetEar,componentNo).beginSilence=precedingSilence; | 665 stimComponents(targetEar,componentNo).beginSilence=precedingSilence; |
534 stimComponents(targetEar,componentNo).endSilence=-1; | 666 stimComponents(targetEar,componentNo).endSilence=-1; |
603 | 735 |
604 % target | 736 % target |
605 componentNo=2; | 737 componentNo=2; |
606 targetDelay=precedingSilence+ maskerDuration+ gapDuration; | 738 targetDelay=precedingSilence+ maskerDuration+ gapDuration; |
607 stimComponents(targetEar,componentNo).type=targetType; | 739 stimComponents(targetEar,componentNo).type=targetType; |
740 stimComponents(targetEar,componentNo).OHIOtype=OHIOtype; | |
608 stimComponents(targetEar,componentNo).toneDuration=targetDuration; | 741 stimComponents(targetEar,componentNo).toneDuration=targetDuration; |
609 stimComponents(targetEar,componentNo).frequencies=targetFrequency; | 742 stimComponents(targetEar,componentNo).frequencies=targetFrequency; |
610 stimComponents(targetEar,componentNo).amplitudesdB=targetLevel; | 743 stimComponents(targetEar,componentNo).amplitudesdB=targetLevel; |
611 stimComponents(targetEar,componentNo).beginSilence=targetDelay; | 744 stimComponents(targetEar,componentNo).beginSilence=targetDelay; |
612 stimComponents(targetEar,componentNo).endSilence=-1; | 745 stimComponents(targetEar,componentNo).endSilence=-1; |
659 stimulusParameters.testTargetEnds=... | 792 stimulusParameters.testTargetEnds=... |
660 stimulusParameters.testTargetBegins+withinRuns.variableValue; | 793 stimulusParameters.testTargetBegins+withinRuns.variableValue; |
661 % case 'SRT' | 794 % case 'SRT' |
662 % set(handles.editdigitInput,'visible','off') | 795 % set(handles.editdigitInput,'visible','off') |
663 otherwise | 796 otherwise |
664 stimulusParameters.testTargetBegins=targetDelay; | 797 switch experiment.paradigm(1:3) |
665 stimulusParameters.testTargetEnds=targetDelay+targetDuration; | 798 case 'OHI' |
799 stimulusParameters.testTargetBegins=0; | |
800 stimulusParameters.testTargetEnds=OHIOtoneDuration; | |
801 otherwise | |
802 stimulusParameters.testTargetBegins=targetDelay; | |
803 stimulusParameters.testTargetEnds=targetDelay+targetDuration; | |
804 end | |
666 end | 805 end |
667 | 806 |
668 % ------------------------------------------------------------- play! | 807 % ------------------------------------------------------------- play! |
669 % Create and play stimulus (as required by different paradigms) | 808 % Create and play stimulus (as required by different paradigms) |
670 switch experiment.ear | 809 switch experiment.ear |