calError.m 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. %% calError.m
  2. %% Description: calculate the error rates, discard rates the ANOVA of error array
  3. %% Date: 04/12/2014
  4. %% Contact: zangxuelian@gmail.com
  5. function dataOut = calError(dataIn, Exp)
  6. %% calculate discard rate array
  7. % %% Array: o1e1 o1e2 o1e3 o1e4 o1e5 o1e6 o2e1 o2e2 o2e3
  8. % %% o2e4 o2e5 o2e6
  9. % %% disArray.p1...
  10. numOfEP = Exp.nEp + Exp.nEpT;
  11. dataTemp = [dataIn.train.err; dataIn.test.err; dataIn.train.dis; dataIn.test.dis];
  12. errArray = zeros(Exp.subNum, 2*(Exp.nEp + Exp.nEpT ));
  13. for j = 1 : Exp.subNum % for each subject
  14. for t = 0:1 % for old and new
  15. for m = 1:(numOfEP) % for EP 1:6
  16. temp = dataTemp(dataTemp.NSub == j & dataTemp.New1 == t & dataTemp.NE == m,:);
  17. if ~isempty(temp)
  18. numOfAllTrial = Exp.nTrl * Exp.numOfBlock.TrainEpoch/2 ;
  19. errArray(j, t*numOfEP+m) = 100*length(temp.NE)/numOfAllTrial;
  20. else
  21. errArray(j, t*numOfEP+m) = 0;
  22. end
  23. end
  24. end
  25. end
  26. dataOut.errSpssArray = errArray;
  27. %% discard trial
  28. dataTemp = [dataIn.train.dis; dataIn.test.dis];
  29. disArray = zeros(Exp.subNum, 2*(Exp.nEp + Exp.nEpT ));
  30. for j = 1 : Exp.subNum % for each subject
  31. % for iLeftRight = 1:2
  32. for t = 0:1 % for old and new
  33. for m = 1:(numOfEP) % for EP 1:6
  34. temp = dataTemp(dataTemp.NSub == j & dataTemp.New1 == t & dataTemp.NE == m,:);
  35. % if iLeftRight == 1% left
  36. if ~isempty(temp)
  37. numOfAllTrial = Exp.nTrl * Exp.numOfBlock.TrainEpoch/2 ;
  38. disArrayLeft(j, t*numOfEP+m) = 100*length(temp.NE)/numOfAllTrial;
  39. else
  40. disArrayLeft(j, t*numOfEP+m) = 0;
  41. end
  42. % else
  43. % temp = temp(temp.Crr2 == -2,:);
  44. % if ~isempty(temp)
  45. % numOfAllTrial = Exp.nTrl * Exp.numOfBlock.TrainEpoch/2 ;
  46. % disArrayRight(j, t*numOfEP+m) = 100*length(temp.NE)/numOfAllTrial;
  47. % else
  48. % disArrayRight(j, t*numOfEP+m) = 0;
  49. % end
  50. % end
  51. end
  52. end
  53. % end
  54. end
  55. dataOut.disSpssArray = disArray;
  56. end