Skip to content

Commit

Permalink
add clean_rez_params option
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanharvey1 committed Dec 3, 2024
1 parent 7f298c5 commit 0413d25
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions preProcessing/preprocessSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ function preprocessSession(varargin)
addParameter(p, 'path_to_dlc_bat_file', '', @isfile)
addParameter(p, 'nKilosortRuns', 1, @isnumeric);
addParameter(p, 'sortFiles', true, @islogical);
addParameter(p, 'clean_rez_params', { ...
'mahalThreshold', 12, ...
'minNumberOfSpikes', 20, ...
'multiTrough', true, ...
'isi', true, ...
'singleBin', true, ...
'global', true, ...
}, @iscell);


% addParameter(p,'pullData',[],@isdir); To do...
parse(p, varargin{:});
Expand All @@ -112,6 +121,7 @@ function preprocessSession(varargin)
path_to_dlc_bat_file = p.Results.path_to_dlc_bat_file;
nKilosortRuns = p.Results.nKilosortRuns;
sortFiles = p.Results.sortFiles;
clean_rez_params = p.Results.clean_rez_params;


if ~exist(basepath, 'dir')
Expand Down Expand Up @@ -213,7 +223,7 @@ function preprocessSession(varargin)
fprintf(1, 'There was an error! The message was:\n%s', e.message);
try
warning('LFPfromDat failed, trying ResampleBinary')
ResampleBinary([basepath, '\', basename, '.dat'],...
ResampleBinary([basepath, '\', basename, '.dat'], ...
[basepath, '\', basename, '.lfp'], session.extracellular.nChannels, 1, 16);
catch e
warning('LFP file could not be generated, moving on');
Expand Down Expand Up @@ -281,7 +291,7 @@ function preprocessSession(varargin)
kilosortFolder = KiloSortWrapper('SSD_path', SSD_path, 'rejectchannels', excludeChannels);
if cleanRez
load(fullfile(kilosortFolder, 'rez.mat'), 'rez');
CleanRez(rez, 'savepath', kilosortFolder);
CleanRez(rez, 'savepath', kilosortFolder, clean_rez_params{:});
end
end
end
Expand All @@ -292,7 +302,7 @@ function preprocessSession(varargin)
'rejectchannels', session.channelTags.Bad.channels); % 'NT',20*1024 for long sessions when RAM is overloaded
if cleanRez
load(fullfile(kilosortFolder, 'rez.mat'), 'rez');
CleanRez(rez, 'savepath', kilosortFolder);
CleanRez(rez, 'savepath', kilosortFolder, clean_rez_params{:});
end
% PhyAutoClustering(kilosortFolder);
end
Expand Down

0 comments on commit 0413d25

Please sign in to comment.