Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
AmpScan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Joshua Steer
AmpScan
Commits
b24c9690
Commit
b24c9690
authored
6 years ago
by
Joshua Steer
Browse files
Options
Downloads
Patches
Plain Diff
Changes to registration smoothing
parent
cafa1a59
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
AmpScan/registration.py
+15
-16
15 additions, 16 deletions
AmpScan/registration.py
AmpScan/ssm.py
+3
-2
3 additions, 2 deletions
AmpScan/ssm.py
GUIs/AmpScanGUI.py
+0
-2
0 additions, 2 deletions
GUIs/AmpScanGUI.py
with
18 additions
and
20 deletions
AmpScan/registration.py
+
15
−
16
View file @
b24c9690
...
...
@@ -86,53 +86,52 @@ class registration(object):
[
self
.
b
.
vert
,
self
.
b
.
faces
,
self
.
b
.
values
]))
regData
=
copy
.
deepcopy
(
bData
)
self
.
reg
=
AmpObject
(
regData
,
stype
=
'
reg
'
)
self
.
disp
=
AmpObject
({
'
vert
'
:
np
.
zeros
(
self
.
reg
.
vert
.
shape
),
'
faces
'
:
self
.
reg
.
faces
,
'
values
'
:
self
.
reg
.
values
})
if
scale
is
not
None
:
tmin
=
self
.
t
.
vert
.
min
(
axis
=
0
)[
2
]
rmin
=
self
.
reg
.
vert
.
min
(
axis
=
0
)[
2
]
SF
=
((
tmin
-
scale
)
/
(
rmin
-
scale
))
-
1
logic
=
self
.
reg
.
vert
[:,
2
]
<
scale
d
=
(
self
.
reg
.
vert
[
logic
,
2
]
-
scale
)
*
SF
self
.
reg
.
vert
[
logic
,
2
]
+=
d
self
.
disp
.
vert
[
logic
,
2
]
+=
d
self
.
reg
.
vert
=
self
.
b
.
vert
+
self
.
disp
.
vert
normals
=
np
.
cross
(
self
.
t
.
vert
[
self
.
t
.
faces
[:,
1
]]
-
self
.
t
.
vert
[
self
.
t
.
faces
[:,
0
]],
self
.
t
.
vert
[
self
.
t
.
faces
[:,
2
]]
-
self
.
t
.
vert
[
self
.
t
.
faces
[:,
0
]])
mag
=
(
normals
**
2
).
sum
(
axis
=
1
)
if
subset
is
None
:
rVert
=
self
.
reg
.
vert
else
:
rVert
=
self
.
reg
.
vert
[
subset
]
for
step
in
np
.
arange
(
steps
,
0
,
-
1
,
dtype
=
float
):
# Index of 10 centroids nearest to each baseline vertex
ind
=
tTree
.
query
(
rVert
,
neigh
)[
1
]
# D = np.zeros(self.reg.vert.shape)
ind
=
tTree
.
query
(
self
.
reg
.
vert
,
neigh
)[
1
]
# Define normals for faces of nearest faces
norms
=
normals
[
ind
]
# Get a point on each face
fPoints
=
self
.
t
.
vert
[
self
.
t
.
faces
[
ind
,
0
]]
# Calculate dot product between point on face and normals
d
=
np
.
einsum
(
'
ijk, ijk->ij
'
,
norms
,
fPoints
)
t
=
(
d
-
np
.
einsum
(
'
ijk, ik->ij
'
,
norms
,
rV
ert
))
/
mag
[
ind
]
t
=
(
d
-
np
.
einsum
(
'
ijk, ik->ij
'
,
norms
,
self
.
reg
.
v
ert
))
/
mag
[
ind
]
# Calculate the vector from old point to new point
G
=
rV
ert
[:,
None
,
:]
+
np
.
einsum
(
'
ijk, ij->ijk
'
,
norms
,
t
)
G
=
self
.
reg
.
v
ert
[:,
None
,
:]
+
np
.
einsum
(
'
ijk, ij->ijk
'
,
norms
,
t
)
# Ensure new points lie inside points otherwise set to 99999
# Find smallest distance from old to new point
if
inside
is
False
:
G
=
G
-
rV
ert
[:,
None
,
:]
G
=
G
-
self
.
reg
.
v
ert
[:,
None
,
:]
GMag
=
np
.
sqrt
(
np
.
einsum
(
'
ijk, ijk->ij
'
,
G
,
G
))
GInd
=
GMag
.
argmin
(
axis
=
1
)
else
:
G
,
GInd
=
self
.
__calcBarycentric
(
rV
ert
,
G
,
ind
)
G
,
GInd
=
self
.
__calcBarycentric
(
self
.
reg
.
v
ert
,
G
,
ind
)
# Define vector from baseline point to intersect point
D
=
G
[
np
.
arange
(
len
(
G
)),
GInd
,
:]
rVert
+=
D
/
step
# rVert += D/step
self
.
disp
.
vert
+=
D
/
step
if
smooth
>
0
and
step
>
1
:
# v = self.reg.vert[~subset]
self
.
reg
.
lp_smooth
(
smooth
,
brim
=
fixBrim
)
# self.reg.vert[~subset] = v
self
.
disp
.
lp_smooth
(
smooth
,
brim
=
fixBrim
)
self
.
reg
.
vert
=
self
.
b
.
vert
+
self
.
disp
.
vert
else
:
self
.
reg
.
vert
=
self
.
b
.
vert
+
self
.
disp
.
vert
self
.
reg
.
calcNorm
()
self
.
reg
.
calcStruct
()
self
.
reg
.
values
[:]
=
self
.
calcError
(
error
)
...
...
This diff is collapsed.
Click to expand it.
AmpScan/ssm.py
+
3
−
2
View file @
b24c9690
...
...
@@ -9,6 +9,7 @@ import os
import
numpy
as
np
from
.core
import
AmpObject
from
.registration
import
registration
import
os
class
pca
(
object
):
...
...
@@ -60,7 +61,7 @@ class pca(object):
"""
self
.
fnames
=
[
f
for
f
in
os
.
listdir
(
path
)
if
f
.
endswith
(
'
.stl
'
)]
self
.
shapes
=
[
AmpObject
(
path
+
f
,
'
limb
'
,
unify
=
unify
)
for
f
in
self
.
fnames
]
self
.
shapes
=
[
AmpObject
(
os
.
path
.
join
(
path
,
f
)
,
'
limb
'
,
unify
=
unify
)
for
f
in
self
.
fnames
]
for
s
in
self
.
shapes
:
s
.
lp_smooth
(
3
,
brim
=
True
)
...
...
@@ -100,7 +101,7 @@ class pca(object):
self
.
registered
.
append
(
r
)
if
save
is
not
None
:
for
f
,
r
in
zip
(
self
.
fnames
,
self
.
registered
):
r
.
save
(
save
+
f
)
r
.
save
(
os
.
path
.
join
(
save
,
f
)
)
self
.
X
=
np
.
array
([
r
.
vert
.
flatten
()
for
r
in
self
.
registered
]).
T
if
baseline
is
True
:
self
.
X
=
np
.
c_
[
self
.
X
,
self
.
baseline
.
vert
.
flatten
()]
...
...
This diff is collapsed.
Click to expand it.
GUIs/AmpScanGUI.py
+
0
−
2
View file @
b24c9690
import
sys
import
numpy
as
np
from
vtk.util
import
numpy_support
import
vtk
from
AmpScan
import
AmpObject
from
AmpScan.registration
import
registration
from
AmpScan.align
import
align
from
AmpScan.ampVis
import
qtVtkWindow
from
AmpScan.pressSens
import
pressSense
from
PyQt5.QtCore
import
QPoint
,
QSize
,
Qt
,
QTimer
,
QRect
,
pyqtSignal
from
PyQt5.QtGui
import
(
QColor
,
QFontMetrics
,
QImage
,
QPainter
,
QIcon
,
QOpenGLVersionProfile
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment