% select directory containing .mat files containing embedding data fDir = uigetdir('Select decathlon_embedding_data directory'); % generate embedding data struct from data files embedding = build_embedding_data_struct(fDir); % find t-SNE speed threshold for parsing t-SNE trajectories into pauses at modes make_plot = true; [sigma,embedding.z_thresh] = fit_tsne_z_logspeed_gmm(embedding.z_speed,make_plot); % set kernel parameters for density estimation L = numel(embedding.z_data); maxVal = max(max(abs(cat(1,embedding.z_data{:})))); maxVal = round(maxVal * 1.1); sig = sigma(1); numPoints = 501; rangeVals = [-maxVal maxVal]; % compute raw density without any filtering [~,density] = findPointDensity(cat(1,embedding.z_data{:}),sig,numPoints,rangeVals); figure('Name','Combined density maps'); subplot(1,2,1); plot_density(density,ones(size(density))); title('Unfiltered density map'); % filter data for pts pausing below the speed threshold for a min duration frame_rate = 100; min_dur = 0.05; slow_mode = cellfun(@(zz) zz