B_WaveformAnalysisDATA_extendedTrain.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. % extraction des data pour une waveform analysis puis k-mean methods pour
  2. % clusteriser les differents de neurons
  3. clear all; clc;
  4. load('RextendedTraining.mat')
  5. WFlength=800; %total duration of the waevform 800microseconds
  6. bins=25;%bins=25microsecond
  7. time=(bins:bins:WFlength);
  8. runAnalysis=1;
  9. for i=1:size(R.WF,1)
  10. if sum(R.WF(i,:))==0
  11. R.WFanalysis(i,2)=0;
  12. R.WFanalysis(i,3)=0;
  13. else
  14. [maxValue, MaxIndex] = max(R.WF(i,:));
  15. [minValue, MinIndex] = min(R.WF(i,:));
  16. PeakValleyW=abs(time(MaxIndex)-time(MinIndex));
  17. PeakValleyM=abs(maxValue-minValue);
  18. R.WFanalysis(i,2)=PeakValleyM;
  19. idx = find(diff(R.WF(i,:) >= minValue/2));
  20. x2 = time(idx) + (minValue/2 - R.WF(i,idx)) .* (time(idx+1) - time(idx)) ./ (R.WF(i,idx+1) - R.WF(i,idx));
  21. if length(x2)==1
  22. R.WFanalysis(i,3)=NaN;
  23. else
  24. ValleyFWHM=x2(2)-x2(1);
  25. R.WFanalysis(i,3)=ValleyFWHM;
  26. end
  27. end
  28. end
  29. selection=R.WFanalysis(:,2)~=0;
  30. X=R.WFanalysis(selection,1:3);
  31. idx(1:sum(selection),1)=1;
  32. idx(X(:,1)>20,1)=2; % threshold 20Hz to separate MSN from FSI
  33. idx(idx(:,1)==2 & X(:,3)>150,1)=0;
  34. idx(X(:,1)<20 & X(:,1)>12.5 & idx(:,1)==1,1)=0; % intermediate frequencies = not classified
  35. for Y=1:size(idx,1)
  36. if idx(Y,1)==1
  37. color(Y,:)=[255/255 0/255 0/255];%MSN
  38. sizeplot(Y,1)=50;
  39. elseif idx(Y,1)==2
  40. color(Y,:)=[0 255/255 0/255];%FSI
  41. sizeplot(Y,1)=50;
  42. elseif idx(Y,1)==3
  43. color(Y,:)=[0/255 0/255 255/255]; %TAN
  44. sizeplot(Y,1)=50;
  45. elseif idx(Y,1)==0
  46. color(Y,:)=[0/255 0/255 0/255];%unclassified
  47. sizeplot(Y,1)=5;
  48. end
  49. end
  50. figure;
  51. subplot(3,4,[1 2 3 5 6 7 9 10 11])
  52. scatter(X(:,1),X(:,3),sizeplot,color)
  53. hold on
  54. title(strcat('all neurons clustering kmean'))
  55. xlabel('FR') % x-axis label
  56. ylabel('half-width')% y-axis label
  57. hold off
  58. Celltype(:,1)=0;
  59. Celltype(selection,1)=idx(:,1);
  60. save('Celltype_extendedTraining.mat','Celltype')
  61. %% examples of waveforms
  62. subplot(3,4,4)
  63. plot(time,R.WF(1,:))
  64. axis([0 800 -0.08 0.06 ])
  65. subplot(3,4,8)
  66. plot(time,R.WF(39,:))
  67. axis([0 800 -0.08 0.06 ])
  68. subplot(3,4,12)
  69. plot(time,R.WF(281,:))
  70. axis([0 800 -0.08 0.06 ])