Advertisement
t6nisko

Untitled

Sep 28th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. %
  2. % Practice session: Data Analysis: Spiking Data
  3. % Codebase for Matlab/Octave
  4. %
  5.  
  6.  
  7.  
  8. %% Load data
  9.  
  10. % prepare empty structure
  11. data = {};
  12.  
  13. % for every neuron
  14. for n = 1:72
  15.  
  16. % load the data file and store it in the data structure under the
  17. % number n
  18. data{end + 1} = load(['C:\Users\Tõnis Kristian\Desktop\02-Data Analysis/data/lgn/matlab/mlgnori_' sprintf('%02d', n) '.mat']);
  19.  
  20. end
  21.  
  22.  
  23.  
  24. %% Exercise 3
  25.  
  26. %
  27. % here is an example of how you can plot raster plot for a single trial
  28. %
  29.  
  30. % from the data for the neuron number 5 we take variable spktimes
  31. % it is a 3D matrix, we take 3rd stimiulus and trial number 8
  32. spikes = data{5}.mlgn.spktimes(3,8,:);
  33.  
  34. % have a look at the size of the resulting variable: it is still a 3D matrix
  35. size(spikes)
  36.  
  37. % we reshape it into usual 2-dimensional matrix with only one row
  38. spikes = reshape(spikes, 1, []);
  39.  
  40. % so that you can access element number 1078 just as
  41. spikes(1078)
  42.  
  43. % now we are ready to plot it
  44.  
  45. % for each moment of time (we have 3500 of them)
  46. for t = 1:size(spikes,2)
  47.  
  48. % if there is a spike at this time moment
  49. if spikes(t) == 1
  50.  
  51. % draw a vertical line
  52. line([t t], [7 7.5], 'Color', 'k');
  53. end
  54. end
  55.  
  56. % add labels to X and Y axis
  57. xlabel('Time (ms)', 'FontSize', 16);
  58. ylabel('Trial', 'FontSize', 16);
  59.  
  60. % specify range for the Y axis so that the plot would resemble the real thing
  61. ylim([0 10])
  62.  
  63. % add title to your plot
  64. title('10 trials', 'FontSize', 20)
  65.  
  66. % and specify font size for numbers on the axis
  67. set(gca,'FontSize', 14)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement