Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %
- % Practice session: Data Analysis: Spiking Data
- % Codebase for Matlab/Octave
- %
- %% Load data
- % prepare empty structure
- data = {};
- % for every neuron
- for n = 1:72
- % load the data file and store it in the data structure under the
- % number n
- data{end + 1} = load(['C:\Users\Tõnis Kristian\Desktop\02-Data Analysis/data/lgn/matlab/mlgnori_' sprintf('%02d', n) '.mat']);
- end
- %% Exercise 3
- %
- % here is an example of how you can plot raster plot for a single trial
- %
- % from the data for the neuron number 5 we take variable spktimes
- % it is a 3D matrix, we take 3rd stimiulus and trial number 8
- spikes = data{5}.mlgn.spktimes(3,8,:);
- % have a look at the size of the resulting variable: it is still a 3D matrix
- size(spikes)
- % we reshape it into usual 2-dimensional matrix with only one row
- spikes = reshape(spikes, 1, []);
- % so that you can access element number 1078 just as
- spikes(1078)
- % now we are ready to plot it
- % for each moment of time (we have 3500 of them)
- for t = 1:size(spikes,2)
- % if there is a spike at this time moment
- if spikes(t) == 1
- % draw a vertical line
- line([t t], [7 7.5], 'Color', 'k');
- end
- end
- % add labels to X and Y axis
- xlabel('Time (ms)', 'FontSize', 16);
- ylabel('Trial', 'FontSize', 16);
- % specify range for the Y axis so that the plot would resemble the real thing
- ylim([0 10])
- % add title to your plot
- title('10 trials', 'FontSize', 20)
- % and specify font size for numbers on the axis
- set(gca,'FontSize', 14)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement