Mercurial > hg > map
comparison multithreshold 1.46/nextStimulus.m @ 22:45f28c49461e master
removing duplicate changes
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 13 Jun 2011 18:21:05 +0100 |
parents | 8c7a18d89610 |
children | 02aa9826efe0 |
comparison
equal
deleted
inserted
replaced
21:c489ebada16e | 22:45f28c49461e |
---|---|
80 pause(.1) | 80 pause(.1) |
81 end | 81 end |
82 end | 82 end |
83 | 83 |
84 set(handles.textMSG,'BackgroundColor','w', 'ForegroundColor', 'b') | 84 set(handles.textMSG,'BackgroundColor','w', 'ForegroundColor', 'b') |
85 | 85 |
86 % Now the serious business of crafting and presenting the stimulus | 86 % Now the serious business of crafting and presenting the stimulus |
87 errormsg= stimulusMakeAndPlay (handles); | 87 errormsg= stimulusMakeAndPlay (handles); |
88 | 88 |
89 if ~isempty(errormsg) | 89 if ~isempty(errormsg) |
90 % e.g. clipping. subjGUI will service the error | 90 % e.g. clipping. subjGUI will service the error |
312 % ----------------------------- catch trial | 312 % ----------------------------- catch trial |
313 if withinRuns.catchTrial | 313 if withinRuns.catchTrial |
314 targetLevel=-100; % no target | 314 targetLevel=-100; % no target |
315 end | 315 end |
316 | 316 |
317 % ----------------------------- calibration of sound output | |
318 calibrationCorrectiondB=stimulusParameters.calibrationdB; | |
319 if calibrationCorrectiondB<-50 | |
320 if maskerFrequency==targetFrequency | |
321 load 'calibrationFile' % calibrationFrequency calibrationAttenutation | |
322 idx=find(calibrationFrequency==targetFrequency); | |
323 if isempty(idx) | |
324 error('Calibration bty file; frequency not found') | |
325 else | |
326 calibrationCorrectiondB=calibrationAttenutation(idx) | |
327 end | |
328 else | |
329 error('calibration by file requested but masker frequency is not the same as target') | |
330 end | |
331 end | |
332 | |
333 | |
317 % -------------------------------------- Checks on excessive signal level | 334 % -------------------------------------- Checks on excessive signal level |
318 | 335 |
319 % clipping is relevant only for soundcard use (not modelling) | 336 % clipping is relevant only for soundcard use (not modelling) |
320 switch experiment.ear | 337 switch experiment.ear |
321 case {'left', 'right', 'diotic',... | 338 case {'left', 'right', 'diotic',... |
327 | 344 |
328 % NB calibration *reduces* the level of the soundCard output | 345 % NB calibration *reduces* the level of the soundCard output |
329 switch experiment.ear | 346 switch experiment.ear |
330 case {'left', 'right', 'diotic',... | 347 case {'left', 'right', 'diotic',... |
331 'dichotic', 'dioticLeft', 'dichoticRight'} | 348 'dichotic', 'dioticLeft', 'dichoticRight'} |
332 clippingLevel=91+stimulusParameters.calibrationdB; | 349 clippingLevel=91+calibrationCorrectiondB; |
333 soundCardMinimum=clippingLevel-20*log10(2^24); | 350 soundCardMinimum=clippingLevel-20*log10(2^24); |
334 otherwise | 351 otherwise |
335 clippingLevel=inf; | 352 clippingLevel=inf; |
336 soundCardMinimum=-inf; | 353 soundCardMinimum=-inf; |
337 end | 354 end |
364 ') is clipping ***']; | 381 ') is clipping ***']; |
365 withinRuns.forceThreshold=clippingLevel; | 382 withinRuns.forceThreshold=clippingLevel; |
366 withinRuns.forceThreshold=NaN; | 383 withinRuns.forceThreshold=NaN; |
367 return | 384 return |
368 end | 385 end |
369 | 386 |
370 case 'targetLevel' | 387 case 'targetLevel' |
371 upperLevel=stimulusParameters.WRVlimits(2); | 388 upperLevel=stimulusParameters.WRVlimits(2); |
372 lowerLevel=stimulusParameters.WRVlimits(1); | 389 lowerLevel=stimulusParameters.WRVlimits(1); |
373 if ~withinRuns.catchTrial | 390 if ~withinRuns.catchTrial |
374 if max(targetLevel, cueTargetLevel)> upperLevel | 391 if max(targetLevel, cueTargetLevel)> upperLevel |
375 errormsg=['target level (' ... | 392 errormsg=['target level (' ... |
376 num2str(max(targetLevel, cueTargetLevel)) ... | 393 num2str(max(targetLevel, cueTargetLevel)) ... |
377 ') is too high ***']; | 394 ') is too high ***']; |
378 withinRuns.forceThreshold=upperLevel; | 395 withinRuns.forceThreshold=upperLevel; |
379 withinRuns.forceThreshold=NaN; | 396 withinRuns.forceThreshold=NaN; |
380 return | 397 return |
381 end | 398 end |
382 if max(targetLevel, cueTargetLevel)< lowerLevel | 399 if max(targetLevel, cueTargetLevel)< lowerLevel |
383 errormsg=['target level (' ... | 400 errormsg=['target level (' ... |
384 num2str(max(targetLevel, cueTargetLevel)) ... | 401 num2str(max(targetLevel, cueTargetLevel)) ... |
385 ') is too low ***']; | 402 ') is too low ***']; |
386 withinRuns.forceThreshold=lowerLevel; | 403 withinRuns.forceThreshold=lowerLevel; |
387 withinRuns.forceThreshold=NaN; | 404 withinRuns.forceThreshold=NaN; |
388 return | 405 return |
389 end | 406 end |
390 if max(targetLevel, cueTargetLevel)> clippingLevel | 407 if max(targetLevel, cueTargetLevel)> clippingLevel |
391 errormsg=['target level (' ... | 408 errormsg=['target level (' ... |
392 num2str(max(targetLevel, cueTargetLevel)) ... | 409 num2str(max(targetLevel, cueTargetLevel)) ... |
393 ') is clipping ***']; | 410 ') is clipping ***']; |
394 withinRuns.forceThreshold=upperLevel; | 411 withinRuns.forceThreshold=upperLevel; |
395 withinRuns.forceThreshold=NaN; | 412 withinRuns.forceThreshold=NaN; |
396 return | 413 return |
397 end | 414 end |
398 end | 415 end |
399 case 'maskerDuration' | 416 case 'maskerDuration' |
400 % this is odd! but harmless | 417 % this is odd! but harmless |
401 if max(maskerDuration, cueMaskerDuration)> ... | 418 if max(maskerDuration, cueMaskerDuration)> ... |
402 stimulusParameters.WRVlimits(2) | 419 stimulusParameters.WRVlimits(2) |
403 errormsg=['maskerDuration (' ... | 420 errormsg=['maskerDuration (' ... |
491 end | 508 end |
492 | 509 |
493 backgroundType=stimulusParameters.backgroundType; | 510 backgroundType=stimulusParameters.backgroundType; |
494 switch stimulusParameters.backgroundType | 511 switch stimulusParameters.backgroundType |
495 case {'noiseDich', 'pinkNoiseDich'} | 512 case {'noiseDich', 'pinkNoiseDich'} |
496 % case 'Dich' | 513 % case 'Dich' |
497 % dich means put the background in the ear opposite to the target | 514 % dich means put the background in the ear opposite to the target |
498 backgroundType=backgroundType(1:end-4); | 515 backgroundType=backgroundType(1:end-4); |
499 switch targetEar | 516 switch targetEar |
500 case 1 | 517 case 1 |
501 backgroundEar=2; | 518 backgroundEar=2; |
502 case 2 | 519 case 2 |
503 backgroundEar=1; | 520 backgroundEar=1; |
504 end | 521 end |
505 otherwise | 522 otherwise |
506 % case {'none','noise', 'pinkNoise', 'TEN','babble'} | 523 % case {'none','noise', 'pinkNoise', 'TEN','babble'} |
507 backgroundEar=targetEar; | 524 backgroundEar=targetEar; |
508 end | 525 end |
509 | 526 |
510 % ------------------------------- Make Stimulus ------------------- | 527 % ------------------------------- Make Stimulus ------------------- |
511 % single interval up/down plays cue then target stimulus | 528 % single interval up/down plays cue then target stimulus |
513 globalStimParams.FS=stimulusParameters.sampleRate; | 530 globalStimParams.FS=stimulusParameters.sampleRate; |
514 dt=1/stimulusParameters.sampleRate; | 531 dt=1/stimulusParameters.sampleRate; |
515 globalStimParams.dt=dt; | 532 globalStimParams.dt=dt; |
516 stimulusParameters.dt=dt; % for use later | 533 stimulusParameters.dt=dt; % for use later |
517 | 534 |
518 % calibration of sound output | 535 |
519 correctiondB=stimulusParameters.calibrationdB; | 536 |
520 globalStimParams.audioOutCorrection=10^(correctiondB/20); | 537 globalStimParams.audioOutCorrection=10^(calibrationCorrectiondB/20); |
521 % the output will be reduced by this amount in stimulusCreate | 538 % the output will be reduced by this amount in stimulusCreate |
522 % i.e. audio=audio/globalStimParams.audioOutCorrection | 539 % i.e. audio=audio/globalStimParams.audioOutCorrection |
523 % A 91 dB level will yield a peak amp of 1 for calibration=0 | 540 % A 91 dB level will yield a peak amp of 1 for calibration=0 |
524 % A 91 dB level will yield a peak amp of 0.4467 for calibration=7 | 541 % A 91 dB level will yield a peak amp of 0.4467 for calibration=7 |
525 % A 98 dB level will yield a peak amp of 1 for calibration=7 | 542 % A 98 dB level will yield a peak amp of 1 for calibration=7 |
678 fileName=['..' filesep '..' filesep ... | 695 fileName=['..' filesep '..' filesep ... |
679 'multithresholdResources' filesep ... | 696 'multithresholdResources' filesep ... |
680 'backgrounds and maskers'... | 697 'backgrounds and maskers'... |
681 filesep 'ten.wav']; | 698 filesep 'ten.wav']; |
682 [tenNoise, FS]=wavread(fileName); | 699 [tenNoise, FS]=wavread(fileName); |
683 | 700 |
684 tenNoise=resample(tenNoise, globalStimParams.FS, FS); | 701 tenNoise=resample(tenNoise, globalStimParams.FS, FS); |
685 stimComponents(backgroundEar,componentNo).type='file'; | 702 stimComponents(backgroundEar,componentNo).type='file'; |
686 stimComponents(backgroundEar,componentNo).stimulus=tenNoise'; | 703 stimComponents(backgroundEar,componentNo).stimulus=tenNoise'; |
687 end | 704 end |
688 stimComponents(backgroundEar,componentNo).toneDuration=... | 705 stimComponents(backgroundEar,componentNo).toneDuration=... |
703 stimulusParameters.testTargetBegins=... | 720 stimulusParameters.testTargetBegins=... |
704 stimulusParameters.stimulusDelay... | 721 stimulusParameters.stimulusDelay... |
705 +stimulusParameters.maskerDuration; | 722 +stimulusParameters.maskerDuration; |
706 stimulusParameters.testTargetEnds=... | 723 stimulusParameters.testTargetEnds=... |
707 stimulusParameters.testTargetBegins+withinRuns.variableValue; | 724 stimulusParameters.testTargetBegins+withinRuns.variableValue; |
708 % case 'SRT' | 725 % case 'SRT' |
709 % set(handles.editdigitInput,'visible','off') | 726 % set(handles.editdigitInput,'visible','off') |
710 otherwise | 727 otherwise |
711 stimulusParameters.testTargetBegins=targetDelay; | 728 stimulusParameters.testTargetBegins=targetDelay; |
712 stimulusParameters.testTargetEnds=targetDelay+targetDuration; | 729 stimulusParameters.testTargetEnds=targetDelay+targetDuration; |
713 end | 730 end |
714 | 731 |