Skip to content

Commit

Permalink
dynamic histogram plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie-Fabre committed Oct 13, 2024
1 parent d2652dd commit 46d9225
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 845 deletions.
469 changes: 171 additions & 298 deletions +bc/+qm/plotGlobalQualityMetric.asv

Large diffs are not rendered by default.

471 changes: 172 additions & 299 deletions +bc/+qm/plotGlobalQualityMetric.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion +bc/+qm/qualityParamValues.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
param.waveformBaselineWindowStart = 20;
param.waveformBaselineWindowStop = 30; % in samples
end
param.minThreshDetectPeaksTroughs = 0.1; % this is multiplied by the max value
param.minThreshDetectPeaksTroughs = 0.2; % this is multiplied by the max value
% in a units waveform to give the minimum prominence to detect peaks using
% matlab's findpeaks function.
param.normalizeSpDecay = 1; % whether to normalize spatial decay points relative to
Expand Down
205 changes: 0 additions & 205 deletions +bc/+qm/runAllQualityMetrics.asv

This file was deleted.

7 changes: 5 additions & 2 deletions +bc/+qm/waveformShape.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@
linearFit = param.spDecayLinFit;
[spatialDecaySlope, spatialDecayFit, spatialDecayPoints, spatialDecayPoints_loc, estimatedUnitXY] = ...
bc.qm.helpers.getSpatialDecay(templateWaveforms, thisUnit, maxChannel, channelPositions, linearFit, param.normalizeSpDecay, param.computeSpatialDecay);

spatialDecayFit_1 = spatialDecayFit(1);
if linearFit
spatialDecayFit_1 = spatialDecayFit(2);
else
spatialDecayFit_1 = spatialDecayFit(1);
end
% (get waveform baseline fraction)
if ~isnan(waveformBaselineWindow(1))
waveformBaseline = max(abs(thisWaveform(waveformBaselineWindow(1): ...
Expand Down
38 changes: 33 additions & 5 deletions +bc/+viz/unitQualityGUI_synced.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

%% unit quality gui: plot various quality metric plots for single units
% This function is very messy - don't attempt to modify. Send me an email or raise an issue :)
%
% toggle between units with the right and left arrows
% the slowest part by far of this is plotting the raw data, need to figure out how
% to make this faster
Expand Down Expand Up @@ -130,9 +132,35 @@ function initializePlot(unitQualityGuiHandle, ephysData, qMetric, unitType, uniq
numCols = ceil(numSubplots/numRows);

% Color matrix setup
colorMtx = [bc.viz.colors(15); bc.viz.colors(15)];
colorMtx = [colorMtx(1:21, :, :), repmat(0.7, 21, 1)]; % make 70% transparent
colorMtx = colorMtx([1:4:end, 2:4:end, 3:4:end, 4:4:end], :); % shuffle colors
red_colors = [
0.8627 0.0784 0.2353; % Crimson
1.0000 0.1412 0.0000; % Scarlet
0.7255 0.0000 0.0000; % Cherry
0.5020 0.0000 0.1255; % Burgundy
0.5020 0.0000 0.0000; % Maroon
0.8039 0.3608 0.3608 % Indian Red
];

blue_colors = [
0.2549 0.4118 0.8824; % Royal Blue
0.0000 0.0000 0.5020 % Navy Blue
];
% Color matrix setup
darker_yellow_orange_colors = [
0.7843 0.7843 0.0000; % Dark Yellow
0.8235 0.6863 0.0000; % Dark Golden Yellow
0.8235 0.5294 0.0000; % Dark Orange
0.8039 0.4118 0.3647; % Dark Coral
0.8235 0.3176 0.2275; % Dark Tangerine
0.8235 0.6157 0.6510; % Dark Salmon
0.7882 0.7137 0.5765; % Dark Goldenrod
0.8235 0.5137 0.3922; % Dark Light Coral
0.7569 0.6196 0.0000; % Darker Goldenrod
0.8235 0.4510 0.0000 % Darker Orange
];


colorMtx = [red_colors; blue_colors;darker_yellow_orange_colors]; % shuffle colors

%sgtitle([num2str(sum(unitType == 1)), ' single units, ', num2str(sum(unitType == 2)), ' multi-units, ', ...
% num2str(sum(unitType == 0)), ' noise units, ', num2str(sum(unitType == 3)), ' non-somatic units.']);
Expand All @@ -148,9 +176,9 @@ function initializePlot(unitQualityGuiHandle, ephysData, qMetric, unitType, uniq

% Plot histogram
if i > 2
h = histogram(ax, metricData, 40, 'FaceColor', colorMtx(i, 1:3), 'FaceAlpha', colorMtx(i, 4), 'Normalization', 'probability');
h = histogram(ax, metricData, 40, 'FaceColor', colorMtx(i, 1:3), 'Normalization', 'probability');
else
h = histogram(ax, metricData, 'FaceColor', colorMtx(i, 1:3), 'FaceAlpha', colorMtx(i, 4), 'Normalization', 'probability');
h = histogram(ax, metricData, 'FaceColor', colorMtx(i, 1:3), 'Normalization', 'probability');
end
binsize_offset = h.BinWidth/2;
% Add horizontal lines instead of rectangles
Expand Down
42 changes: 24 additions & 18 deletions +bc/+viz/upSetPlot.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function upSetPlot(data, labels, figH)
function upSetPlot(data, labels, figH, setSizeColor)
% More info on UpSet plots in the original publication:
% Alexander Lex, Nils Gehlenborg, Hendrik Strobelt, Romain Vuillemot,
% Hanspeter Pfister. UpSet: Visualization of Intersecting Sets
Expand All @@ -10,15 +10,16 @@ function upSetPlot(data, labels, figH)
% written by Zhaoxu Liu / slandarer

if nargin < 3 || isempty(figH)
figH = figure('Units', 'normalized', 'Position', [.3, .2, .5, .63], 'Color', [1, 1, 1]);

figH = figure('Units', 'normalized', 'Position', [.2, .2, 1, .63], 'Color', [1, 1, 1]);
end

% set colors
intxColor = [66, 182, 195] ./ 255;
intxColor = [0, 0, 0];
if nargin < 4 || isempty(setSizeColor)
setSizeColor = bc.viz.colors(size(data,2));
end
lineColor = [61, 58, 61] ./ 255;


% get probabilities & groups
pBool = abs(dec2bin((1:(2^size(data, 2) - 1))')) - 48;
[pPos, ~] = find(((pBool * (1 - data')) | ((1 - pBool) * data')) == 0);
Expand All @@ -36,22 +37,22 @@ function upSetPlot(data, labels, figH)
%% create figure and subplots
axI = axes('Parent', figH);
hold on;
set(axI, 'Position', [.33, .35, .655, .61], 'LineWidth', 1.2, 'Box', 'off', 'TickDir', 'out', ...
set(axI, 'Position', [.45, .35, .53, .48], 'LineWidth', 1.2, 'Box', 'off', 'TickDir', 'out', ...
'FontName', 'Arial', 'FontSize', 12, 'XTick', [], 'XLim', [0, length(pType) + 1])
axI.YLabel.String = 'Intersection Size';
axI.YLabel.FontSize = 16;
%

axS = axes('Parent', figH);
hold on;
set(axS, 'Position', [.01, .08, .245, .26], 'LineWidth', 1.2, 'Box', 'off', 'TickDir', 'out', ...
set(axS, 'Position', [.2, .08, .2, .26], 'LineWidth', 1.2, 'Box', 'off', 'TickDir', 'out', ...
'FontName', 'Arial', 'FontSize', 12, 'YColor', 'none', 'YLim', [.5, size(data, 2) + .5], ...
'YAxisLocation', 'right', 'XDir', 'reverse', 'YTick', [])
axS.XLabel.String = 'Set Size';
axS.XLabel.FontSize = 16;
%

axL = axes('Parent', figH);
hold on;
set(axL, 'Position', [.33, .08, .655, .26], 'YColor', 'none', 'YLim', [.5, size(data, 2) + .5], 'XColor', 'none', 'XLim', axI.XLim)
set(axL, 'Position', [.45, .08, .53, .26], 'YColor', 'none', 'YLim', [.5, size(data, 2) + .5], 'XColor', 'none', 'XLim', axI.XLim)

%% plot interaction bar plots
barHdlI = bar(axI, pCount);
Expand All @@ -69,19 +70,21 @@ function upSetPlot(data, labels, figH)
for i = 1:length(pType)
barHdlI.CData(i, :) = intxColor(i, :);
end
text(axI, 1:length(pType), pCount, string(pCount), 'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'bottom', 'FontName', 'Arial', 'FontSize', 12, 'Color', [61, 58, 61]./255)
%text(axI, 1:length(pType), pCount, string(pCount), 'HorizontalAlignment', 'center', ...
% 'VerticalAlignment', 'bottom', 'FontName', 'Arial', 'FontSize', 12, 'Color', [61, 58, 61]./255)

%% plot set sizes
barHdlS = barh(axS, sCount, 'BarWidth', .6);
barHdlS.EdgeColor = 'none';
barHdlS.BaseLine.Color = 'none';

% Adjust label position
for i = 1:size(data, 2)
annotation('textbox', [(axS.Position(1) + axS.Position(3) + axI.Position(1)) / 2 - .02, ...
axS.Position(2) + axS.Position(4) ./ size(data, 2) .* (i - .5) - .02, .04, .04], ...
'String', labels{sInd(i)}, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', ...
'FitBoxToText', 'on', 'LineStyle', 'none', 'FontName', 'Arial', 'FontSize', 13)
text(axS, max(sCount), i, labels{sInd(i)}, 'HorizontalAlignment', 'right', ...
'VerticalAlignment', 'middle', 'FontName', 'Arial', 'FontSize', 13, ...
'Color', [0.2, 0.2, 0.2]);
end

if size(setSizeColor, 1) == 1
setSizeColor = [setSizeColor; setSizeColor];
end
Expand All @@ -97,8 +100,11 @@ function upSetPlot(data, labels, figH)
barHdlS.CData(i, :) = setSizeColor(i, :);
sstr{i} = [num2str(sCount(i)), ' '];
end
text(axS, sCount, 1:size(data, 2), sstr, 'HorizontalAlignment', 'right', ...
'VerticalAlignment', 'middle', 'FontName', 'Arial', 'FontSize', 12, 'Color', [61, 58, 61]./255)
%text(axS, sCount + max(sCount)*0.02, 1:size(data, 2), sstr, 'HorizontalAlignment', 'left', ...
% 'VerticalAlignment', 'middle', 'FontName', 'Arial', 'FontSize', 12, 'Color', [61, 58, 61]./255)

% Adjust x-axis limits to accommodate labels
axS.XLim = [-max(sCount)*0.15, max(sCount) * 1.5];

%% plot interaction details
patchColor = [248, 246, 249; 255, 254, 255] ./ 255;
Expand Down
Loading

0 comments on commit 46d9225

Please sign in to comment.