Skip to content

Commit

Permalink
Update to new release v1.0.20200529 (https://neurostars.org/t/display…
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed May 29, 2020
1 parent 13b7c3c commit cf8c0fc
Show file tree
Hide file tree
Showing 27 changed files with 10,784 additions and 392 deletions.
2,718 changes: 2,718 additions & 0 deletions backup/mainunit.lfm

Large diffs are not rendered by default.

6,598 changes: 6,598 additions & 0 deletions backup/mainunit.pas

Large diffs are not rendered by default.

62 changes: 61 additions & 1 deletion cifti.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function loadCifti(fnm: string; lOverlayIndex, lSeriesIndex: integer; isLoadCort
{$ELSE}
function TMesh.loadCifti(fnm: string; lOverlayIndex, lSeriesIndex: integer; isLoadCortexLeft: boolean): integer;
{$ENDIF}
label 131;
type
TBrainModel = record
IndexOffset, IndexCount, SurfaceNumberOfVertices,
Expand Down Expand Up @@ -64,8 +65,10 @@ type
var
hdr: TNIFTIhdr2;
hdrSzSwap : int32;
lut : array of TRGBA;
f: file;
nSeries, xmlLen,i,j,k, fsz,xmlPos: integer;
fmx: single;
nVert, mx, nSeries, xmlLen,i,j,k, fsz,xmlPos, tablePos: integer;
xmlStr, allBrainStructures, desiredBrainStructure : string;
rawData: TFloats;
vertexIndices: array of integer;
Expand Down Expand Up @@ -94,6 +97,29 @@ function readXInt(key: string): integer;
begin
result := strtointdef(readXStr(key), 0);
end;
function readLut(idx: integer): TRGBA;
//<Label Key="1" Red="0.270588" Green="0" Blue="1" Alpha="1">R_V1_ROI</Label> lut[i] := ReadLut(xmlStr, i);
var
lStart, lEnd: integer;
begin
result.R := 0;
result.G := 0;
result.B := 0;
result.A := 0;
xmlPos := tablePos; //random storage of labels, keys may not be sequential
lStart := posExEnd('<Label Key="'+inttostr(idx)+'"');
if lStart < 1 then exit;
lEnd := PosEx('</Label>', xmlStr, lStart);
xmlPos := lStart;
if lEnd < 1 then exit;
result.R := round(strtofloatDef(readXStr('Red'),0) * 255.0);
result.G := round(strtofloatDef(readXStr('Green'),0) * 255);
result.B := round(strtofloatDef(readXStr('Blue'),0) * 255.0);
result.A := round(strtofloatDef(readXStr('Alpha'),0) * 255.0);
//printf(format('%d r%d g%d b%d', [idx, result.R, result.G, result.B]));
//result.A := 100;
end;

function readXArrayInt: integer;
var
s: string;
Expand Down Expand Up @@ -270,6 +296,40 @@ begin
k := k + 1;
end;
{$ENDIF}
//
//<LabelTable>
// <Label Key="0" Red="1" Green="1" Blue="1" Alpha="0">???</Label>
// <Label Key="1" Red="0.270588" Green="0" Blue="1" Alpha="1">R_V1_ROI</Label>
//TVertexRGBA
// lut : array of TRGBA;

xmlPos := pos('</LabelTable>', xmlStr);
if xmlPos > 0 then begin
xmlPos := pos('<LabelTable>', xmlStr);
if xmlPos < 1 then goto 131;
nVert := bm.SurfaceNumberOfVertices;
fmx := overlay[lOverlayIndex].intensity[0];
for i := 0 to (nVert-1) do
if overlay[lOverlayIndex].intensity[i] > fmx then
fmx := overlay[lOverlayIndex].intensity[i];
mx := round(fmx);
if mx < 1 then goto 131;
tablePos := xmlPos;
xmlPos := pos('<Label Key="'+inttostr(mx)+'"', xmlStr);
if xmlPos < 1 then goto 131;
setlength(lut, mx + 1);
for i := 0 to mx do
lut[i] := ReadLut(i);
setlength(vertexRGBA, nVert);
for i := 0 to (nVert-1) do begin
j := round(overlay[lOverlayIndex].intensity[i]);
if j < 0 then continue;
vertexRGBA[i] := lut[j];
end;
setlength(overlay[lOverlayIndex].intensity, 0);
//GLForm1.caption := 'xx'+inttostr(mx);
end;
131:
setlength(rawData,0);
setlength(vertexIndices,0);
result := nSeries;
Expand Down
6 changes: 5 additions & 1 deletion colorTable.pas
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function maxRGBA(c1, c2: TRGBA ): TRGBA;
function inten2rgb(intensity, mn, mx: single; lut: TLUT; mode: integer): TRGBA; overload;
var
i: byte;
isInvert : boolean;
//isInvert : boolean;
begin
if (mn < 0) and (mx < 0) and (mode = kPaintHideDefaultBehavior) then begin
if intensity >= mx then
Expand Down Expand Up @@ -218,6 +218,10 @@ function loadCustomLUT(var lIndex: integer): TLUTnodes;
setNode(0,0,0,0,0, 0, result);
setNode(255,255,255,255,255, 1, result);
result.isFreeSurfer:= false;
if lIndex >= GLForm1.LayerColorDrop.Items.Count then
lIndex := GLForm1.LayerColorDrop.Items.Count -1;
if lIndex < 0 then
lIndex := 0;
lFilename := CLUTdir+pathdelim+GLForm1.LayerColorDrop.Items[lIndex]+'.clut';
if not fileexists(lFilename) then begin
lIndex := 0;
Expand Down
9 changes: 9 additions & 0 deletions commandsu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ procedure CLIP (DEPTH: single);
procedure CLIPAZIMUTHELEVATION (DEPTH,AZI,ELEV: single);
procedure COLORBARPOSITION(P: integer);
procedure COLORBARVISIBLE (VISIBLE: boolean);
procedure CONTOUR(layer: integer);
procedure EDGECOLOR(name: string; varies: boolean);
procedure EDGELOAD(lFilename: string);
procedure EDGESIZE(size: single; varies: boolean);
Expand Down Expand Up @@ -625,6 +626,14 @@ procedure TRACKPREFS(lLength,lWidth,lDither: single);
GLForm1.TrackDitherTrack.Position := round(lDither * GLForm1.TrackDitherTrack.Max);
end;

procedure CONTOUR(layer: integer);
begin
gMesh.Contours(layer);
GLForm1.GLboxRequestUpdate(nil);
GLForm1.UpdateToolbar;
GLForm1.UpdateLayerBox(true);
end;

procedure BACKCOLOR (R,G,B: byte);
begin
gPrefs.BackColor := RGBToColor(R,G,B);
Expand Down
24 changes: 23 additions & 1 deletion define_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface
{$endif}

const
kVers = 'v1.0.20191122 Beta';
kVers = 'v1.0.20200529';
NaN : double = 1/0;
kTab = chr(9);
kCR = chr (13);
Expand Down Expand Up @@ -49,6 +49,7 @@ interface
TVertexRGBA = array of TRGBA;
TBools = array of boolean;
TInts = array of integer;
TUInt8s = array of uint8;
TInt16s = array of int16;
TUInt16s = array of uint16;
TInt32s = array of int32;
Expand Down Expand Up @@ -453,6 +454,7 @@ procedure SwapLongWord(var s : LongWord);
s := outguy.Long;
end; // SwapLongWord()

{$IFDEF SLOWREADLNBIN}
procedure ReadLnBin(var f: TFByte; var s: string);
const
kEOLN = $0A;
Expand All @@ -466,6 +468,26 @@ procedure ReadLnBin(var f: TFByte; var s: string);
s := s + Chr(bt);
end;
end;
{$ELSE}
procedure ReadLnBin(var f: TFByte; var s: string); inline;
const
kEOLN = $0A;
var
bt : Byte;
begin
s := '';
//while (not EOF(f)) do begin //<- half the speed!
while (true) do begin
try
Read(f,bt);
except
exit;
end;
if bt = kEOLN then exit;
s := s + Chr(bt);
end;
end;
{$ENDIF}

function RGBA(lR,lG,lB,lA: byte): TRGBA;
//set red,green,blue and alpha of a Quad
Expand Down
Loading

0 comments on commit cf8c0fc

Please sign in to comment.