


%% add the spikes repository to the path

% this repository is at: https://github.com/cortex-lab/spikes
addpath(genpath('C:\Users\Nick\Documents\GitHub\spikes'))


%% load spiking data

kilosortDir = 'J:\Hopkins\20160722\';
sp = loadKSdir(kilosortDir)


%% load stimulus information 

load stimInfo.mat

%% plot a receptive field for some cluster

thisCID = 155; % choose a cluster to plot

stimEventsToUse = 2; % 1 is grey-to-white, 2 is grey-to-black.

% some parameters for this analysis
p.makePlots = true; 
p.useSVD = true;
p.countWindow = [-0.05 0.15];
p.binSize = 0.01;

theseStimTimes = stimTimes{stimEventsToUse};
theseStimPos = stimPositions{stimEventsToUse};

theseST = sp.st(sp.clu==thisCID);

[rfmap, stats] = sparseNoiseRF(theseST, theseStimTimes, theseStimPos, p);
set(gcf, 'Name', sprintf('cluster %d', thisCID));
