forked from Chaogan-Yan/REST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_ReadLutColorScheme.m
executable file
·49 lines (47 loc) · 1.83 KB
/
rest_ReadLutColorScheme.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function Result = rest_ReadLutColorScheme(ALutFilename)
%Read look up table of color scheme By Xiao-Wei Song according to MRIcro's help forum
%------------------------------------------------------------------------------------------------------------------------------
% Copyright(c) 2007~2010
% State Key Laboratory of Cognitive Neuroscience and Learning in Beijing Normal University
% Written by Xiao-Wei Song
% http://resting-fmri.sourceforge.net
%20070918
%------------------------------------------------------------------------------------------------------------------------------
%Read a binary LUT file-format to construct a look-up-table / color scheme
%Code is translated from MRIcron's LoadColorScheme in nifti_img.pas, 20070918
theLutFile = fopen(ALutFilename,'r');
if theLutFile>0,
try
fseek(theLutFile,0,'eof');
theSize =ftell(theLutFile);
if any(theSize==[768, 800, 970]),
fseek(theLutFile,theSize-768, 'bof');
Result =zeros(256,3);
Result(:,1) =fread(theLutFile, 256, 'uint8');
Result(:,2) =fread(theLutFile, 256, 'uint8');
Result(:,3) =fread(theLutFile, 256, 'uint8');
Result =Result/max(Result(:));
else
error('Non correct binary LUT file format that I don''t support currently');
end
catch
end
fclose(theLutFile);
else
error(sprintf('Failed to open color file: %s', ALutFilename));
end
% if (lZ =768) or (lZ = 800) or (lZ=970) then begin
% //binary LUT
% assignfile(lFdata,lStr);
% Filemode := 0;
% reset(lFdata,1);
% seek(lFData,lZ-768);
% GetMem( lBuff, 768);
% BlockRead(lFdata, lBuff^, 768);
% for lZ := 0 to 255 do begin
% lHdr.LUT[lZ].rgbRed := lBuff^[lZ];
% lHdr.LUT[lZ].rgbGreen := lBuff^[lZ+256];
% lHdr.LUT[lZ].rgbBlue := lBuff^[lZ+512];
% lHdr.LUT[lZ].rgbReserved := kLUTalpha;
% end;