123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- %% ANALYZE THE 5 Hz LOGS OF THE EYE POSITION DATA
- %% EPHYS ==================================================================
- cd ..
- bf = fullfile(pwd);
- cd 'Analysis_code'
- f = {fullfile(bf,'Preprocessed_data','EPHYS',...
- 'M03','20180807_B2','M03_20180807_B2_STIM.mat'),...
- fullfile(bf,'Preprocessed_data','EPHYS',...
- 'M04','20181004_B1','M04_20181004_B1_STIM.mat')};
- medX=[];medY=[];iqrX=[];iqrY=[];IQRX=[];IQRY=[];X=[];Y=[];
- for M=1:2
- load(f{M});
-
- for s=1:length(B)
- % Tracker-log based
- EC(s,M).t = [B(s).Log.Eye.t]';
-
- EC(s,M).X=[]; EC(s,M).Y=[];
- ppd = B(s).Par.PixPerDeg;
- for i=1:length(B(s).Log.Eye)
- EC(s,M).X = [EC(s,M).X; B(s).Log.Eye(i).CurrEyePos(1)./ppd];
- EC(s,M).Y = [EC(s,M).Y; B(s).Log.Eye(i).CurrEyePos(2)./ppd];
- end
- X=[X;EC(s,M).X ones(size(EC(s,M).X)).*M ones(size(EC(s,M).X)).*s];
- Y=[Y;EC(s,M).Y ones(size(EC(s,M).X)).*M ones(size(EC(s,M).X)).*s];
-
- medX = [medX; median(EC(s,M).X)];
- iqrX = [iqrX; iqr(EC(s,M).X)];
- IQRX = [IQRX; [medX(end)-iqrX(end)/2 medX(end)+iqrX(end)/2]];
- medY = [medY; median(EC(s,M).Y)];
- iqrY = [iqrY; iqr(EC(s,M).Y)];
- IQRY = [IQRY; [medY(end)-iqrY(end)/2 medY(end)+iqrY(end)/2]];
- end
- end
- %% Give stats =============================================================
- % Per animal ---
- m={'M03','M04'};
- fprintf('============================================\n');
- fprintf('EPHYS DATA ---------------------------------\n');
- fprintf('============================================\n');
- for i =1:2
- fprintf(['Eye-positions monkey ' m{i} '\n']);
- s=X(:,2)==i;
- cmedX = median(X(s,1));
- cmedY = median(Y(s,1));
- cmedE = median(sqrt(X(s,1).^2 + Y(s,1).^2));
- ciqrX = iqr(X(s,1));
- ciqrY = iqr(Y(s,1));
- ciqrE = iqr(sqrt(X(s,1).^2 + Y(s,1).^2));
- fprintf(['Median [iqr] X-POS: ' num2str(cmedX) ' [' num2str(ciqrX) ']\n']);
- fprintf(['Median [iqr] Y-POS: ' num2str(cmedY) ' [' num2str(ciqrY) ']\n']);
- fprintf(['Median [iqr] ECC: ' num2str(cmedE) ' [' num2str(ciqrE) ']\n\n']);
- end
- % Both monkeys ---
- fprintf(['Eye-positions both monkeys\n']);
- cmedX = median(X(:,1));
- cmedY = median(Y(:,1));
- cmedE = median(sqrt(X(:,1).^2+Y(:,1).^2));
- ciqrX = iqr(X(:,1));
- ciqrY = iqr(Y(:,1));
- ciqrE = iqr(sqrt(X(:,1).^2+Y(:,1).^2));
- fprintf(['Median [iqr] X-POS: ' num2str(cmedX) ' [' num2str(ciqrX) ']\n']);
- fprintf(['Median [iqr] Y-POS: ' num2str(cmedY) ' [' num2str(ciqrY) ']\n']);
- fprintf(['Median [iqr] ECC: ' num2str(cmedE) ' [' num2str(ciqrE) ']\n\n']);
- %% fMRI ===================================================================
- % Which logfiles?
- SLIST = {fullfile(bf,'Analysis_code','MRI','pRF_PrepDatalist_M01.m'),...
- fullfile(bf,'Analysis_code','MRI','pRF_PrepDatalist_M02.m')};
- MM={'M01';'M02'}; ppd3T=63.3; HW3T=960; HH3T=540;
- fld = '/media/8TB/NHP-BIDS';
- mri_eye=[];
- for m=1:length(SLIST)
- run(SLIST{m})
- fprintf(['Getting eye data for ' MM{m} '\n'])
- for d=1:length(DATA)
- sess = DATA{d,1}(1:8);
- runnr = DATA{d,2};
- bsinc = DATA{d,3};
-
- fprintf(['Sess ' sess ', run ' runnr '\n'])
-
- % load log
- logfile = fullfile(bf,'Analysis_code','Eye','MRI_eyelog',MM{m},...
- ['sub-' MM{m} '_ses-' sess '_task-prf_run-' runnr '_model'],...
- 'EyeX.txt');
- TX=readtable(logfile);
- TX.Properties.VariableNames = {'t','d','x'};
- logfile = fullfile(bf,'Analysis_code','Eye','MRI_eyelog',MM{m},...
- ['sub-' MM{m} '_ses-' sess '_task-prf_run-' runnr '_model'],...
- 'EyeY.txt');
- TY=readtable(logfile);
- TY.Properties.VariableNames = {'t','d','y'};
- logfile = fullfile(bf,'Analysis_code','Eye','MRI_eyelog',MM{m},...
- ['sub-' MM{m} '_ses-' sess '_task-prf_run-' runnr '_model'],...
- 'Log_ALL_eventlog.csv');
- TE=readtable(logfile);
- % get bar sweep series start & stop
- p0=(bsinc(1)-1)*20+1; p1=bsinc(1)*20;
- for ev=1:size(TE,1)
- if strcmp(TE.info{ev},num2str(p0))
- t0 = TE.time_s(ev);
- elseif strcmp(TE.info{ev},num2str(p1))
- tE = TE.time_s(ev);
- end
- end
- mri_eye = [mri_eye; ...
- TX.x(TX.t>t0 & TX.t<tE)./ppd3T ...
- TY.y(TY.t>t0 & TY.t<tE)./ppd3T ...
- ones(sum(TX.t>t0 & TX.t<tE),1)*m ...
- ones(sum(TX.t>t0 & TX.t<tE),1)*d];
- end
- end
-
- %% Give stats =============================================================
- % Per animal ---
- m={'M01','M02'};
- fprintf('============================================\n');
- fprintf('MRI DATA -----------------------------------\n');
- fprintf('============================================\n');
- for i =1:2
- fprintf(['Eye-positions monkey ' m{i} '\n']);
- s=mri_eye(:,3)==i;
- cmedX = median(mri_eye(s,1));
- cmedY = median(mri_eye(s,2));
- cmedE = median(sqrt(mri_eye(s,1).^2 + mri_eye(s,2).^2));
- ciqrX = iqr(mri_eye(s,1));
- ciqrY = iqr(mri_eye(s,2));
- ciqrE = iqr(sqrt(mri_eye(s,1).^2 + mri_eye(s,2).^2));
- fprintf(['Median [iqr] X-POS: ' num2str(cmedX) ' [' num2str(ciqrX) ']\n']);
- fprintf(['Median [iqr] Y-POS: ' num2str(cmedY) ' [' num2str(ciqrY) ']\n']);
- fprintf(['Median [iqr] ECC: ' num2str(cmedE) ' [' num2str(ciqrE) ']\n\n']);
- end
- % Both monkeys ---
- fprintf('Eye-positions both monkeys\n');
- cmedX = median(mri_eye(:,1));
- cmedY = median(mri_eye(:,2));
- cmedE = median(sqrt(mri_eye(:,1).^2+mri_eye(:,2).^2));
- ciqrX = iqr(mri_eye(:,1));
- ciqrY = iqr(mri_eye(:,2));
- ciqrE = iqr(sqrt(mri_eye(:,1).^2+mri_eye(:,1).^2));
- fprintf(['Median [iqr] X-POS: ' num2str(cmedX) ' [' num2str(ciqrX) ']\n']);
- fprintf(['Median [iqr] Y-POS: ' num2str(cmedY) ' [' num2str(ciqrY) ']\n']);
- fprintf(['Median [iqr] ECC: ' num2str(cmedE) ' [' num2str(ciqrE) ']\n\n']);
|