123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- %% Load Ind mat files
- % calls accuplot_mini requiring the Accusleep from Zeke Barger
- % each mat file contains four animals channels 1-4 -> first animal channels 5-8 -> second animal etc.
- % ch 1 = visual cortex right side, ch 2 = superior colliculus right side
- % ch 3 = superior colliculus left side, ch 4 = visual cortex left side
- base_dir=uigetdir(pwd); % point to directory of matfiles
- mat=dir(fullfile(base_dir,'*.mat')); % list of files
- nfiles=length(mat);
- %%
- % initiates arrays for visual cortex (VC) and superior colliculus (SC)
- VC=[];
- SC=[];
- for thisF=1:nfiles
- in_mat=fullfile(base_dir,mat(thisF).name);
- data=load(in_mat);
- EEG=data.d; % d1,d2,d3,d4 (four animals per file) EEG=data x chan
- spectra=[];
- %loop for channels 1:4
- %accuplot function ==> G.spectrogram for each channel
- for ii=1:4
- [G,fAxis,showFreqs]=accuplot_mini(EEG, ii, 1000); %takes EEG, ch, fs
- % spektrum
- spe=mean(G.spectrogram,1);
- m=mean(spe);
- normSpe=spe/m; % normalisation to mean power
- %plot(fAxis(showFreqs),normSpe)
- spectra=cat(1,spectra,normSpe);
- end
- % division into VC and SC
- VC=cat(3,VC,spectra([1,4],:));
- SC=cat(3,SC,spectra([2,3],:));
- end
- %%
- % dividing each file into group_treatment
- KO_veh=[1,5,9,26,30,34,37,41,45,39,43,47,15,19,23,51,55,59,52,56,60,62,66,70,64,68,72,...
- 90,94,98,100,104,108,103,107,111,137,141,145,161,165,169,163,167,171];
- KO_pfe=[3,7,11,13,17,21,16,20,24,50,54,58,74,78,82,76,80,84,...
- 88,92,96,113,117,121,124,128,132,126,130,134,102,106,110,138,142,146,139,143,147,149,153,157,151,155,159];
- WT_veh=[28,32,36,38,42,46,14,18,22,49,53,57,61,65,69,...
- 89,93,97,91,95,99,112,116,120,114,118,122,127,131,135,150,154,158,160,164,168,162,166,170,172:174];
- WT_pfe=[2,6,10,4,8,12,25,29,33,27,31,35,40,44,48,63,67,71,73,77,81,75,79,83,85:87,...
- 115,119,123,125,129,133,101,105,109,136,140,144,148,152,156];
- %% Mean and figures
- mKOve_vc=mean(VC(:,:,KO_veh),3);
- mKOpf_vc=mean(VC(:,:,KO_pfe),3);
- mWTve_vc=mean(VC(:,:,WT_veh),3);
- mWTpf_vc=mean(VC(:,:,WT_pfe),3);
- figure(1)
- subplot(211)
- hold on
- plot(fAxis(showFreqs),mWTve_vc','k')
- plot(fAxis(showFreqs),mWTpf_vc','b')
- subplot(212)
- hold on
- plot(fAxis(showFreqs),mKOve_vc','k')
- plot(fAxis(showFreqs),mKOpf_vc','b')
- mKOve_sc=mean(SC(:,:,KO_veh),3);
- mKOpf_sc=mean(SC(:,:,KO_pfe),3);
- mWTve_sc=mean(SC(:,:,WT_veh),3);
- mWTpf_sc=mean(SC(:,:,WT_pfe),3);
- figure(2)
- subplot(211)
- hold on
- plot(fAxis(showFreqs),mWTve_sc','k')
- plot(fAxis(showFreqs),mWTpf_sc','b')
- subplot(212)
- hold on
- plot(fAxis(showFreqs),mKOve_sc','k')
- plot(fAxis(showFreqs),mKOpf_sc','b')
- % average of spectra
- %% save spectrum for each group
- s.VCko=VC(:,:,KO_veh);
- s.VCwt=VC(:,:,WT_veh);
- s.SCko=SC(:,:,KO_veh);
- s.SCwt=SC(:,:,WT_veh);
- s.VCkoP=VC(:,:,KO_pfe);
- s.VCwtP=VC(:,:,WT_pfe);
- s.SCkoP=SC(:,:,KO_pfe);
- s.SCwtP=SC(:,:,WT_pfe);
- path1='C:\Users\...'; % path to output
- IDs=strcat(path1,'\SSVEPspectra.mat'); % name of output file
- save(IDs, 's');
|