-
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.
adding some clusterless decoding code from kenny
- Loading branch information
Showing
64 changed files
with
36,268 additions
and
383 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
function rgb = vals2rgb(vals, colormap, crange) | ||
% Take in a vector of N values and return and return a Nx3 matrix of RGB | ||
% values associated with a given colormap | ||
% | ||
% rgb = AFQ_vals2colormap(vals, [colormap = 'jet'], [crange]) | ||
% | ||
% Inputs: | ||
% vals = A vector of values to map to a colormap or a cell array of | ||
% vectors of values | ||
% colormap = A matlab colormap. Examples: colormap = 'autumn'; | ||
% colormap = 'jet'; colormap = 'hot'; | ||
% crange = The values to map to the minimum and maximum of the colormap. | ||
% Defualts to the full range of values in vals. | ||
% | ||
% Outputs: | ||
% rgb = Nx3 matrix of rgb values mapping each value in vals to the | ||
% corresponding rgb colors. If vals is a cell array then rgb | ||
% will be a cell array of the same length | ||
% | ||
% Example: | ||
% vals = rand(1,100); | ||
% rgb = AFQ_vals2colormap(vals, 'hot'); | ||
% | ||
% Copyright Jason D. Yeatman, June 2012 | ||
|
||
if ~exist('colormap','var') || isempty(colormap) | ||
colormap = 'jet'; | ||
end | ||
|
||
% | ||
if ~iscell(vals) | ||
if ~exist('crange','var') || isempty(crange) | ||
crange = [min(vals) max(vals)]; | ||
end | ||
% Generate the colormap | ||
cmap = eval([colormap '(256)']); | ||
% Normalize the values to be between 1 and 256 | ||
vals(vals < crange(1)) = crange(1); | ||
vals(vals > crange(2)) = crange(2); | ||
valsN = round(((vals - crange(1)) ./ diff(crange)) .* 255)+1; | ||
% Convert any nans to ones | ||
valsN(isnan(valsN)) = 1; | ||
% Convert the normalized values to the RGB values of the colormap | ||
rgb = cmap(valsN, :); | ||
elseif iscell(vals) | ||
if ~exist('crange','var') || isempty(crange) | ||
crange = [min(vertcat(vals{:})) max(vertcat(vals{:}))]; | ||
end | ||
% Generate the colormap | ||
cmap = eval([colormap '(256)']); | ||
for ii = 1:length(vals) | ||
% Normalize the values to be between 1 and 256 for cell ii | ||
valsN = vals{ii}; | ||
valsN(valsN < crange(1)) = crange(1); | ||
valsN(valsN > crange(2)) = crange(2); | ||
valsN = round(((valsN - crange(1)) ./ diff(crange)) .* 255)+1; | ||
% Convert any nans to ones | ||
valsN(isnan(valsN)) = 1; | ||
% Convert the normalized values to the RGB values of the colormap | ||
rgb{ii} = cmap(valsN, :); | ||
end | ||
end | ||
return |
Binary file not shown.
Oops, something went wrong.