diff listeningTest/multiComp/endMultiComp.m @ 0:4fd284285159

Adding listening test plus some helpful functions and scripts.
author Brecht <b.deman@qmul.ac.uk>
date Thu, 24 Apr 2014 23:53:31 +0100
parents
children d113f0626fe3
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/listeningTest/multiComp/endMultiComp.m	Thu Apr 24 23:53:31 2014 +0100
@@ -0,0 +1,100 @@
+function endMultiComp(hf) % called when 'Finished' clicked
+
+playSound([]); % stop all sound
+
+dat=get(hf,'userdata');
+
+if(sum(dat.playVec) ~= size(dat.sesDat.cuSndList,2))
+    x = mat2str(dat.permVec(find(dat.playVec==0)));
+    errordlg(['Please continue until all sounds are assessed: you haven''t listened to ' x ' yet.'], 'Not all sounds played!');
+    return;
+end
+
+% are you sure?
+choice = questdlg('Are you sure you are finished and want to submit your response for this round?','Finish and submit','No','Yes','No');
+if strcmp(choice, 'No')
+    return; 
+end
+
+% TODO: replace some of the following by savemultiComp
+
+sesDat=dat.sesDat;
+test=dat.test;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Collect the results into rsl
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+rsl.gcom=get(dat.gcom,'string'); % general comments
+rsl.hcom=get(struct([]), 'struct'); % empty array of individual comments
+rsl.permVec=dat.permVec;
+rsl.playVec=dat.playVec;
+
+nbSnd=test.nbComb;
+nbScale=length(test.scale);
+
+for noScale=1:nbScale
+   for noSnd=1:nbSnd
+      rsl.hcom{noSnd}=get(dat.hcom{noSnd}, 'string'); % individual comments
+      posIc=get(dat.hIcon(noScale,noSnd),'position');
+      scale=test.scale(noScale);
+      posx=posIc(1);
+      dxx=dat.dxx;
+      dxI=dat.dxI;      
+      minx=scale.minn;
+      maxx=scale.maxx;
+      stepp=scale.stepp;      
+      a=(maxx-minx)/(1-2*dxx);
+      b=minx-a*dxx;
+      nx=a*(posx+dxI/2)+b;
+      rsl.mat(noScale,noSnd)=nx;
+   end
+end
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Timer 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+rsl.duration=etime(clock,dat.t0);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% generate a small report file 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+fid=reportTest(sesDat,rsl,'MULTIPLE COMPARISON 1D');
+
+% scales
+fprintf(fid,'%%%%%%%%%%%% scales ');eol(fid);eol(fid);
+for noScale=1:nbScale
+   fprintf(fid,'Scale #%d -- %s',noScale,test.scale(noScale).name);eol(fid);
+end
+
+% matrix results
+for noScale=1:nbScale
+   fprintf(fid,'SCALE #%d: ',noScale);
+   for noSnd=1:nbSnd
+       fprintf(fid,'%2.2f \t',rsl.mat(noScale,noSnd));
+    end
+eol(fid);
+end
+
+% COMMENTS
+fprintf(fid,'');eol(fid);
+fprintf(fid,'%%%%%%%%%%%% COMMENTS');eol(fid);
+
+for index = 1:nbSnd
+    com = rsl.hcom{dat.permVec(index)}; % individual comments
+    fprintf(fid,'Sound %d, marker %s\n',index,com);
+end
+
+fprintf(fid,'%s\n',rsl.gcom); % print general comments
+
+
+eol(fid);eol(fid);
+fclose(fid);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Save it
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+dat=get(hf,'userdata');
+saveTest(dat,rsl,'multiComp');
\ No newline at end of file