neo-matlab-example-script.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. % based on sample code here: https://neo.readthedocs.io/en/0.8.0/io.html#neo.io.NeoMatlabIO
  2. block = struct();
  3. block.segments = { };
  4. block.name = 'my block with matlab';
  5. for s = 1:3
  6. seg = struct();
  7. seg.name = strcat('segment ',num2str(s-1));
  8. seg.analogsignals = { };
  9. for a = 1:5
  10. anasig = struct();
  11. anasig.name = ['sig ', num2str(a-1)];
  12. anasig.signal = rand(600,1);
  13. anasig.signal_units = 'mV';
  14. anasig.t_start = 0;
  15. anasig.t_start_units = 's';
  16. anasig.sampling_rate = 20;
  17. anasig.sampling_rate_units = 'Hz';
  18. seg.analogsignals{a} = anasig;
  19. end
  20. seg.spiketrains = { };
  21. for t = 1:7
  22. sptr = struct();
  23. sptr.name = ['st ', num2str(t-1)];
  24. sptr.times = rand(30,1)*30;
  25. sptr.times_units = 's';
  26. sptr.t_start = 0;
  27. sptr.t_start_units = 's';
  28. sptr.t_stop = 30;
  29. sptr.t_stop_units = 's';
  30. seg.spiketrains{t} = sptr;
  31. end
  32. event = struct();
  33. event.name = 'event 0';
  34. event.times = [0, 10, 30];
  35. event.times_units = 's';
  36. event.labels = ['trig0'; 'trig1'; 'trig2'];
  37. seg.events{1} = event;
  38. epoch = struct();
  39. epoch.name = 'epoch 0';
  40. epoch.times = [10, 20];
  41. epoch.times_units = 's';
  42. epoch.durations = [4, 10];
  43. epoch.durations_units = 's';
  44. epoch.labels = ['a0'; 'a1'];
  45. seg.epochs{1} = epoch;
  46. block.segments{s} = seg;
  47. end
  48. save 'neo-matlab.mat'