From 80ce2b024ae31b649029c5840f109e446dadb336 Mon Sep 17 00:00:00 2001 From: Vigneswaran-Chandrasekaran Date: Sat, 6 Nov 2021 13:21:29 +0530 Subject: [PATCH] Initial commit --- behavioral_plot.m | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 behavioral_plot.m diff --git a/behavioral_plot.m b/behavioral_plot.m new file mode 100644 index 0000000..8a17d1f --- /dev/null +++ b/behavioral_plot.m @@ -0,0 +1,27 @@ +nwb = nwbRead('nicklab~Subjects~Cori~2016-12-17~001~alf.nwb'); +markBehavioralEvents(nwb, 'licks', 150, 10); + +function markBehavioralEvents(nwb, eventName, start_time, duration) + + arguments + nwb {mustBeA(nwb, "NwbFile")} + eventName char = 'lick_times' + start_time double = 0 + duration double = 10 + end + + behavior_module = nwb.processing.get('behavior'); + event = behavior_module.nwbdatainterface.get('BehavioralEvents'); + timestamps = event.timeseries.get('licks').timestamps.load; + x_ticks = timestamps(timestamps >= start_time & ... + timestamps <= start_time + duration); + plot(x_ticks, ones(length(x_ticks), 1), 'x', ... + 'DisplayName', 'lick times', ... + 'LineWidth', 1.2) + ylim([0, 2]); + xlim([start_time start_time+duration]); + set(gca,'YTickLabel',[]); + xlabel('time (s)'); + title('Lick time raster'); + legend +end \ No newline at end of file