mainfolder='U:/LindeDomingoJuan/Memoreye_DATA/' partis=good_partis_sub; perNan=NaN(length(partis),2,2); %Preparing output variable %% for delay=1:2 for ppp=1:length(partis) % Loading dataset if delay== 1 toload =[mainfolder '/eyelink_preprocessed/mean_recentered_th100/object_1_onset_11_seconds/' partis{ppp,:} '.mat']; %for 1st delay elseif delay==2 toload =[mainfolder '/eyelink_preprocessed/mean_recentered_th100/2nd_cue_onset_17_5__seconds/' partis{ppp,:} '.mat']; %for 2nd delay end load(toload) cx=squeeze(data_epoch_thr.eyedat(:,1,:)); %data of channel x cy=squeeze(data_epoch_thr.eyedat(:,2,:)); %data of channel y cxv=cx(:); %data as a vector cyv=cy(:); %data as a vector % Saving the percentage of NaN per epoch. perNan(ppp,1,delay)=(sum(isnan(cxv))/length(cxv))*100; perNan(ppp,2,delay)=(sum(isnan(cyv))/length(cyv))*100; end end %% baddelay1=excludingoutlier(perNan(:,1,1)) baddelay2=excludingoutlier(perNan(:,1,2)) index=(baddelay1+baddelay2)==0; %keeping only participants that are OK in both epochs %% Making a final list of good participants and saving the file counter=1; for ppp = 1:length(good_partis_sub) if index(ppp)==1 good_partis{counter} =good_partis_sub{ppp} counter=counter+1; end end %% Plotting results if figure_NaNs figure; subplot(1,2,1) boxplot(squeeze(perNan(:,:,1))) ylabel('% of NaN') xlabel('channel (x and y)') title('delay 1 epoch') subplot(1,2,2) boxplot(squeeze(perNan(:,:,2))) ylabel('% of NaN') xlabel('channel (x and y)') title('delay 2epoch') end m1=['the max NaN % in delay 1 is ' num2str(max(perNan(index,:,1))) ' and the min is ' num2str(min(perNan(index,:,1)))]; m2=['the max NaN % in delay 2 is ' num2str(max(perNan(index,:,2))) ' and the min is ' num2str(min(perNan(index,:,2)))]; disp(m1) disp(m2) %% function output=excludingoutlier(data) %excluding participants with values >1.5*IQR in the third quartile ad=squeeze(data(:,1,1)); r = iqr(ad); Q = quantile(ad,[0.75]); output=ad>(1.5*r)+Q; end