FindGameTdcsFrameChoiceFiles.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. function DL=FindGameTdcsFiles(ParentDir,SubVec,SessVec,RunVec,InMaskChar,ExMaskChar,BatchPath)
  2. % FindFiles
  3. % EMEGS - Electro Magneto Encephalography Software
  4. % ? Copyright 2005 Markus Junghoefer & Peter Peyk
  5. % Implemented programs from: Andrea de Cesarei, Thomas Gruber,
  6. % Olaf Hauk, Andreas Keil, Olaf Steinstraeter, Nathan Weisz
  7. % and Andreas Wollbrink.
  8. %
  9. % This program is free software; you can redistribute it and/or
  10. % modify it under the terms of the GNU General Public License
  11. % as published by the Free Software Foundation; either version 3
  12. % of the License, or (at your option) any later version.
  13. %
  14. % This program is distributed in the hope that it will be useful,
  15. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. % GNU General Public License for more details.
  18. % You should have received a copy of the GNU General Public License
  19. % along with this program; if not, write to the Free Software
  20. % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. if nargin<8; MegEegStatusVec=[]; end
  22. if nargin<7; BatchPath=[]; end
  23. if nargin<6; ExMaskChar=[]; end
  24. if nargin<5; InMaskChar=[]; end
  25. if nargin<4; RunVec=[]; end
  26. if nargin<3; SessVec=[]; end
  27. if nargin<2; SubVec=[]; end
  28. if nargin<1; ParentDir=[]; end
  29. %100 Ano
  30. %200 Cat
  31. % Trigger Codes:
  32. %
  33. % Choice:
  34. % 10 = kein Risiko eingegangen, Gain Trial (noRiskGT)
  35. % 11 = Risiko eingegangen, Gain Trial (riskGT)
  36. % 12 kein Risiko eingegangen, Loss Trial (noRiskLT)
  37. % 13 = Risiko eingegangen, Loss Trial (riskLT)
  38. %
  39. %
  40. %
  41. %
  42. % Safety: 25 = für sichere 10cent entschieden (safe10G)
  43. % 26 = für sichere 15cent Verlust entschieden (safe15L)
  44. % 35= für sichere 20cent entschieden (safe20G)
  45. % 36= für sichere 30cent Verlust entschieden (safe30L)
  46. % 45= für sichere 30cent entschieden (safe30G)
  47. % 46= für sichere 45cent Verlust entschieden (safe45L)
  48. % 55 = für sichere 40cent entschieden (safe40G)
  49. % 56 = für sichere 60cent Verlust entschieden (safe60L)
  50. %
  51. %
  52. %
  53. %
  54. % Wenn man die Risiko Option gewählt hat!
  55. % RiskFeedback:
  56. % 21 = 25cent verloren (f25L)
  57. % 22 = 25cent gewonnen (f25G)
  58. % 31 = 50cent verloren (f50L)
  59. % 32 = 50cent gewonnen (f50G)
  60. % 41 = 75cent verloren (f75L)
  61. % 42 = 75cent gewonnen (f75G)
  62. % 51 = 100cent verloren (f100L)
  63. % 52 = 100cent gewonnen (f100G)
  64. if isempty(ExMaskChar); ExMaskChar=char(''); end
  65. if isempty(InMaskChar); InMaskChar=char(''); end
  66. if isempty(RunVec); RunVec=[0]; end %1 2
  67. if isempty(SessVec); SessVec=[1]; end %1 2
  68. if isempty(SubVec); SubVec=[42 65 66]; end % 1 2 9 10 17 18 25 26 51 53 54 59 61 62 63 67 69 70 71 75 76 77 78 80
  69. if isempty(ParentDir); ParentDir='Z:\kroker\GameTdcsFrameBetween\MEG\GameTdcsFrameBetweenChoiceAna'; end
  70. if isempty(BatchPath); BatchPath='Z:\kroker\GameTdcsFrameBetween\MEG\GameTdcsFrameBetweenChoiceAna\00Batches'; end
  71. %ExMaskChar=char('*.mrk','*.bak','*.dsc','*.log','*.segments','BadChannels');
  72. %InMaskChar=char('*AEM');
  73. InMaskChar=char('*110','*111','*112','*113','*210','*211','*212','*213');
  74. %InMaskChar=char('*.at110&111&112&113.100.MN5.m4','*.at210&211&212&213.100.MN5.m4'); %Corr Expected Value
  75. %InMaskChar=char('*app110','*app111','*app112','*app113','*app210','*app211','*app212','*app213');
  76. %InMaskChar=char('*at00*');
  77. %InMaskChar=char('*i110','*i111','*i112','*i113'); %,'*i210','*i211','*i212','*i213');
  78. %InMaskChar=char('*.pmg');
  79. %InMaskChar=char('*.cot');
  80. %InMaskChar=char('*ses.ctf.*');
  81. %BatchFileChar=['at-post-gainloss-anocat']
  82. %BatchFileChar=['AEM']
  83. BatchFileChar=['Calc-MN5']
  84. %BatchFileChar=['App2at']
  85. %BatchFileChar=['Calc-MN5-ML']
  86. %BatchFileChar=['i-Files']
  87. %BatchFileChar=['Stats']
  88. %BatchFileChar=['pmg']
  89. %BatchFileChar=['cot']
  90. %BatchFileChar=['ses.ctf']
  91. %BatchFileChar=['at111-112-121-122-211-212-221-222.100.MN5.rep']
  92. StudyStr='GTB';
  93. DL=[];
  94. RenameStatus=0
  95. for SessIndTmp=1:length(SessVec)
  96. SessInd=SessVec(SessIndTmp);
  97. SessIndStr=int2str(SessInd);
  98. for InMaskInd=1:size(InMaskChar,1)
  99. InMask=deblank(InMaskChar(InMaskInd,:))
  100. for SubIndTmp=1:length(SubVec)
  101. SubInd=SubVec(SubIndTmp);
  102. SubIndStr=int2str(SubInd);
  103. if SubInd<10;
  104. SubIndStr=['C0',SubIndStr];
  105. else
  106. SubIndStr=['C',SubIndStr];
  107. end
  108. for RunIndTmp=1:length(RunVec)
  109. RunInd=RunVec(RunIndTmp);
  110. RunIndStr=int2str(RunInd);
  111. if RunInd>0
  112. Path=[ParentDir,filesep,StudyStr,'-',SubIndStr,filesep,StudyStr,'-',SubIndStr,'-',SessIndStr,filesep,StudyStr,'-',SubIndStr,'-',RunIndStr,'.ds',filesep]
  113. else
  114. Path=[ParentDir,filesep,StudyStr,'-',SubIndStr,filesep,StudyStr,'-',SubIndStr,'-',SessIndStr,filesep]
  115. end
  116. PathMask=[Path,InMask]
  117. D=dir(PathMask)
  118. for k=length(D):-1:1
  119. FilePath=[Path,D(k).name];
  120. TakeFile=1;
  121. ExMaskInd=1;
  122. while TakeFile & ExMaskInd<=size(ExMaskChar,1)
  123. ExMask=deblank(ExMaskChar(ExMaskInd,:));
  124. if ~isempty(findstr(FilePath,ExMask))
  125. TakeFile=0;
  126. end
  127. ExMaskInd=ExMaskInd+1;
  128. end
  129. if TakeFile
  130. if RenameStatus
  131. RenFilePath=[Path,StudyStr,'-',D(k).name];
  132. copyfile(FilePath,RenFilePath,'writable');
  133. delete(FilePath);
  134. FilePath=RenFilePath;
  135. RenFilePath=[];
  136. end
  137. if isempty(DL)
  138. DL=char(FilePath);
  139. else
  140. DL=char(DL,FilePath);
  141. end
  142. end
  143. end
  144. end
  145. end
  146. end
  147. end
  148. if RenameStatus; return; end
  149. if isempty(DL);
  150. fprintf(1,['Sorry, no files with mask "',InMaskChar,'" found ...']); return;
  151. end
  152. if ~isempty(BatchPath)
  153. DefBatchFilePath=[BatchPath,filesep,'Batch.',BatchFileChar,'.rep']
  154. SaveFileMat(DL,[],DefBatchFilePath);
  155. end
  156. return;