-
Notifications
You must be signed in to change notification settings - Fork 12
Tutorial 1: Play a video of the session
William Chapman edited this page Jul 16, 2014
·
1 revision
This is provided as a simple introduction to accessing the fields of a Session object. Once you load your object and rename it as root, understand and execute the lines below:
% Plays a video of the trajectory
root.cel = root.cells(1,:); % watch the first cell
speed = 10; % play back at 10X
lookBack = 20; % trail 20 seconds
% Fix the position and headdir to make sense
root = root.FixDir;
root = root.FixPos;
pauseTime = (1/root.fs_video); % how long between each frame
stepSize = speed;
x = root.x; y= root.y; t = root.ts; hd = CMBHOME.Utils.ContinuizeEpochs(root.headdir);
cx = CMBHOME.Utils.ContinuizeEpochs(root.cel_x); % Get all x positions at firing
cy = CMBHOME.Utils.ContinuizeEpochs(root.cel_y); % Get all y positions at firing
ci = CMBHOME.Utils.ContinuizeEpochs(root.cel_i); % Get all indices of firing
f1=figure('Position',[200 200 1024 800]);
lookBack = ceil(lookBack*root.fs_video);
%% Loop:
for i = stepSize+1:stepSize:length(t)
% figure setup
figure(f1);cla;hold on
inds = max([i-lookBack, 1]):i;
cinds = (ci<=i) & (ci>=inds(1));
plot(x(inds),y(inds));
if ~isempty(inds)
plot(cx(cinds),cy(cinds),'o','MarkerFaceColor',[1 0 0],'MarkerEdgeColor',[0 0 0]);
end
% render
xlim([min(root.x) max(root.x)]);ylim([min(root.y) max(root.y)])
title(num2str(floor(t(i))))
spks = numel(intersect((i-stepSize):i,ci))>0;
pause(pauseTime)
end
Copyright (c) 2016, Trustees of Boston University, All Rights Reserved