Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed May 28, 2019
1 parent 9b5b6d9 commit 0a64681
Show file tree
Hide file tree
Showing 27 changed files with 1,773 additions and 441 deletions.
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Supported mesh formats include 3DO, 3DS, AC, BYU, CTM, DAE, DXF, FreeSurfer, GII

![alt tag](https://github.com/neurolabusc/surf-ice/blob/master/Surfice.jpg)

##### Installing

You can get the latest release from [github](https://github.com/neurolabusc/surf-ice/releases) or [NITRC](https://www.nitrc.org/projects/surfice). Releases are provided for Linux, MacOS and Windows. Each release includes two versions of Surf Ice: "Surfice" requires OpenGL 3.3 or later, while "SurficeOld" runs on older computers (requiring OpenGL 2.1). A [wiki](https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage) provides a full manual and troubleshooting advice.

##### Compiling

This project is built using the open source [FreePascal Lazarus](http://www.lazarus-ide.org/) compiler and integrated development environment. You will need to have the LazOpenGLContext and PascalScript packages installed. To do this, launch the Lazarus application and choose Packages/InstallPackages. You will want to select these two packages from the "Available for installation" list. Finally, click the "Save and rebuild" button. Once these are installed, you can load this package and compile it using the Run/Run menu option.
Expand Down Expand Up @@ -42,36 +46,9 @@ You can also build this project from the command line (assuming you have FPC Laz
lazbuild surfice.lpr
```

##### Recent Versions

2-February-2018 (v1.0.20180202)
- [Atlas-based regions of interest](https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage#Atlas-based_Region_of_interest_Analyses).
- [Python scripting](https://github.com/neurolabusc/surf-ice/blob/master/PYTHON.md).
- [Outline, ](https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage#Atlas-based_Region_of_interest_Analyses)[Grid and HideCurves shaders added](https://www.nitrc.org/plugins/mwiki/index.php/surfice:MainPage#Gallery).

20-December-2017 (v1.0.20171220)
- Support [PALM](https://github.com/andersonwinkler/PALM) format [DPV](https://brainder.org/2011/09/25/braindering-with-ascii-files/).

21-June-2017
- [Smooth](https://github.com/neurolabusc/OpenGLCoreTutorials) numbers in colorbars.
- Conversion of images from voxels to mesh now allows the user to specify a minimum cluster size.
- Pan image by [shift-dragging](https://www.nitrc.org/forum/forum.php?thread_id=7857&forum_id=6713).
- MacOS retina support (better but slower, use Preferences window to disable).

7-February-2017
- Ability to individually adjust translucency of overlays (rather than having one value for all).
- Looks better on Linux high-DPI screens.
- New command Advanced/ComputeCurvature creates FreeSurfer Format CURV file.
- Control-clicking overlay name in the overlay panel reverses the overlay colors (and the name is displayed in black instead of blue). Control-click again to switch to normal mode.
- Support for several variations of the [CIfTI format](https://www.humanconnectome.org/software/get-connectome-workbench.html)(dscalar.nii, dlabel.nii, dtseries.nii).

30-September-2016
- Add support for the TRK.GZ (DSI studio), DAT (MRI studio) formats.
- Support for tracks with [scalars](https://github.com/johncolby/along-tract-stats) and [properties](http://trackvis.org/blog/tag/track_merge/).
- "Faster" track viewing mode looks better (Lucas Nesi's imposter method).
##### Versions

20-April-2016
- Add support for the 3DS, MS3D, LWO2, DXF and GTS formats.
The [releases](https://github.com/neurolabusc/surf-ice/releases) page provides version notes.

##### License

Expand Down
2 changes: 1 addition & 1 deletion define_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface
uses graphics;
{$endif}
const
kVers = 'v1.0.20190220';
kVers = 'v1.0.20190518';
NaN : double = 1/0;
kTab = chr(9);
kCR = chr (13);
Expand Down
4 changes: 3 additions & 1 deletion gl_core_3d.pas
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ procedure SetTrackUniforms(lineWidth, ScreenPixelX, ScreenPixelY: integer);

glUniform1f(glGetUniformLocation(gShader.programTrackID, pAnsiChar('Ambient')), gShader.TrackAmbient) ;
glUniform1f(glGetUniformLocation(gShader.programTrackID, pAnsiChar('Diffuse')), gShader.TrackDiffuse) ;
glUniform1f(glGetUniformLocation(gShader.programTrackID, pAnsiChar('Specular')), gShader.TrackSpecular) ;
//glUniform1f(glGetUniformLocation(gShader.programTrackID, pAnsiChar('Specular')), gShader.TrackSpecular * 0.75) ; //<<<<<<<<<
glUniform1f(glGetUniformLocation(gShader.programTrackID, pAnsiChar('Specular')), gShader.TrackSpecular) ; //full glisten

{$ENDIF}

end;
Expand Down
2 changes: 1 addition & 1 deletion gl_legacy_3d.pas
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function BuildDisplayList(var faces: TFaces; vertices: TVertices; vRGBA: TVertex
fNorm : TPoint3f;
begin
//glDeleteLists(mesh.displayList, 1);
if (length(vertices) < 3) or (length(faces) < 1) then exit;
if (length(vertices) < 3) or (length(faces) < 1) then exit(0);
setlength(vNorm, length(vertices) );
//compute vertex normals
fNorm := ptf(0,0,0);
Expand Down
23 changes: 15 additions & 8 deletions mainunit.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object GLForm1: TGLForm1
Left = 137
Left = 233
Height = 684
Top = 45
Top = 94
Width = 1047
AllowDropFiles = True
Caption = 'Surf Ice'
Expand Down Expand Up @@ -422,6 +422,7 @@ object GLForm1: TGLForm1
BorderSpacing.Top = 2
DropDownCount = 22
ItemHeight = 26
ItemIndex = 0
Items.Strings = (
'a'
'b'
Expand All @@ -435,7 +436,7 @@ object GLForm1: TGLForm1
ParentFont = False
Style = csDropDownList
TabOrder = 3
Text = '0'
Text = 'a'
end
object TrackScalarNameDrop: TComboBox
AnchorSideLeft.Control = TrackLengthLabel
Expand Down Expand Up @@ -516,6 +517,7 @@ object GLForm1: TGLForm1
BorderSpacing.Right = 2
DropDownCount = 22
ItemHeight = 26
ItemIndex = 0
Items.Strings = (
'a'
'b'
Expand All @@ -529,7 +531,7 @@ object GLForm1: TGLForm1
ParentFont = False
Style = csDropDownList
TabOrder = 0
Text = '0'
Text = 'a'
end
object NodeColorVariesCheck: TCheckBox
AnchorSideLeft.Control = NodeColorLabel
Expand Down Expand Up @@ -723,6 +725,7 @@ object GLForm1: TGLForm1
BorderSpacing.Top = 2
DropDownCount = 22
ItemHeight = 26
ItemIndex = 0
Items.Strings = (
'a'
'b'
Expand All @@ -736,7 +739,7 @@ object GLForm1: TGLForm1
ParentFont = False
Style = csDropDownList
TabOrder = 0
Text = '0'
Text = 'a'
end
object EdgeColorVariesCheck: TCheckBox
AnchorSideLeft.Control = EdgeColorLabel
Expand Down Expand Up @@ -1021,7 +1024,7 @@ object GLForm1: TGLForm1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeshBlendTrack
AnchorSideRight.Side = asrBottom
Left = 180
Left = 177
Height = 18
Hint = 'If checked, edge size varies'
Top = 34
Expand All @@ -1043,8 +1046,8 @@ object GLForm1: TGLForm1
Left = 2
Height = 16
Top = 35
Width = 174
Caption = 'Shader For Background Only'
Width = 171
Caption = 'Shader For Background only'
ParentColor = False
ParentFont = False
end
Expand Down Expand Up @@ -1617,6 +1620,10 @@ object GLForm1: TGLForm1
Caption = 'Invert Colors'
OnClick = LayerInvertColorsMenuClick
end
object LayerAOMapMenu: TMenuItem
Caption = 'Darkening layer'
OnClick = LayerAOMapMenuClick
end
object LayerShowHeaderMenu: TMenuItem
Caption = 'Show Header'
OnClick = LayerShowHeaderMenuClick
Expand Down
56 changes: 47 additions & 9 deletions mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ TGLForm1 = class(TForm)
LayerOptionsBtn: TButton;
LeftSplitter: TSplitter;
CenterPanel: TPanel;
LayerAOMapMenu: TMenuItem;
NextOverlayMenu: TMenuItem;
PrevOverlayMenu: TMenuItem;
OverlaySep: TMenuItem;
overlayload1: TMenuItem;
overlayvisible1: TMenuItem;
PSScript1: TPSScript;
S3Label: TLabel;
BGShader: TLabel;
SaveScriptDialog: TSaveDialog;
ScriptingInsertMenu: TMenuItem;
mesh1: TMenuItem;
Expand Down Expand Up @@ -138,7 +140,6 @@ TGLForm1 = class(TForm)
ColorbarSep: TMenuItem;
meshAlphaTrack: TTrackBar;
MeshBlendTrack: TTrackBar;
BGShader: TLabel;
ROImeshMenu: TMenuItem;
XRayLabel: TLabel;
TransBlackClrbarMenu: TMenuItem;
Expand Down Expand Up @@ -321,6 +322,7 @@ procedure LayerAlphaTrackMouseUp(Sender: TObject; Button: TMouseButton; Shift: T
var Accept: Boolean);
procedure LeftSplitterChangeBounds(Sender: TObject);
procedure LeftSplitterMoved(Sender: TObject);
procedure LayerAOMapMenuClick(Sender: TObject);
procedure PrevOverlayMenuClick(Sender: TObject);
procedure UpdateLayerBox(NewLayers: boolean);

Expand Down Expand Up @@ -1838,6 +1840,7 @@ procedure TGLForm1.OpenScript(scriptname: string; isShowScriptPanel: boolean = t
if not fileexists(scriptname) then exit;
if (ScriptPanel.Width < 24) and (isShowScriptPanel) then
ScriptPanel.Width := 240;
gPrefs.PrevScript := scriptname;
ScriptMemo.Lines.LoadFromFile(scriptname);
gPrefs.InitScript:='';
ScriptingRunMenuClick(nil);
Expand Down Expand Up @@ -1923,6 +1926,8 @@ procedure TGLForm1.LayerPopupPopup(Sender: TObject);
i := LayerList.ItemIndex+ 1;
if (i < 1) or (i > gMesh.OpenOverlays) then exit;
LayerInvertColorsMenu.Checked := gMesh.Overlay[i].LUTinvert;
LayerAOMapMenu.Checked := gMesh.Overlay[i].aoMap;

end;

procedure TGLForm1.LayerListClickCheck(Sender: TObject);
Expand Down Expand Up @@ -2024,6 +2029,16 @@ procedure TGLForm1.LeftSplitterMoved(Sender: TObject);
//caption := inttostr(random(888));
end;

procedure TGLForm1.LayerAOMapMenuClick(Sender: TObject);
var
i: integer;
begin
i := LayerList.ItemIndex+ 1;
if (i < 1) or (i > gMesh.OpenOverlays) then exit;
gMesh.Overlay[i].aoMap := not gMesh.Overlay[i].aoMap;
LayerWidgetChange(sender);
end;

procedure TGLForm1.PrevOverlayMenuClick(Sender: TObject);
var
i: integer;
Expand Down Expand Up @@ -2064,7 +2079,7 @@ procedure TGLForm1.UpdateLayerBox(NewLayers: boolean);
LayerList.Items.add(format('%d/%d: %s',[gMesh.Overlay[i].CurrentVolume, gMesh.Overlay[i].volumes, s]))
else
LayerList.Items.add(s);
LayerList.Checked[i-1] := true;
LayerList.Checked[i-1] := gMesh.Overlay[i].LUTvisible <> kLUTinvisible;//true;
end;
LayerList.ItemIndex := gMesh.OpenOverlays - 1;
end;
Expand Down Expand Up @@ -2306,6 +2321,17 @@ procedure TGLForm1.MultiPassRenderingToolsUpdate;
AOLabel.Visible:= lBetter;
occlusionTrack.Visible:= lBetter;
ShaderForBackgroundOnlyCheck.Visible:= lBetter;
if lBetter then begin
XRayLabel.Caption := 'XRay';
BGShader.Caption := 'Shader For Background Only';
end else begin
XRayLabel.Caption := 'Disabled: ';

if not gPrefs.SupportBetterRenderQuality then
BGShader.Caption := 'Poor Hardware'
else
BGShader.Caption := 'Poor Quality (see Preferences)';
end;
MeshBlendTrack.Visible:= lBetter;
meshAlphaTrack.visible := lBetter;
end;
Expand Down Expand Up @@ -2348,10 +2374,19 @@ function meshBackgroundOpen: boolean;
end;

procedure TGLForm1.UpdateToolbar;
//var
// isOverlayNodeTrack : boolean;
begin
OverlayBox.Visible := (gMesh.OpenOverlays > 0);
//OverlayBox.Top := 0;
BackgroundBox.Visible := (length(gNode.nodes) > 0) or (gTrack.n_count > 0) or ((gMesh.OpenOverlays > 0) and (meshBackgroundOpen));
//isOverlays := (length(gNode.nodes) > 0) or (gTrack.n_count > 0) or ((gMesh.OpenOverlays > 0) and (meshBackgroundOpen));
//BGShader.Enabled := isOverlays;
//ShaderForBackgroundOnlyCheck.Enabled := isOverlays;
//MeshBlendTrack.Enabled := isOverlays;
//isOverlayNodeTrack := (length(gNode.nodes) > 0) or (gTrack.n_count > 0) or ((gMesh.OpenOverlays > 0) and (meshBackgroundOpen));
//MeshBlendTrack.Visible := isOverlayNodeTrack;
//BGShader.Visible := isOverlayNodeTrack;
//ShaderForBackgroundOnlyCheck.Visible := isOverlayNodeTrack;
//BackgroundBox.Visible := (length(gNode.nodes) > 0) or (gTrack.n_count > 0) or ((gMesh.OpenOverlays > 0) and (meshBackgroundOpen));
NodeBox.Visible:= (length(gNode.nodes) > 0) ;
if (length(gNode.edges) > 0) and (EdgeBox.Visible = false) and (BackgroundBox.Visible) then begin
//this keeps node and edge boxes next to each other
Expand Down Expand Up @@ -2607,7 +2642,7 @@ function TGLForm1.OpenMesh(FilenameIN: string): boolean;
exit;
end;
//ext := UpperCase(ExtractFileExt(Filename));
if (ext = '.ANNOT') or (ext = '.MGH') or (ext = '.MGZ') or (ext = '.NII') or (ext = '.HDR') or (ext = '.NII.GZ') or (ext = '.DPV') or (ext = '.ANNOT') or (ext = '.W') or (ext = '.CURV') then begin
if (ext = '.COL') or (ext = '.ANNOT') or (ext = '.MGH') or (ext = '.MGZ') or (ext = '.NII') or (ext = '.HDR') or (ext = '.NII.GZ') or (ext = '.DPV') or (ext = '.ANNOT') or (ext = '.W') or (ext = '.CURV') then begin
OpenOverlay(Filename);
exit;
end else if (ext = '.VTK') and (not isVtkMesh (Filename)) then begin
Expand Down Expand Up @@ -4299,7 +4334,7 @@ function TGLForm1.UpdateClrBar: integer;
if (gMesh.OpenOverlays > 0) then
for lI := 1 to gMesh.OpenOverlays do
//https://www.nitrc.org/forum/forum.php?thread_id=10001&forum_id=6713
if (length(gMesh.overlay[lI].intensity) > 0) and (gMesh.overlay[lI].LUTvisible <> kLUTinvisible) and (not isFreeSurferLUT(gMesh.overlay[lI].LUTindex)) then begin
if (length(gMesh.overlay[lI].intensity) > 0) and (not gMesh.overlay[lI].aoMap) and (gMesh.overlay[lI].LUTvisible <> kLUTinvisible) and (not isFreeSurferLUT(gMesh.overlay[lI].LUTindex)) then begin
isDuplicate := false;
lJ := 1;
while (lJ < lI) do begin
Expand Down Expand Up @@ -5643,10 +5678,13 @@ procedure TGLForm1.SaveMesh(var mesh: TMesh; isSaveOverlays: boolean);
{$ELSE}
procedure TGLForm1.SaveMesh(var mesh: TMesh; isSaveOverlays: boolean);
const
kMeshFilter = 'OBJ (Widely supported)|*.obj|GIfTI (Neuroimaging)|*.gii|MZ3 (Small and fast)|*.mz3|PLY (Widely supported)|*.ply|VRML (Shapeways color printing)|*.wrl';
//kMeshFilter = 'OBJ (Widely supported)|*.obj|GIfTI (Neuroimaging)|*.gii|MZ3 (Small and fast)|*.mz3|PLY (Widely supported)|*.ply|VRML (Shapeways color printing)|*.wrl|WebGL PRWM|*.prwm';
//prwm expects normals
kMeshFilter = 'OBJ (Widely supported)|*.obj|GIfTI (Neuroimaging)|*.gii|MZ3 (Small and fast)|*.mz3|PLY (Widely supported)|*.ply|VRML (Shapeways color printing)|*.wrl|STL (Large and slow)|*.stl';
var
nam, ext, x: string;
begin
//mesh.SaveMesh('/Users/rorden/nrrdify/tst.prwm'); exit;
if length(mesh.Faces) < 1 then begin
showmessage('Unable to save: no mesh is loaded (use File/Open).');
exit;
Expand All @@ -5660,7 +5698,7 @@ procedure TGLForm1.SaveMesh(var mesh: TMesh; isSaveOverlays: boolean);
else if gPrefs.SaveAsFormat = 1 then
ext := '.gii'
else
ext := '.mz3';
ext := '.mz3'; //2
SaveMeshDialog.DefaultExt := ext;
if (fileexists(gPrefs.PrevFilename[1])) or (not isSaveOverlays) then begin
if isSaveOverlays then
Expand All @@ -5677,7 +5715,7 @@ procedure TGLForm1.SaveMesh(var mesh: TMesh; isSaveOverlays: boolean);
if length(SaveMeshDialog.Filename) < 1 then exit;
//caption := inttostr(SaveMeshDialog.FilterIndex)+' '+SaveMeshDialog.Filename; exit; //666
x := UpperCase(ExtractFileExt(SaveMeshDialog.Filename));
if (x <> '.MZ3') and (x <> '.PLY') and (x <> '.OBJ') and (x <> '.GII') and (x <> '.WRL') then begin
if (x <> '.STL') and (x <> '.MZ3') and (x <> '.PLY') and (x <> '.OBJ') and (x <> '.GII') and (x <> '.WRL') and (x <> '.PRWM')then begin
x := ext;
SaveMeshDialog.Filename := SaveMeshDialog.Filename + x;
end;
Expand Down
Loading

0 comments on commit 0a64681

Please sign in to comment.