collect_MUA_v2.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. %%% collect MUA temp files - THINGS
  2. % v.2-Gemini
  3. % 2022 P. Papale fecit
  4. clear all
  5. addpath(genpath('\_code\code_utils_v2\'));
  6. % constants
  7. % monkey = 'monkeyF';
  8. monkey = 'monkeyN';
  9. datadir_gen = '\';
  10. temp_folder = '\_temps\';
  11. trial_length = .3;
  12. pre_trial = .1;
  13. if monkey == 'monkeyN'
  14. dates = {'20220111','20220112','20220113','20220114'};
  15. partitions = 1:8;
  16. else
  17. dates = {'20240112','20240115','20240116','20240118'};
  18. partitions = 1:4;
  19. end
  20. log_prefix = 'THINGS_';
  21. ALLMAT = [];
  22. ALLMUA = [];
  23. for day = 1:length(dates)
  24. clear datadir all_folders blocks
  25. datadir = [datadir_gen,monkey,'\',dates{day},'\'];
  26. disp(['%%%%%% DAY: ',num2str(day),' ...']);
  27. all_folders = dir(datadir);
  28. all_folders = all_folders([all_folders(:).isdir]);
  29. all_folders = all_folders(~ismember({all_folders(:).name},{'.','..'}));
  30. blocks = length(all_folders);
  31. for block_number = 1:blocks
  32. % block_number = str2num(all_folders(b).name(7:end));
  33. tic
  34. disp(['%%% Block: ',num2str(block_number),' ...']);
  35. block_mua = [];
  36. for partition_idx = partitions
  37. clear instance_name temp_block_mua
  38. partition_name = ['partition',num2str(partition_idx),'_B',sprintf('%03.0f', block_number)];
  39. if isfile([datadir_gen,monkey,temp_folder,'TEMP_MUA_',dates{day},'_',partition_name,'.mat'])
  40. if partition_idx == 1
  41. clear temp_MAT
  42. % load MAT temps
  43. load([datadir_gen,monkey,temp_folder,'TEMP_MAT_',dates{day},'_B',num2str(block_number),'.mat']);
  44. ALLMAT = [ALLMAT; temp_MAT];
  45. end
  46. % load MUA temps
  47. load([datadir_gen,monkey,temp_folder,'TEMP_MUA_',dates{day},'_',partition_name,'.mat']);
  48. block_mua = [block_mua; temp_block_mua];
  49. disp(['% (Partiton: ',num2str(partition_idx),' done!)']);
  50. end
  51. end
  52. ALLMUA = [ALLMUA block_mua];
  53. disp(['%%% ... done in: ',num2str(round(toc)),'s'])
  54. end
  55. end
  56. post_trial = trial_length-pre_trial;
  57. tb =-pre_trial*1000:1:(post_trial)*1000;
  58. filename = [datadir_gen,monkey,'/',log_prefix,'MUA_trials.mat'];
  59. save(filename,'ALLMUA','ALLMAT','tb','-v7.3')
  60. pause(5)