Skip to content
Snippets Groups Projects
Commit e9237145 authored by Mark Winter's avatar Mark Winter
Browse files

Actually add colors when creating a new phenotype. Uses the "bright" track color table.

parent 0862de99
Branches
Tags
No related merge requests found
......@@ -6,9 +6,21 @@
% undo stack it will always be followed by a ContextSetPhenotype action.
function [historyAction phenoID] = AddPhenotype(description)
global CellPhenotypes
global CellPhenotypes Colors
if ( isempty(Colors) )
Load.CreateColors();
end
% Find all colors that haven't been used yet
phenoColors = vertcat(CellPhenotypes.colors);
allowedColors = getAllowedColors(phenoColors);
newColorIdx = randi(size(allowedColors,1));
newPhenoColor = allowedColors(newColorIdx,:);
CellPhenotypes.descriptions = [CellPhenotypes.descriptions description];
CellPhenotypes.colors = [CellPhenotypes.colors; newPhenoColor];
phenoID = length(CellPhenotypes.descriptions);
......@@ -16,3 +28,24 @@ function [historyAction phenoID] = AddPhenotype(description)
historyAction = '';
end
function [allowedColors bAllowedColors] = getAllowedColors(phenoColors)
global Colors
if ( isempty(Colors) )
Load.CreateColors();
end
bAllowedColors = false(size(Colors,1),1);
for i=1:size(Colors,1)
dists = sum((ones(size(phenoColors,1),1)*Colors(i,1:3) - phenoColors).^2, 2);
minDist = min(dists);
% A dubious threshold, but less than anything in the table
if ( minDist > (0.1^2) )
bAllowedColors(i) = 1;
end
end
allowedColors = Colors(bAllowedColors, 1:3);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment