1
1

example.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. % Minimal example for MATLAB users
  2. clear all
  3. % Load data from the specially prepared matlab files
  4. % PLEASE NOTE: These are not the original data files, and are provided for
  5. % convenience only. These files contain the data structures returned by the
  6. % Python loading routines, converted to a matlab format. Thus, these files
  7. % contain a condensed, interpreted subset of the original data.
  8. % Note that due to file size restrictions in the MATLAB file format, raw
  9. % signals are saved in separate files, channel by channel.
  10. data = load("../datasets_matlab/i140703-001_lfp-spikes.mat");
  11. % Plot the LFP and spikes of electrode 62 from 3s to 5s
  12. % Note: All annotations of the original Python data objects are saved as
  13. % "an_XXX" in the matlab structs
  14. for i=1:length(data.block.segments{1}.analogsignals)
  15. if data.block.segments{1}.analogsignals{i}.an_channel_id==62
  16. % LFP
  17. % Sampled at 1KHz
  18. time_axis = [0:1/data.block.segments{1}.analogsignals{i}.sampling_rate:(length(data.block.segments{1}.analogsignals{i}.signal)-1)/data.block.segments{1}.analogsignals{i}.sampling_rate];
  19. plot(time_axis(3000:5000), data.block.segments{1}.analogsignals{i}.signal(3000:5000), 'k-');
  20. hold on
  21. % Spikes
  22. for t=1:length(data.block.segments{1}.spiketrains{i}.times)
  23. % Spikes are saved in the native resolution of 30kHz
  24. st = data.block.segments{1}.spiketrains{i}.times(t) / 30000;
  25. if st>=3 && st<=5
  26. plot(st,0,'rx');
  27. end
  28. end
  29. xlabel("time [1/" + data.block.segments{1}.analogsignals{i}.sampling_rate_units + "]");
  30. ylabel("LFP [" + data.block.segments{1}.analogsignals{i}.signal_units + "]");
  31. title(data.block.segments{1}.analogsignals{i}.description);
  32. end
  33. end