Skip to content

Commit

Permalink
Merge pull request #37 from cbimbo/main
Browse files Browse the repository at this point in the history
Add split good vs. mua for non-somatic units
  • Loading branch information
Julie-Fabre authored Nov 23, 2023
2 parents 0d8bcac + 6388ec0 commit bfd5746
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 109 deletions.
2 changes: 2 additions & 0 deletions qualityMetrics/bc_checkParameterFields.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
defaultValues.saveAsTSV = 0;
defaultValues.unitType_for_phy = 0;

% separate good from mua in non-somatic
defaultValues.splitGoodAndMua_NonSomatic = 0;

%% Check for missing fields and add them with default value
[param_complete, missingFields] = bc_addMissingFieldsWithDefault(param, defaultValues);
Expand Down
100 changes: 0 additions & 100 deletions qualityMetrics/bc_getQualityUnitType.asv

This file was deleted.

22 changes: 16 additions & 6 deletions qualityMetrics/bc_getQualityUnitType.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@


%% Sanitize and check inputs
% sanitize parameter input
% Sanitize parameter input
param = bc_checkParameterFields(param);

% check whether to save this classification for automated loading by phy
% Check whether to save this classification for automated loading by phy
if (nargin < 3 || isempty(savePath)) && param.unitType_for_phy == 1
savePath = pwd;
warning('no save path specified. using current working directory')
Expand All @@ -43,9 +43,6 @@
qMetric.spatialDecaySlope > param.minSpatialDecaySlope | qMetric.waveformDuration_peakTrough < param.minWvDuration | ...
qMetric.waveformDuration_peakTrough > param.maxWvDuration | qMetric.waveformBaselineFlatness > param.maxWvBaselineFraction) = 0; % NOISE

% Classify non-somatic units
unitType(qMetric.isSomatic ~= param.somatic & isnan(unitType)) = 3; % NON-SOMATIC

% Classify mua units
unitType((qMetric.percentageSpikesMissing_gaussian > param.maxPercSpikesMissing | qMetric.nSpikes < param.minNumSpikes & ...
qMetric.fractionRPVs_estimatedTauR > param.maxRPVviolations | ...
Expand All @@ -68,12 +65,25 @@
% Classify good units
unitType(isnan(unitType)) = 1; % SINGLE SEXY UNIT

% Classify non-somatic units
if param.splitGoodAndMua_NonSomatic
unitType(qMetric.isSomatic ~= param.somatic & unitType == 1) = 3; % GOOD NON-SOMATIC
unitType(qMetric.isSomatic ~= param.somatic & unitType == 2) = 4; % MUA NON-SOMATIC
else
unitType(qMetric.isSomatic ~= param.somatic & ismember(unitType,[1 2])) = 3; % NON-SOMATIC
end

% Get unit type string
unitType_string = cell(size(unitType, 1), 1);
unitType_string(unitType == 0) = {'NOISE'};
unitType_string(unitType == 3) = {'NON-SOMA'};
unitType_string(unitType == 1) = {'GOOD'};
unitType_string(unitType == 2) = {'MUA'};
if param.splitGoodAndMua_NonSomatic
unitType_string(unitType == 3) = {'NON-SOMA GOOD'};
unitType_string(unitType == 4) = {'NON-SOMA MUA'};
else
unitType_string(unitType == 3) = {'NON-SOMA'};
end

%% Save classification for phy
% save unitType for phy if param.unitType_for_phy is equal to 1
Expand Down
18 changes: 15 additions & 3 deletions qualityMetrics/bc_qualityParamValuesForUnitMatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,22 @@
% recorded in the raw data. This is usually 384 or 385 for neuropixels
% recordings
paramBC.nSyncChannels = 1;
if ~isempty(ephysMetaDir)
if exist('ephysMetaDir','var') && ~isempty(ephysMetaDir)
paramBC.ephysMetaFile = [ephysMetaDir.folder, filesep, ephysMetaDir.name];
paramBC.gain_to_uV = NaN;
else
paramBC.ephysMetaFile = 'NaN';
paramBC.gain_to_uV = gain_to_uV;
if exist('gain_to_uV','var')
paramBC.gain_to_uV = gain_to_uV;
else
paramBC.gain_to_uV = NaN;
end
end
if exist('rawFile','var')
paramBC.rawFile = rawFile;
else
paramBC.rawFile = 'NaN';
end
paramBC.rawFile = rawFile;

% distance metric parameters
paramBC.computeDistanceMetrics = 0; % whether to compute distance metrics - this can be time consuming
Expand Down Expand Up @@ -115,6 +123,10 @@
paramBC.isoDmin = 20;
paramBC.lratioMax = 0.1;
paramBC.ssMin = NaN;

% split good and mua non-somatic
paramBC.splitGoodAndMua_NonSomatic = 1;

end
% %bc_qualityParamValues
% BCparam = struct;
Expand Down

0 comments on commit bfd5746

Please sign in to comment.