Skip to content

Instantly share code, notes, and snippets.

@nclack
Last active October 4, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nclack/2695810 to your computer and use it in GitHub Desktop.
Save nclack/2695810 to your computer and use it in GitHub Desktop.
Plot the shape of a tracked whisker at a given time point.
w = LoadWhiskers('trial.whiskers');
measurements = LoadMeasurements('trial.measurements');
whisker_id=0; % the tracked whisker of interest
frame_id=100; % the time point of interest
times = [measurements(:).fid];
names = [measurements(:).label];
curveids = [measurements(:).wid];
%% Query the measurements to find curves
% that match the whisker id and time of interest
mask=(names==whisker_id).*(times==frame_id);
t = times(mask);
c = curveids(mask);
% there should be only one match
% but just in case, just take the first one
t=t(1);
c=c(1);
%% Find the corresponding curve in the whisker's data
idx=find(([w(:).id]==c).*([w(:).time]==t),1,'first');
plot(w(idx).x,w(idx).y));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment