From d5f0ef7cc9fb0c0163ac8b15f2c20cbd900b9afb Mon Sep 17 00:00:00 2001 From: Julie-Fabre Date: Wed, 5 Jun 2024 18:37:29 +0100 Subject: [PATCH] update unitmatch default params --- .../bc_qualityParamValuesForUnitMatch.m | 8 +++---- qualityMetrics/bc_updateSpatialDecaySlope.asv | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 qualityMetrics/bc_updateSpatialDecaySlope.asv diff --git a/qualityMetrics/bc_qualityParamValuesForUnitMatch.m b/qualityMetrics/bc_qualityParamValuesForUnitMatch.m index 01dd707f..fc9c4115 100644 --- a/qualityMetrics/bc_qualityParamValuesForUnitMatch.m +++ b/qualityMetrics/bc_qualityParamValuesForUnitMatch.m @@ -95,11 +95,11 @@ end paramBC.minThreshDetectPeaksTroughs = 0.2; % this is multiplied by the max value paramBC.firstPeakRatio = 1.1; % if units have an initial peak before the trough, - % in a units waveform to give the minimum prominence to detect peaks using % matlab's findpeaks function. -paramBC.firstPeakRatio = 1.1; % if units have an initial peak before the trough, - +paramBC.normalizeSpDecay = 1; % whether to normalize spatial decay points relative to +% maximum - this makes the spatrial decay slop calculation more invariant to the +% spike-sorting algorithm used % recording parametrs paramBC.ephys_sample_rate = 30000; % samples per second @@ -146,7 +146,7 @@ paramBC.somatic = 1; paramBC.minWvDuration = 100; % in us paramBC.maxWvDuration = 800; % in us -paramBC.minSpatialDecaySlope = -0.003; +paramBC.minSpatialDecaySlope = -0.005; paramBC.maxWvBaselineFraction = 0.3; %distance metrics diff --git a/qualityMetrics/bc_updateSpatialDecaySlope.asv b/qualityMetrics/bc_updateSpatialDecaySlope.asv new file mode 100644 index 00000000..3c3451d0 --- /dev/null +++ b/qualityMetrics/bc_updateSpatialDecaySlope.asv @@ -0,0 +1,22 @@ +function bc_updateSpatialDecaySlope(kilosortSavePath, qMetricSavePath) + +% load in quality metrics +[~, qMetric] = bc_loadSavedMetrics(qMetricSavePath); + +% load in relevant kilosort files +[~, spikeTemplates, templateWaveforms, ~, ~, ... + ~, ~] = bc_loadEphysData(kilosortSavePath); + +uniqueTemplates = unique(spikeTemplates); + +% update spatial decay value +for iUnit = 1:size(uniqueTemplates,1) + + thisUnit = uniqueTemplates(iUnit); + + qMetric.spatialDecaySlope(iUnit) = qMetric.spatialDecaySlope(iUnit)./max(max(templateWaveforms(thisUnit, :,:))); +end + +% save new metrics +parquetwrite([fullfile(qMetricSavePath, 'templates._bc_qMetrics.parquet')], qMetric) +end \ No newline at end of file