ck_Load.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. function ck_Load(subj, sess, Do)
  2. % loads the (Blackroack) ephys PRF data and organizes it in trials
  3. % c.klink@nin.knaw.nl
  4. %% init ===================================================================
  5. if nargin<3
  6. fprintf('Not specified what to do. Taking defaults\n')
  7. Do.Load.Any = true;
  8. % these can be left to 'false', thse raw-raw data are not included in
  9. % the shared dataset due to size considerations. Load the 'Proc' files
  10. % below to get all the necessary information for this step.
  11. Do.Load.DigChan = false; % new files
  12. Do.Load.MUA = false; % new files
  13. Do.Load.LFP = false; % new files
  14. Do.Load.Behavior = false; % new files
  15. Do.Load.ProcMUA = true;
  16. Do.Load.ProcLFP = true;
  17. Do.Load.ProcBEH = true;
  18. Do.SyncTimes = true;
  19. Do.SaveUncut = false;
  20. Do.SaveMUA_perArray = true;
  21. Do.SaveLFP_perArray = true;
  22. end
  23. if nargin<2
  24. subj = 'M03';
  25. sess = '20180807_B2';
  26. fprintf(['Using defaults, SUBJ: ' subj ', SESS: ' sess '\n\n']);
  27. end
  28. setup = 'NIN';
  29. fprintf('=============================================================\n');
  30. fprintf(' Loading and processing data for %s, %s\n', subj, sess);
  31. fprintf('=============================================================\n');
  32. %% data location ==========================================================
  33. base_path = pwd;
  34. cd ../../
  35. SHARED_ROOT_FLD = pwd;
  36. cd(base_path);
  37. raw_fld = fullfile(SHARED_ROOT_FLD,'Raw_data','EPHYS','Data_blackrock');
  38. ch_fld = fullfile(SHARED_ROOT_FLD,'Raw_data','EPHYS','Channelmaps');
  39. pp_fld = fullfile(SHARED_ROOT_FLD,'Raw_data','EPHYS','Data_matlab');
  40. beh_fld = fullfile(SHARED_ROOT_FLD,'Raw_data','EPHYS','Log_pRF');
  41. save_fld = fullfile(SHARED_ROOT_FLD,'Preprocessed_data','EPHYS');
  42. %% load tools =============================================================
  43. addpath(genpath(fullfile(SHARED_ROOT_FLD,'Toolboxes')));
  44. %% Get digital channel contents ===========================================
  45. if Do.Load.DigChan
  46. cd(fullfile(raw_fld,subj,sess));
  47. nev_files = dir('*.nev');
  48. fprintf('=== Loading digital channel info ===\n');
  49. for i=1:length(nev_files)
  50. NEV=openNEV(fullfile(nev_files(i).folder,nev_files(i).name),...
  51. 'overwrite');
  52. N(i).TimeStamp = NEV.Data.SerialDigitalIO.TimeStamp;
  53. N(i).t0 = N(i).TimeStamp(1);
  54. N(i).DigData = NEV.Data.SerialDigitalIO.UnparsedData;
  55. N(i).bits = log2(single(N(i).DigData));
  56. N(i).sf = 30e3;
  57. N(i).fp_i = find(N(i).bits==1,1,'first');
  58. N(i).t_fp = N(i).TimeStamp(N(i).fp_i);
  59. clear NEV
  60. end
  61. fprintf('Done!\n');
  62. cd(base_path);
  63. end
  64. % get the channelmapping
  65. if strcmp(subj,'M03')
  66. C=load(fullfile(ch_fld,'channel_area_mapping_M03'));
  67. elseif strcmp(subj,'M04')
  68. C=load(fullfile(ch_fld,'channel_area_mapping_M04'));
  69. end
  70. %% Get MUA ================================================================
  71. if Do.Load.MUA
  72. cd(fullfile(pp_fld,subj,sess));
  73. mua_files = dir('MUA*.mat');
  74. fprintf('=== Loading preprocessed MUA ===\n');
  75. for i=1:length(mua_files)
  76. fprintf([num2str(i) '/' num2str(length(mua_files)) '\n']);
  77. load(fullfile(mua_files(i).folder,mua_files(i).name));
  78. M(i).chan=channelDataMUA;% (1:128);
  79. M(i).sf = 1e3;
  80. % create timeline based on digital channel
  81. M(i).tsec = 0:1/M(i).sf:(1/M(i).sf)*length(M(i).chan{1});
  82. M(i).tsec(end)=[];
  83. clear channelDataMUA
  84. end
  85. fprintf('Done!\n');
  86. cd(base_path);
  87. end
  88. %% Get LFP ================================================================
  89. if Do.Load.LFP
  90. cd(fullfile(pp_fld,subj,sess));
  91. lfp_files = dir('LFP*.mat');
  92. fprintf('=== Loading preprocessed LFP ===\n');
  93. for i=1:length(lfp_files)
  94. fprintf([num2str(i) '/' num2str(length(lfp_files)) '\n']);
  95. load(fullfile(lfp_files(i).folder,lfp_files(i).name));
  96. L(i).chan=channelDataLFP(1:128);
  97. L(i).t = M(i).tsec(1):1/L(i).chan{1}.LFPsamplerate:M(i).tsec(end);
  98. clear channelDataLFP
  99. end
  100. fprintf('Done!\n');
  101. cd(base_path);
  102. end
  103. %% Get behavioral log =====================================================
  104. if Do.Load.Behavior
  105. cd(fullfile(beh_fld,setup,subj,[subj '_' sess]))
  106. fprintf('=== Loading Behavioral logs ===\n');
  107. recn = 1;
  108. mat_fn = dir('Log*Run*.mat');
  109. for m=1:length(mat_fn)
  110. fprintf([mat_fn(m).name '\n']);
  111. B(recn,m)=load(fullfile(mat_fn(m).folder,mat_fn(m).name));
  112. MTi = find(arrayfun(@(x) strcmp(x.type,'MRITrigger'),...
  113. B(recn,m).Log.Events)==1,1,'first');
  114. if m==1
  115. triggertime=B(recn,m).Log.Events(MTi).t;
  116. end
  117. for tt=1:length(B(recn,m).Log.Events)
  118. B(recn,m).Log.Events(tt).t_mri = B(recn,m).Log.Events(tt).t - ...
  119. triggertime;
  120. end
  121. end
  122. % also get the stimulus
  123. S = load('RetMap_Stimulus.mat');
  124. S = S.ret_vid;
  125. for j=1:size(S,2)
  126. ori = S(j).orient(1);
  127. imnr = mod(j,B(recn).StimObj.Stm.RetMap.nSteps/8);
  128. if imnr==0; imnr=B(recn).StimObj.Stm.RetMap.nSteps/8;end
  129. img = S(imnr).img{1};
  130. img(img==255 | img==0)=1;
  131. img(img~=1)=0;
  132. STIM.img{j}=imrotate(img,-ori,'nearest','crop');
  133. end
  134. STIM.blank = uint8(zeros(size(STIM.img{j})));
  135. fprintf(['Saving ' fullfile(save_fld,[subj '_' sess '_STIM\n'])]);
  136. warning off; mkdir(fullfile(save_fld,subj,sess)); warning on
  137. save(fullfile(save_fld,subj,sess,[subj '_' sess '_STIM']),'STIM','B','-v7.3');
  138. fprintf('Done!\n');
  139. cd(base_path);
  140. end
  141. %% Load already processed files ===========================================
  142. warning off
  143. if Do.Load.ProcMUA
  144. fprintf(['Loading ' fullfile(save_fld,subj,sess,'MUA',...
  145. [subj '_' sess '_uncut_MUA']) '\n']);
  146. load(fullfile(save_fld,subj,sess,'MUA',...
  147. [subj '_' sess '_uncut_MUA']));
  148. end
  149. if Do.Load.ProcLFP
  150. fprintf(['Loading ' fullfile(save_fld,subj,sess,'LFP',...
  151. [subj '_' sess '_uncut_LFP']) '\n']);
  152. load(fullfile(save_fld,subj,sess,'LFP',...
  153. [subj '_' sess '_uncut_LFP']));
  154. end
  155. if Do.Load.ProcBEH
  156. fprintf(['Loading ' fullfile(save_fld,subj,sess,[subj '_' sess '_STIM']) '\n']);
  157. load(fullfile(save_fld,subj,sess,[subj '_' sess '_STIM']));
  158. end
  159. warning on
  160. %% Sync timelines =========================================================
  161. if Do.SyncTimes
  162. fprintf('=== Syncing time-bases across recordings and logs ===\n');
  163. % get log-time of all and first 'newpos'
  164. fprintf('Getting log-times of all and first ''newpos''\n');
  165. for b=1:length(B)
  166. log_t = [B(b).Log.Events.t];
  167. B(b).log_newpos = arrayfun(@(x) strcmp(x.type,'NewPosition'),B(b).Log.Events);
  168. B(b).t_allnp=log_t(B(b).log_newpos);
  169. B(b).allnp_img=[B(b).Log.Events(B(b).log_newpos).StimName];
  170. B(b).t_firstnp=B(b).t_allnp(1);
  171. end
  172. % get rec-times of all 'newpos'
  173. fprintf('Getting rec-times of all ''newpos''\n');
  174. for n=1:length(N)
  175. N(n).tsec = single(N(n).TimeStamp)./N(n).sf;
  176. npi = find(N(n).bits==1);
  177. N(n).np_samp = N(n).TimeStamp(npi);
  178. N(n).np_sec = N(n).tsec(npi);
  179. % split runs
  180. for b=1:length(B)
  181. ii = (b-1)*length(B(b).allnp_img)+1 : ...
  182. b*length(B(b).allnp_img);
  183. N(n).run(b).np_sec = N(n).np_sec(ii);
  184. N(n).run(b).barpos = B(b).allnp_img;
  185. N(n).run(b).stim_sec = N(n).run(b).np_sec(N(n).run(b).barpos~=0);
  186. end
  187. end
  188. fprintf('Done!\n');
  189. end
  190. %% Saving the (rawish) MUA & LFP data =====================================
  191. if Do.SaveUncut
  192. fprintf('=== Saving the un-cut data =====\n');
  193. fprintf(fullfile(save_fld,subj,sess,'MUA',...
  194. [subj '_' sess '_uncut_MUA\n']));
  195. warning off; mkdir(fullfile(save_fld,subj,sess,'MUA')); warning on
  196. save(fullfile(save_fld,subj,sess,'MUA',...
  197. [subj '_' sess '_uncut_MUA']),'M','B','N','C','-v7.3');
  198. fprintf(fullfile(save_fld,subj,sess,'LFP',...
  199. [subj '_' sess '_uncut_LFP\n']));
  200. warning off; mkdir(fullfile(save_fld,subj,sess,'LFP')); warning on
  201. save(fullfile(save_fld,subj,sess,'LFP',...
  202. [subj '_' sess '_uncut_LFP']),'L','B','N','C','-v7.3');
  203. fprintf('Done!\n');
  204. end
  205. %% Get MUA responses for each stim-position / channel =====================
  206. if Do.SaveMUA_perArray
  207. win = [0.05 B(1).Par.TR*B(1).StimObj.Stm.RetMap.TRsPerStep]; %[start stop] in sec
  208. fprintf('=== Getting MUA response per trial =====\n');
  209. for m=1:length(M) %>> while testing, do only 1 array
  210. fprintf('- Array %d -', m);
  211. fprintf('\nChannel: 000');
  212. for c=1:length(M(m).chan)
  213. fprintf('\b\b\b\b%3d\t',c);
  214. M(m).ch(c).coll = []; M(m).ch(c).coll_odd = []; M(m).ch(c).coll_even = [];
  215. M(m).ch(c).BL = []; M(m).ch(c).BL_odd = []; M(m).ch(c).BL_even = [];
  216. % collect traces and average
  217. for r=1:length(N(m).run)
  218. start_samp = find(M(m).tsec >= N(m).run(r).stim_sec(1),1,'first');
  219. stop_samp = find(M(m).tsec >= N(m).run(r).stim_sec(end)+win(2),1,'first');
  220. if r==1
  221. nsamp = stop_samp-start_samp;
  222. end
  223. M(m).ch(c).coll = [M(m).ch(c).coll; ...
  224. M(m).chan{c}(start_samp:start_samp+nsamp)'];
  225. M(m).run(r).tsec = M(m).tsec(start_samp:start_samp+nsamp);
  226. M(m).ch(c).BL = [M(m).ch(c).BL; ...
  227. M(m).chan{c}(start_samp-1000:start_samp)'];
  228. if mod(r,2) % odd
  229. M(m).ch(c).coll_odd = [M(m).ch(c).coll_odd; ...
  230. M(m).chan{c}(start_samp:start_samp+nsamp)'];
  231. M(m).ch(c).BL_odd = [M(m).ch(c).BL_odd; ...
  232. M(m).chan{c}(start_samp-1000:start_samp)'];
  233. else % even
  234. M(m).ch(c).coll_even = [M(m).ch(c).coll_even; ...
  235. M(m).chan{c}(start_samp:start_samp+nsamp)'];
  236. M(m).ch(c).BL_even = [M(m).ch(c).BL_even; ...
  237. M(m).chan{c}(start_samp-1000:start_samp)'];
  238. end
  239. end
  240. % average over runs
  241. mMUA(c).runs = M(m).ch(c).coll;
  242. SIG = [];
  243. for r=1:size(M(m).ch(c).BL,1)
  244. SIG = [SIG; M(m).ch(c).coll(r,:)-...
  245. mean(M(m).ch(c).BL(r,:),2)];
  246. end
  247. mMUA(c).mean = mean(SIG);
  248. mMUA(c).std = std(SIG);
  249. mMUA(c).BL = mean(M(m).ch(c).BL);
  250. mMUA_odd(c).runs = M(m).ch(c).coll_odd;
  251. SIG_odd = [];
  252. for r=1:size(M(m).ch(c).BL_odd,1)
  253. SIG_odd = [SIG_odd; M(m).ch(c).coll_odd(r,:)-...
  254. mean(M(m).ch(c).BL_odd(r,:),2)];
  255. end
  256. mMUA_odd(c).mean = mean(SIG_odd);
  257. mMUA_odd(c).std = std(SIG_odd);
  258. mMUA_odd(c).BL = mean(M(m).ch(c).BL_odd);
  259. mMUA_even(c).runs = M(m).ch(c).coll_even;
  260. SIG_even = [];
  261. for r=1:size(M(m).ch(c).BL_even,1)
  262. SIG_even = [SIG_even; M(m).ch(c).coll_even(r,:)-...
  263. mean(M(m).ch(c).BL_even(r,:),2)];
  264. end
  265. mMUA_even(c).mean = mean(SIG_even);
  266. mMUA_even(c).std = std(SIG_even);
  267. mMUA_even(c).BL = mean(M(m).ch(c).BL_even);
  268. % split by bar position
  269. for b=1:length(N(m).run(1).stim_sec)
  270. t1i= find(M(m).run(1).tsec >= ...
  271. N(m).run(1).stim_sec(b)+win(1),1,'first');
  272. t2i= find(M(m).run(1).tsec <= ...
  273. N(m).run(1).stim_sec(b)+win(2),1,'last');
  274. act_chunk = mMUA(c).mean(t1i:t2i);
  275. mMUA(c).bar(b) = mean(act_chunk);
  276. clear act_chunk
  277. act_chunk_odd = mMUA_odd(c).mean(t1i:t2i);
  278. mMUA_odd(c).bar(b) = mean(act_chunk_odd);
  279. clear act_chunk_odd
  280. act_chunk_even = mMUA_even(c).mean(t1i:t2i);
  281. mMUA_even(c).bar(b) = mean(act_chunk_even);
  282. clear act_chunk_even
  283. end
  284. end
  285. fprintf('\n');
  286. fprintf('Saving the averaged MUA responses for array %d...\n', m);
  287. % warning off; [~,~]=mkdir(fullfile(save_fld,subj,sess,'MUA')); warning on
  288. % save(fullfile(save_fld,subj,sess,'MUA',...
  289. % [subj '_' sess '_array_' num2str(m) '_mMUA']),'mMUA','C','-v7.3');
  290. clear mMUA
  291. save(fullfile(save_fld,subj,sess,'MUA',...
  292. [subj '_' sess '_array_' num2str(m) '_mMUA_odd']),'mMUA_odd','C','-v7.3');
  293. clear mMUA_odd
  294. save(fullfile(save_fld,subj,sess,'MUA',...
  295. [subj '_' sess '_array_' num2str(m) '_mMUA_even']),'mMUA_even','C','-v7.3');
  296. clear mMUA_even
  297. end
  298. clear M
  299. fprintf('All done!\n');
  300. end
  301. %% Get LFP responses for each stim-position / channel =====================
  302. if Do.SaveLFP_perArray
  303. HasLicense = CheckLicenseAvailable('Signal_Toolbox',5,600);
  304. end
  305. if ~HasLicense
  306. fprintf('Cannot do LFP analysis right now due to lack of licenses\n');
  307. fprintf('Try again later (an/or send email to other users..)\n');
  308. end
  309. if Do.SaveLFP_perArray && HasLicense
  310. win = [0.05 B(1).Par.TR*B(1).StimObj.Stm.RetMap.TRsPerStep]; %[start stop] in sec
  311. % chronux specs
  312. chron.tapers = [5 9];
  313. chron.Fs = 500; % sampling freq
  314. chron.fpass = [1 150]; % [fmin fmax]
  315. chron.mwin = [0.500 0.050]; % moving window
  316. fprintf('=== Getting LFP response per trial =====\n');
  317. for m=1:length(L) %>> while testing, do only 1 array
  318. fprintf('- Array %d -', m);
  319. fprintf('\nChannel: 000');
  320. L(m).freq(1).name = 'Theta (4-8)';
  321. L(m).freq(1).fband = [3.9 8];
  322. L(m).freq(2).name = 'Alpha (8-16)';
  323. L(m).freq(2).fband = [8 16];
  324. L(m).freq(3).name = 'Beta (16-30)';
  325. L(m).freq(3).fband = [16 30];
  326. L(m).freq(4).name = 'Low gamma (30-60)';
  327. L(m).freq(4).fband = [30 60];
  328. L(m).freq(5).name = 'High gamma (60-120)';
  329. L(m).freq(5).fband = [60 120];
  330. for c=1:length(L(m).chan)
  331. fprintf('\b\b\b\b%3d\t',c);
  332. % get power traces per frequency range
  333. [L(m).spect(c).S,L(m).spect(c).t,L(m).spect(c).f] = ...
  334. mtspecgramc(L(m).chan{c}.data,chron.mwin,chron);
  335. L(m).spect(c).tsec = L(m).spect(c).t+L(m).t(1);
  336. for fb = 1:length(L(m).freq)
  337. fsel = L(m).spect(c).f > L(m).freq(fb).fband(1) & ...
  338. L(m).spect(c).f<L(m).freq(fb).fband(2);
  339. L(m).ch(c).freq(fb).trace = ...
  340. mean(L(m).spect(c).S(:,fsel),2);
  341. L(m).ch(c).freq(fb).coll = [];
  342. L(m).ch(c).freq(fb).BL = [];
  343. L(m).ch(c).freq(fb).coll_odd = [];
  344. L(m).ch(c).freq(fb).BL_odd = [];
  345. L(m).ch(c).freq(fb).coll_even = [];
  346. L(m).ch(c).freq(fb).BL_even = [];
  347. end
  348. % collect traces and average
  349. for r=1:length(N(m).run)
  350. start_samp = find(L(m).spect(c).tsec >= ...
  351. N(m).run(r).stim_sec(1),1,'first');
  352. stop_samp = find(L(m).spect(c).tsec >= ...
  353. N(m).run(r).stim_sec(end)+win(2),1,'first');
  354. if r==1
  355. nsamp = stop_samp-start_samp;
  356. end
  357. for fb = 1:length(L(m).freq)
  358. L(m).ch(c).freq(fb).coll = [L(m).ch(c).freq(fb).coll; ...
  359. L(m).ch(c).freq(fb).trace(start_samp:start_samp+nsamp)'];
  360. L(m).ch(c).freq(fb).BL = [L(m).ch(c).freq(fb).BL; ...
  361. L(m).ch(c).freq(fb).trace(start_samp-500:start_samp)'];
  362. if mod(r,2) % odd
  363. L(m).ch(c).freq(fb).coll_odd = [L(m).ch(c).freq(fb).coll_odd; ...
  364. L(m).ch(c).freq(fb).trace(start_samp:start_samp+nsamp)'];
  365. L(m).ch(c).freq(fb).BL_odd = [L(m).ch(c).freq(fb).BL_odd; ...
  366. L(m).ch(c).freq(fb).trace(start_samp-500:start_samp)'];
  367. else % even
  368. L(m).ch(c).freq(fb).coll_even = [L(m).ch(c).freq(fb).coll_even; ...
  369. L(m).ch(c).freq(fb).trace(start_samp:start_samp+nsamp)'];
  370. L(m).ch(c).freq(fb).BL_even = [L(m).ch(c).freq(fb).BL_even; ...
  371. L(m).ch(c).freq(fb).trace(start_samp-500:start_samp)'];
  372. end
  373. end
  374. L(m).run(r).tsec = L(m).spect(c).tsec(start_samp:start_samp+nsamp);
  375. end
  376. % average over runs
  377. for fb = 1:length(L(m).freq)
  378. mLFP(c).freq(fb).runs = L(m).ch(c).freq(fb).coll;
  379. mLFP(c).freq(fb).mean = mean(L(m).ch(c).freq(fb).coll);
  380. mLFP(c).freq(fb).std = std(L(m).ch(c).freq(fb).coll);
  381. mLFP(c).freq(fb).BL = mean(mean(L(m).ch(c).freq(fb).BL));
  382. mLFP_odd(c).freq(fb).runs = L(m).ch(c).freq(fb).coll_odd;
  383. mLFP_odd(c).freq(fb).mean = mean(L(m).ch(c).freq(fb).coll_odd);
  384. mLFP_odd(c).freq(fb).std = std(L(m).ch(c).freq(fb).coll_odd);
  385. mLFP_odd(c).freq(fb).BL = mean(mean(L(m).ch(c).freq(fb).BL_odd));
  386. mLFP_even(c).freq(fb).runs = L(m).ch(c).freq(fb).coll_even;
  387. mLFP_even(c).freq(fb).mean = mean(L(m).ch(c).freq(fb).coll_even);
  388. mLFP_even(c).freq(fb).std = std(L(m).ch(c).freq(fb).coll_even);
  389. mLFP_even(c).freq(fb).BL = mean(mean(L(m).ch(c).freq(fb).BL_even));
  390. % split by bar position
  391. for b=1:length(N(m).run(1).stim_sec)
  392. t1i= find(L(m).run(1).tsec >= ...
  393. N(m).run(1).stim_sec(b)+win(1),1,'first');
  394. t2i= find(L(m).run(1).tsec <= ...
  395. N(m).run(1).stim_sec(b)+win(2),1,'last');
  396. act_chunk = mLFP(c).freq(fb).mean(t1i:t2i);
  397. mLFP(c).freq(fb).bar(b) = mean(act_chunk);
  398. clear act_chunk
  399. act_chunk_odd = mLFP_odd(c).freq(fb).mean(t1i:t2i);
  400. mLFP_odd(c).freq(fb).bar(b) = mean(act_chunk_odd);
  401. clear act_chunk_odd
  402. act_chunk_even = mLFP_even(c).freq(fb).mean(t1i:t2i);
  403. mLFP_even(c).freq(fb).bar(b) = mean(act_chunk_even);
  404. clear act_chunk_even
  405. end
  406. end
  407. end
  408. fprintf('\n');
  409. % fprintf('Saving the averaged LFP responses for array %d...\n', m);
  410. % warning off; mkdir(fullfile(save_fld,subj,sess,'LFP')); warning on
  411. % save(fullfile(save_fld,subj,sess,'LFP',...
  412. % [subj '_' sess '_array_' num2str(m) '_mLFP']),'mLFP','C','-v7.3');
  413. clear mLFP
  414. warning off; mkdir(fullfile(save_fld,subj,sess,'LFP')); warning on
  415. save(fullfile(save_fld,subj,sess,'LFP',...
  416. [subj '_' sess '_array_' num2str(m) '_mLFP_odd']),'mLFP_odd','C','-v7.3');
  417. clear mLFP_odd
  418. warning off; mkdir(fullfile(save_fld,subj,sess,'LFP')); warning on
  419. save(fullfile(save_fld,subj,sess,'LFP',...
  420. [subj '_' sess '_array_' num2str(m) '_mLFP_even']),'mLFP_even','C','-v7.3');
  421. clear mLFP_even
  422. end
  423. clear L
  424. fprintf('All done!\n');
  425. end