Skip to content

Commit

Permalink
fixed the eMouse script
Browse files Browse the repository at this point in the history
  • Loading branch information
marius10p committed Oct 29, 2020
1 parent 060f53e commit ddf63e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
34 changes: 18 additions & 16 deletions eMouse_drift/main_eMouse_drift.m
Expand Up @@ -4,18 +4,18 @@
sortData = 1;
runBenchmark = 1; %set to 1 to compare sorted data to ground truth for the simulation

fpath = 'C:\Users\labadmin\Documents\jic\050320_sim_test\'; % where on disk do you want the simulation? ideally an SSD...
fpath = 'G:\Spikes\eMouse\'; % where on disk do you want the simulation? ideally an SSD...
if ~exist(fpath, 'dir'); mkdir(fpath); end

%KS2 path -- also has the waveforms for the simulation
KS2path = 'C:\Users\labadmin\Documents\jic\KS2_040920\Kilosort2\';
KS2path = 'D:\GitHub\KiloSort2\';

% add paths to the matlab path
addpath(genpath('C:\Users\labadmin\Documents\jic\KS2_040920\Kilosort2\')); % path to kilosort2 folder
addpath(genpath('C:\Users\labadmin\Documents\jic\npy-matlab-master\'));
addpath(genpath('D:\GitHub\KiloSort2')) % path to kilosort folder
addpath('D:\GitHub\npy-matlab') % for converting to Phy

% path to whitened, filtered proc file (on a fast SSD)
rootH = 'D:\kilosort_datatemp\';
rootH = 'G:\Spikes\eMouse\';

% path to config file; if running the default config, no need to change.
pathToYourConfigFile = [KS2path,'eMouse_drift\']; % path to config file
Expand All @@ -42,7 +42,7 @@
end
%
% Run kilosort2 on the simulated data

%%
if( sortData )

% common options for every probe
Expand All @@ -51,6 +51,10 @@
ops.NchanTOT = NchanTOT; % total number of channels in your recording
ops.trange = [0 Inf]; % TIME RANGE IN SECONDS TO PROCESS

ops.sig = 20; % spatial smoothness constant for registration
ops.fshigh = 300; % high-pass more aggresively
ops.nblocks = 5; % blocks for registration. 0 turns it off, 1 does rigid registration. Replaces "datashift" option.


ops.fproc = fullfile(rootH, 'temp_wh.dat'); % proc file on a fast SSD

Expand All @@ -64,27 +68,25 @@
% preprocess data to create temp_wh.dat
rez = preprocessDataSub(ops);

% pre-clustering to re-order batches by depth
rez = clusterSingleBatches(rez);
% NEW STEP TO DO DATA REGISTRATION
rez = datashift2(rez, 1); % last input is for shifting data
% rez2 = datashift2(rez, 0); % last input is for shifting data


% main optimization
% learnAndSolve8;
rez = learnAndSolve8b(rez);
rez = learnAndSolve8b(rez, 1);


% final splits
rez = find_merges(rez, 1);


% final splits by SVD
rez = splitAllClusters(rez, 1);

% final splits by amplitudes
rez = splitAllClusters(rez, 0);

% decide on cutoff
rez = set_cutoff(rez);

rez.good = get_good_units(rez);

% this saves to Phy
rezToPhy(rez, rootZ);

Expand All @@ -108,7 +110,7 @@
fclose(fileID);

% remove temporary file
delete(ops.fproc);
% delete(ops.fproc);
end


Expand Down
6 changes: 3 additions & 3 deletions eMouse_drift/make_eMouseData_drift.m
Expand Up @@ -5,8 +5,8 @@ function make_eMouseData_drift(fpath, KS2path, chanMapName, useGPU, useParPool)
% probe sites.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% you can play with the parameters just below here to achieve a signal more similar to your own data!!!
norm_amp = 16.7; % if 0, use amplitudes of input waveforms; if > 0, set all amplitudes to norm_amp*rms_noise
mu_mean = 0.75; % mean of mean spike amplitudes. Incoming waveforms are in uV; make <1 to make sorting harder
norm_amp = 1.5 * 16.7; % if 0, use amplitudes of input waveforms; if > 0, set all amplitudes to norm_amp*rms_noise
mu_mean = .75; %0.75; % mean of mean spike amplitudes. Incoming waveforms are in uV; make <1 to make sorting harder
noise_model = 'gauss'; %'gauss' or 'fromData'; 'fromData' requires a noiseModel.mat built by make_noise_model
rms_noise = 10; % rms noise in uV. Will be added to the spike signal. 15-20 uV an OK estimate from real data
t_record = 1200; % duration in seconds of simulation. longer is better (and slower!) (1000)
Expand All @@ -24,7 +24,7 @@ function make_eMouseData_drift(fpath, KS2path, chanMapName, useGPU, useParPool)
drift.y0 = 3800; %in um, position along probe where motion is largest
%y = 0 is the tip of the probe
drift.halfDistance = 1000; %in um, distance along probe over which the motion decays
drift.amplitude = 10; %in um for a sine wave
drift.amplitude = 5; %in um for a sine wave
% peak variation is 2Xdrift.amplitude
drift.halfLife = 2; %in seconds
drift.period = 600; %in seconds
Expand Down
2 changes: 1 addition & 1 deletion preProcess/datashift2.m
Expand Up @@ -23,7 +23,7 @@
npt = floor(xrange/16); % this would come out as 16um for Neuropixels probes, which aligns with the geometry.
rez.ops.xup = linspace(xmin, xmax, npt+1); % centers of the upsampled x positions

spkTh = 10; % same as the usual "template amplitude", but for the generic templates
spkTh = 8; % same as the usual "template amplitude", but for the generic templates

% Extract all the spikes across the recording that are captured by the
% generic templates. Very few real spikes are missed in this way.
Expand Down

0 comments on commit ddf63e4

Please sign in to comment.