modify_mp.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. function modify_mp(fld,monkey,sessions)
  2. datadir = fld.procdatadir;
  3. logdir = fullfile(fld.basedir,'Datasets', monkey ,'log');
  4. fprintf('\n======================================================\n');
  5. fprintf(['-- Running modify_mp for ' monkey ' --\n']);
  6. fprintf('======================================================\n');
  7. MP = [];
  8. for sid = 1:length(sessions)
  9. % session info
  10. session = sessions{sid};
  11. q = strsplit(session,'_');
  12. cdate = q{2};
  13. block = str2num(q{3}(end-4));
  14. % load the data
  15. session_id = [monkey '_' cdate '_' num2str(block)];
  16. sessiondir = fullfile(datadir,monkey,session_id);
  17. try
  18. load(fullfile(sessiondir, [session_id '_channels.mat']));
  19. catch
  20. continue
  21. end
  22. new_gt = cell(0);
  23. new_sgt = cell(0);
  24. for ch = 1:size(mp,1)
  25. gt = mp.goodtrials(ch,:);
  26. % we shouldn't do this multiple times
  27. if iscell(gt)
  28. while size(gt,1)==1 && size(gt,2)==1
  29. gt = gt{1};
  30. end
  31. new_gt{ch} = gt;
  32. else
  33. new_gt{ch} = mp.goodtrials(ch,:);
  34. end
  35. sgt = mp.sample_wise_goodtrials(ch,:);
  36. if iscell(sgt)
  37. while size(sgt,1)==1 && size(sgt,2)==1
  38. sgt = sgt{1};
  39. end
  40. new_sgt{ch} = sgt;
  41. else
  42. new_sgt{ch} = mp.sample_wise_goodtrials(ch,:);
  43. end
  44. end
  45. mp.goodtrials = new_gt';
  46. mp.sample_wise_goodtrials = new_sgt';
  47. save(fullfile(sessiondir, [session_id '_channels.mat']),'mp');
  48. end