check_percentage_of_NaN_eyes_2022.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. mainfolder='U:/LindeDomingoJuan/Memoreye_DATA/'
  2. partis=good_partis_sub;
  3. perNan=NaN(length(partis),2,2); %Preparing output variable
  4. %%
  5. for delay=1:2
  6. for ppp=1:length(partis)
  7. % Loading dataset
  8. if delay== 1
  9. toload =[mainfolder '/eyelink_preprocessed/mean_recentered_th100/object_1_onset_11_seconds/' partis{ppp,:} '.mat']; %for 1st delay
  10. elseif delay==2
  11. toload =[mainfolder '/eyelink_preprocessed/mean_recentered_th100/2nd_cue_onset_17_5__seconds/' partis{ppp,:} '.mat']; %for 2nd delay
  12. end
  13. load(toload)
  14. cx=squeeze(data_epoch_thr.eyedat(:,1,:)); %data of channel x
  15. cy=squeeze(data_epoch_thr.eyedat(:,2,:)); %data of channel y
  16. cxv=cx(:); %data as a vector
  17. cyv=cy(:); %data as a vector
  18. % Saving the percentage of NaN per epoch.
  19. perNan(ppp,1,delay)=(sum(isnan(cxv))/length(cxv))*100;
  20. perNan(ppp,2,delay)=(sum(isnan(cyv))/length(cyv))*100;
  21. end
  22. end
  23. %%
  24. baddelay1=excludingoutlier(perNan(:,1,1))
  25. baddelay2=excludingoutlier(perNan(:,1,2))
  26. index=(baddelay1+baddelay2)==0; %keeping only participants that are OK in both epochs
  27. %% Making a final list of good participants and saving the file
  28. counter=1;
  29. for ppp = 1:length(good_partis_sub)
  30. if index(ppp)==1
  31. good_partis{counter} =good_partis_sub{ppp}
  32. counter=counter+1;
  33. end
  34. end
  35. %% Plotting results
  36. if figure_NaNs
  37. figure;
  38. subplot(1,2,1)
  39. boxplot(squeeze(perNan(:,:,1)))
  40. ylabel('% of NaN')
  41. xlabel('channel (x and y)')
  42. title('delay 1 epoch')
  43. subplot(1,2,2)
  44. boxplot(squeeze(perNan(:,:,2)))
  45. ylabel('% of NaN')
  46. xlabel('channel (x and y)')
  47. title('delay 2epoch')
  48. end
  49. m1=['the max NaN % in delay 1 is ' num2str(max(perNan(index,:,1))) ' and the min is ' num2str(min(perNan(index,:,1)))];
  50. m2=['the max NaN % in delay 2 is ' num2str(max(perNan(index,:,2))) ' and the min is ' num2str(min(perNan(index,:,2)))];
  51. disp(m1)
  52. disp(m2)
  53. %%
  54. function output=excludingoutlier(data)
  55. %excluding participants with values >1.5*IQR in the third quartile
  56. ad=squeeze(data(:,1,1));
  57. r = iqr(ad);
  58. Q = quantile(ad,[0.75]);
  59. output=ad>(1.5*r)+Q;
  60. end