forked from Julie-Fabre/bombcell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly define unit type when isolation distances are computed
- Loading branch information
1 parent
c5d7907
commit 583564a
Showing
4 changed files
with
155 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
function unitType = bc_getQualityUnitType(param, qMetric) | ||
% JF, Classify units into good/mua/noise/non-somatic | ||
% ------ | ||
% Inputs | ||
% ------ | ||
% | ||
% ------ | ||
% Outputs | ||
% ------ | ||
if param.computeDistanceMetrics && ~isnan(param.isoDmin) && param.computeDrift && param.extractRaw | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.signalToNoiseRatio >= param.minSNR &... | ||
qMetric.presenceRatio >= param.minPresenceRatio & qMetric.maxDriftEstimate <= param.maxDrift & ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.isoD >= param.isoDmin &... | ||
qMetric.Lratio <= param.lratioMax & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.computeDistanceMetrics && ~isnan(param.isoDmin) && param.computeDrift | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian' <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & ... | ||
qMetric.presenceRatio >= param.minPresenceRatio & qMetric.maxDriftEstimate <= param.maxDrift & ... | ||
qMetric.isoD >= param.isoDmin &... | ||
qMetric.Lratio <= param.lratioMax & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.computeDrift && param.extractRaw | ||
|
||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.signalToNoiseRatio >= param.minSNR &... | ||
qMetric.presenceRatio >= param.minPresenceRatio & qMetric.maxDriftEstimate <= param.maxDrift & ... | ||
qMetric.rawAmplitude > param.minAmplitude & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.computeDistanceMetrics && ~isnan(param.isoDmin) && param.extractRaw | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.signalToNoiseRatio >= param.minSNR &... | ||
qMetric.presenceRatio >= param.minPresenceRatio & isnan(unitType)& ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.isoD >= param.isoDmin &... | ||
qMetric.Lratio <= param.lratioMax & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.computeDrift | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian' <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & ... | ||
qMetric.presenceRatio >= param.minPresenceRatio & qMetric.maxDriftEstimate <= param.maxDrift & ... | ||
isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.computeDistanceMetrics && ~isnan(param.isoDmin) | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
|
||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & ... | ||
qMetric.presenceRatio >= param.minPresenceRatio & ... | ||
qMetric.isoD >= param.isoDmin &... | ||
qMetric.Lratio <= param.lratioMax & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
elseif param.extractRaw | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.rawAmplitude > param.minAmplitude & qMetric.signalToNoiseRatio >= param.minSNR &... | ||
qMetric.presenceRatio >= param.minPresenceRatio & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
else | ||
unitType = nan(length(qMetric.percentageSpikesMissing_gaussian), 1); | ||
unitType(qMetric.nPeaks > param.maxNPeaks | qMetric.nTroughs > param.maxNTroughs | ... | ||
qMetric.spatialDecaySlope >= param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration |... | ||
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness >= param.maxWvBaselineFraction) = 0; % NOISE | ||
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC | ||
unitType(qMetric.percentageSpikesMissing_gaussian <= param.maxPercSpikesMissing & qMetric.nSpikes > param.minNumSpikes & ... | ||
qMetric.fractionRPVs_estimatedTauR <= param.maxRPVviolations & ... | ||
qMetric.presenceRatio >= param.minPresenceRatio & isnan(unitType)) = 1; % SINGLE SEXY UNIT | ||
unitType(isnan(unitType)) = 2; % MULTI UNIT | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.