Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b74ff03
Add file dropdown
ReubenHill May 26, 2023
dcdb229
Trim trailing whitespace
ReubenHill May 26, 2023
c0a2de6
Make atlas points count editable
ReubenHill May 26, 2023
2a64774
Separate headfile stuff so it's loadable
ReubenHill May 26, 2023
c12181e
Check atlas data before using it
ReubenHill May 29, 2023
bf6f86b
save atlas_dir at exit
ReubenHill May 29, 2023
7773fa5
Make atlas imports work
ReubenHill May 29, 2023
f52c06b
add double tap warning
ReubenHill May 29, 2023
ba700f1
Pop up with slider for warn distance
ReubenHill May 29, 2023
4ff0d9d
Add undo to menu and ctrl-z shortcut
ReubenHill Jun 1, 2023
4128869
make settings.mat if not found at exit
ReubenHill Jun 1, 2023
07b34a5
Add saveas to file menu
ReubenHill Jun 1, 2023
16fe53f
make undo work with atlas points
ReubenHill Jun 1, 2023
29057d5
Be able to set measured point as landmark
ReubenHill Jun 2, 2023
5d0a3ec
stop head being more lit each time align is done
ReubenHill Jun 2, 2023
b8eed60
add expected coords checker
ReubenHill Jun 2, 2023
b18586b
swap length for size where necessary
ReubenHill Jun 2, 2023
0f05e7f
make saving coordinates optional
ReubenHill Jun 2, 2023
8c55fd5
add example list of coordinates to find
ReubenHill Jun 2, 2023
0d4f6ee
Make distributable as 1.3.0-alpha
ReubenHill Jun 2, 2023
2b86c4d
display correct version num on gui
ReubenHill Jun 22, 2023
7fb13ae
display correct version num in file
ReubenHill Jun 22, 2023
c2c448f
fix bug of points not disappearing on graph
ReubenHill Jun 22, 2023
be2394c
fix delete row not removing plotted point
ReubenHill Jun 22, 2023
bf04f32
Delete+Undo+Set row modifications
ReubenHill Jun 22, 2023
0d2c4a9
Unify delete rows data and set point to get
ReubenHill Jun 22, 2023
8b7210c
Add expected coords import button and rename insert
ReubenHill Jun 23, 2023
6d6f1e4
Add insert rows button
ReubenHill Jun 23, 2023
6f003b3
Don't allow measurement during double tap warning
ReubenHill Jun 23, 2023
5bc880c
Change expected measurement error+warning behaviour
ReubenHill Jun 23, 2023
5477621
Stop meas success being cleared if double tap warn
ReubenHill Jun 23, 2023
b06ba7f
Don't measure points after error
ReubenHill Jun 23, 2023
b9118f7
Change double tap warning to error
ReubenHill Jun 23, 2023
7a58ce7
Make diable_measurements work again
ReubenHill Jun 23, 2023
cb88f4b
add option to disable double tap error
ReubenHill Jun 23, 2023
6850961
add more button equivs to toolbar
ReubenHill Jun 23, 2023
a2880ce
add menu option to reset gui
ReubenHill Jun 23, 2023
309ab13
Add option to disallow measurements until...
ReubenHill Jun 23, 2023
517d0ce
Rename delete and set button
ReubenHill Jun 26, 2023
bc3b568
Warn that export locations doesn't export coords
ReubenHill Jun 26, 2023
6408b8c
Update expected coordinates import
ReubenHill Jun 26, 2023
07e2570
Add reset expected coords menu button
ReubenHill Jun 26, 2023
1b64f88
Add tick boxes which tick when get expected point
ReubenHill Jun 26, 2023
8b5471b
Fix data saving and default list of points
ReubenHill Jun 26, 2023
27b828a
update to 1.3.0-beta
ReubenHill Jun 26, 2023
74b1f87
Fix double tap and delete+set bugs
ReubenHill Jun 30, 2023
be78fce
Fix 'remove last measured pt' issues
ReubenHill Jun 30, 2023
1e1eb7c
F import expected coordinates bug
ReubenHill Jun 30, 2023
d8bd884
Update version to 1.3.0-beta2
ReubenHill Jun 30, 2023
42e6f96
enable double tap error by default
ReubenHill Jun 30, 2023
9057b2b
Change unexpected measurement to warning not error
ReubenHill Jun 30, 2023
e9df38f
Tickboxes changed to text with 3 states
ReubenHill Jun 30, 2023
ebd75fa
Add more information after loading expected coords
ReubenHill Jun 30, 2023
b9fe5e4
Save all data including expected coords info
ReubenHill Jun 30, 2023
60d5bde
add supposed figure changes
ReubenHill Jun 30, 2023
524481c
Revert "add supposed figure changes"
ReubenHill Jun 30, 2023
20c5213
disable measurements for insert rows popup
ReubenHill Jul 3, 2023
5f218c3
Add ability to prepopulate locations when inserting rows
ReubenHill Jul 3, 2023
13c1010
Optionally save locations between sessions
ReubenHill Jul 3, 2023
6e53bea
Update version to 1.3.0-gamma
ReubenHill Jul 3, 2023
7f09a41
Either insert rows by number or by names
ReubenHill Jul 3, 2023
41f5a7e
make clear when not specifying any points to insert and fix bug
ReubenHill Jul 3, 2023
81b71d5
only ask to save locations list if edited
ReubenHill Jul 3, 2023
e84d0fb
apparently edited figure
ReubenHill Jul 3, 2023
a800c9a
update version to 1.3.0-gamma2
ReubenHill Jul 3, 2023
a5f375a
just in case, save the locations anyway!
ReubenHill Jul 3, 2023
b889858
fix confusing message
ReubenHill Jul 10, 2023
c952dcb
Rename table title to LOCATION | COORDINATES (cm)
ReubenHill Jul 10, 2023
6ba92f2
rename to Delete Coordinates Row(s) and Set Point to Get
ReubenHill Jul 10, 2023
8b9b50a
Add nomenclature to instructions displayed on GUI
ReubenHill Jul 10, 2023
33cc9dc
rename to Remove Last Measured Coordinate (Ctrl+Z)
ReubenHill Jul 10, 2023
dd51577
Make Export Locations... warning more explicit
ReubenHill Jul 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified DIGIGUI.fig
Binary file not shown.
1,997 changes: 1,588 additions & 409 deletions DIGIGUI.m

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions DIGIGUI.prj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<deployment-project plugin="plugin.ezdeploy" plugin-version="1.0">
<configuration build-checksum="222460721" file="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI\DIGIGUI.prj" location="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI" name="DIGIGUI" preferred-package-location="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI\DIGIGUI\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.standalone" target-name="Application Compiler">
<configuration build-checksum="187533882" file="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI\DIGIGUI.prj" location="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI" name="DIGIGUI" preferred-package-location="C:\Users\Reuben\Documents\GitHub\Polhemus-GUI\DIGIGUI\for_redistribution" preferred-package-type="package.type.exe" target="target.ezdeploy.standalone" target-name="Application Compiler">
<param.appname>DIGIGUI</param.appname>
<param.icon>${PROJECT_ROOT}\DIGIGUI_resources\icon.ico</param.icon>
<param.icons>
Expand All @@ -8,12 +8,12 @@
<file>${PROJECT_ROOT}\DIGIGUI_resources\icon_24.png</file>
<file>${PROJECT_ROOT}\DIGIGUI_resources\icon_16.png</file>
</param.icons>
<param.version>1.2</param.version>
<param.version>1.3</param.version>
<param.authnamewatermark>Reuben Nixon-Hill</param.authnamewatermark>
<param.email>reuben.w.hill@gmail.com</param.email>
<param.company />
<param.summary>A graphical user interface for use with the Polhemus Patriot Digitiser at a baud rate of 115200.</param.summary>
<param.description>Version 1.2.1.
<param.description>Version 1.3.0-gamma2.
Copyright © 2023 Reuben Nixon-Hill, MATLAB® © 1984 - 2016 The MathWorks, Inc.
This package is licenced under the MIT Licence (see LICENCE.txt) and was created using MATLAB® compiler.</param.description>
<param.screenshot />
Expand All @@ -38,9 +38,9 @@ This package is licenced under the MIT Licence (see LICENCE.txt) and was created
<param.web.mcr.name>DIGIGUI_web</param.web.mcr.name>
<param.package.mcr.name>DIGIGUI_mcr</param.package.mcr.name>
<param.no.mcr.name>MyAppInstaller_app</param.no.mcr.name>
<param.windows.command.prompt>true</param.windows.command.prompt>
<param.create.log>false</param.create.log>
<param.log.file>log</param.log.file>
<param.windows.command.prompt>false</param.windows.command.prompt>
<param.create.log>true</param.create.log>
<param.log.file>log.txt</param.log.file>
<unset>
<param.company />
<param.screenshot />
Expand All @@ -61,25 +61,30 @@ This package is licenced under the MIT Licence (see LICENCE.txt) and was created
<param.package.mcr />
<param.no.mcr />
<param.no.mcr.name />
<param.windows.command.prompt />
<param.create.log />
</unset>
<fileset.main>
<file>${PROJECT_ROOT}\DIGIGUI.m</file>
</fileset.main>
<fileset.resources>
<file>${PROJECT_ROOT}\DIGIGUI.fig</file>
<file>${PROJECT_ROOT}\refpts_landmarks.mat</file>
<file>${PROJECT_ROOT}\scalpSurfaceMesh.mat</file>
<file>${PROJECT_ROOT}\default_atlas\atlas_landmarks.mat</file>
<file>${PROJECT_ROOT}\default_atlas\CoordinateTransform.m</file>
<file>${PROJECT_ROOT}\default_atlas\mesh.mat</file>
<file>${PROJECT_ROOT}\default_settings.mat</file>
<file>${PROJECT_ROOT}\savedLocationNames.mat</file>
</fileset.resources>
<fileset.package>
<file>${PROJECT_ROOT}\default_atlas</file>
<file>${PROJECT_ROOT}\expected_coordinates_example.txt</file>
<file>${PROJECT_ROOT}\LICENCE.txt</file>
<file>${PROJECT_ROOT}\Locations Example.txt</file>
<file>${PROJECT_ROOT}\Readme.txt</file>
</fileset.package>
<fileset.depfun>
<file>${PROJECT_ROOT}\affine_trans_RJC.m</file>
<file>${PROJECT_ROOT}\affinemap.m</file>
<file>${PROJECT_ROOT}\checkmark.tif</file>
<file>${PROJECT_ROOT}\DIGIGUI.fig</file>
<file>${PROJECT_ROOT}\doubletapdialog.m</file>
<file>${PROJECT_ROOT}\FindPatriotSerial.m</file>
</fileset.depfun>
<build-deliverables>
Expand Down
2 changes: 1 addition & 1 deletion Polhemus_Headmesh_Process.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% Head mesh transformation sequence for polhemus gui
% landmarks = Inion, Nasion, Ar, Al, Cz measured with Polhemus
% pts = landmarks of atlas (from refpts_landmarks.mat)
% pts = landmarks of atlas (from default_atlas/atlas_landmarks.mat)
% mesh = adult atlas scalp mesh

[A,B] = affinemap(pts,landmarks);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ For more information see the comments in `DIGIGUI.m`.

This has been designed for use with MATLAB compiler using the `DIGIGUI.prj` file.

Copyright (C) 2022 Reuben W. Nixon-Hill (formerly Reuben W. Hill)
Copyright (C) 2023 Reuben W. Nixon-Hill (formerly Reuben W. Hill)

This package is licenced under the MIT Licence (see LICENCE.txt).
Binary file added checkmark.tif
Binary file not shown.
65 changes: 65 additions & 0 deletions default_atlas/CoordinateTransform.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
%This function outputs a vector to transform inion to origin
%also outputs rotation transformation matrix to allign the head model to
%intuitive coordinates.
%To apply to row vector, the vector should be multiplied by the transpose
%with the vector on the left
function [Matrix,vector] = CoordinateTransform(landmarks)
%calculate lengths between vectors

%these are the untransformed reference points, defined here in case I want
%to use them
Nasion = landmarks(1,:);
Inion = landmarks(2,:);
Ar = landmarks(3,:);
Al = landmarks(4,:);
Cz = landmarks(5,:);

%------TRANSLATION-------

%translate inion to origion
vector = -Inion;

%translate Al
Al = Al + vector;

%------ROTATE AL TO Y AXIS-------

%calculate rotation to y axis
AlToYAxisRot = vrrotvec(Al,[0,1,0]);

%convert to rotation matrix
AlToYAxisMatrix = vrrotvec2mat(AlToYAxisRot);

%repmat
% Apply translation and rotation to points
for k = 1:5
landmarks(k,:) = landmarks(k,:)+vector;
landmarks(k,:) = landmarks(k,:)*AlToYAxisMatrix';
end

%------ROTATE AR TO XY PLANE ABOUT INION-AL AXIS-------

% find angle to rotate nasion into XY plane about the new y axis
[ArToXYRotAngle,~] = cart2pol(landmarks(3,1),landmarks(3,3));

%Find second rotation matrix
ArToXYMatrix = vrrotvec2mat([0,1,0,ArToXYRotAngle]);

% Apply second rotation to points
for k = 1:5
landmarks(k,:) = landmarks(k,:)*ArToXYMatrix';
end

%------FINAL ROTATION ABOUT AL-AR AXIS TO ALLIGN INION AND NASION-------

%find angle of nasion to xy plane
[~,NasionToXYRotAngle,~] = cart2sph(landmarks(1,1),landmarks(1,2),landmarks(1,3));
%define vector to rotate around (the line joining AL and AR)
NasionRotVector = landmarks(4,:) - landmarks(3,:);
%find rotation matrix
NasionToXYRotMatrix = vrrotvec2mat([NasionRotVector, NasionToXYRotAngle]);

%------OUTPUT FINAL MATRIX-------
Matrix = NasionToXYRotMatrix*ArToXYMatrix*AlToYAxisMatrix;

end
Binary file added default_atlas/atlas_landmarks.mat
Binary file not shown.
File renamed without changes.
Binary file added default_settings.mat
Binary file not shown.
64 changes: 64 additions & 0 deletions doubletapdialog.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
function [choice, enabled] = doubletapdialog(currentchoice, currentenabled)

d = dialog('Position',[300 300 260 180],'Name','Double tap');

checkbox = uicontrol('Parent', d, ...
'Style', 'checkbox', ...
'String', 'Enable double tap error?', ...
'Position', [68 70 200 170], ...
'Value', currentenabled, ...
'Callback', @checkbox_callback);

slider = uicontrol('Parent',d,...
'Style','slider',...
'Position',[31 60 200 25],...
'Min',0,...
'Max',1,...
'Value', currentchoice,...
'Callback',@slider_callback);

txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[31 100 210 30],...
'String', sprintf('Use slider to set error distance.\nCurrent value: %0.2g cm.', currentchoice));

fun = @(~,e)set(txt,'String',sprintf('Use slider to set error distance.\nCurrent value: %0.2g cm.', get(e.AffectedObject,'Value')));

addlistener(slider, 'Value', 'PostSet', fun);

btn = uicontrol('Parent',d,...
'Position',[99 20 70 25],...
'String','Close',...
'Callback','delete(gcf)');

choice = currentchoice;
enabled = currentenabled;

if currentenabled
set(txt,'Enable','on');
set(slider,'Enable','on');
else
set(txt,'Enable','off');
set(slider,'Enable','off');
end

% Wait for d to close before running to completion
uiwait(d);


function slider_callback(slider,event)
choice = slider.Value;
end

function checkbox_callback(checkbox,event)
enabled = checkbox.Value;
if enabled
set(txt,'Enable','on');
set(slider,'Enable','on');
else
set(txt,'Enable','off');
set(slider,'Enable','off');
end
end

end
5 changes: 5 additions & 0 deletions expected_coordinates_example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Location,X,Y,Z
Nasion,15.0,0,0
Ar,0,0,0
Example Pt 1,20.0,0,0
Tolerance,10,NaN,NaN
Binary file removed refpts_landmarks.mat
Binary file not shown.
Binary file modified savedLocationNames.mat
Binary file not shown.