Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ttk
spam
Commits
d28ed01f
Commit
d28ed01f
authored
Mar 18, 2021
by
Edward Andò
Browse files
Resolves
#199
by checking for NaNs in Phi
parent
83a5c5ca
Pipeline
#62636
passed with stages
in 13 minutes and 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
scripts/spam-ldic
View file @
d28ed01f
...
...
@@ -118,36 +118,43 @@ def correlateOneNode(nodeNumber):
- deltaPhiNorm
"""
PhiInit
=
PhiField
[
nodeNumber
]
imagetteReturns
=
spam
.
DIC
.
getImagettes
(
im1
,
nodePositions
[
nodeNumber
],
args
.
HWS
,
PhiInit
.
copy
(),
im2
,
margin
,
im1mask
=
im1mask
,
minMaskCoverage
=
args
.
MASK_COVERAGE
,
greyThreshold
=
[
args
.
GREY_LOW_THRESH
,
args
.
GREY_HIGH_THRESH
],
applyF
=
'no'
,
twoD
=
twoD
)
if
imagetteReturns
[
'returnStatus'
]
==
1
:
# compute displacement that will be taken by the getImagettes
initialDisplacement
=
numpy
.
round
(
PhiInit
[
0
:
3
,
3
]).
astype
(
int
)
PhiInit
[
0
:
3
,
-
1
]
-=
initialDisplacement
#print(imagetteReturns['imagette1'].shape)
#print(imagetteReturns['imagette2'].shape)
#print()
registerReturns
=
spam
.
DIC
.
register
(
imagetteReturns
[
'imagette1'
],
imagetteReturns
[
'imagette2'
],
im1mask
=
imagetteReturns
[
'imagette1mask'
],
PhiInit
=
PhiInit
,
# minus initial displacement above, which is in the search range and thus taken into account in imagette2
margin
=
1
,
# see top of this file for compensation
maxIterations
=
args
.
MAX_ITERATIONS
,
deltaPhiMin
=
args
.
MIN_DELTA_PHI
,
updateGradient
=
args
.
UPDATE_GRADIENT
,
interpolationOrder
=
args
.
INTERPOLATION_ORDER
,
verbose
=
False
,
imShowProgress
=
False
)
goodPhi
=
registerReturns
[
'Phi'
]
goodPhi
[
0
:
3
,
-
1
]
+=
initialDisplacement
return
nodeNumber
,
goodPhi
,
registerReturns
[
'returnStatus'
],
registerReturns
[
'error'
],
registerReturns
[
'iterations'
],
registerReturns
[
'deltaPhiNorm'
]
if
numpy
.
isfinite
(
PhiInit
).
sum
()
==
16
:
imagetteReturns
=
spam
.
DIC
.
getImagettes
(
im1
,
nodePositions
[
nodeNumber
],
args
.
HWS
,
PhiInit
.
copy
(),
im2
,
margin
,
im1mask
=
im1mask
,
minMaskCoverage
=
args
.
MASK_COVERAGE
,
greyThreshold
=
[
args
.
GREY_LOW_THRESH
,
args
.
GREY_HIGH_THRESH
],
applyF
=
'no'
,
twoD
=
twoD
)
if
imagetteReturns
[
'returnStatus'
]
==
1
:
# compute displacement that will be taken by the getImagettes
initialDisplacement
=
numpy
.
round
(
PhiInit
[
0
:
3
,
3
]).
astype
(
int
)
PhiInit
[
0
:
3
,
-
1
]
-=
initialDisplacement
#print(imagetteReturns['imagette1'].shape)
#print(imagetteReturns['imagette2'].shape)
#print()
registerReturns
=
spam
.
DIC
.
register
(
imagetteReturns
[
'imagette1'
],
imagetteReturns
[
'imagette2'
],
im1mask
=
imagetteReturns
[
'imagette1mask'
],
PhiInit
=
PhiInit
,
# minus initial displacement above, which is in the search range and thus taken into account in imagette2
margin
=
1
,
# see top of this file for compensation
maxIterations
=
args
.
MAX_ITERATIONS
,
deltaPhiMin
=
args
.
MIN_DELTA_PHI
,
updateGradient
=
args
.
UPDATE_GRADIENT
,
interpolationOrder
=
args
.
INTERPOLATION_ORDER
,
verbose
=
False
,
imShowProgress
=
False
)
goodPhi
=
registerReturns
[
'Phi'
]
goodPhi
[
0
:
3
,
-
1
]
+=
initialDisplacement
return
nodeNumber
,
goodPhi
,
registerReturns
[
'returnStatus'
],
registerReturns
[
'error'
],
registerReturns
[
'iterations'
],
registerReturns
[
'deltaPhiNorm'
]
else
:
badPhi
=
numpy
.
eye
(
4
)
badPhi
[
0
:
3
,
3
]
=
numpy
.
nan
return
nodeNumber
,
badPhi
,
imagetteReturns
[
'returnStatus'
],
numpy
.
inf
,
0
,
numpy
.
inf
else
:
### Phi has nans or infs
badPhi
=
numpy
.
eye
(
4
)
badPhi
[
0
:
3
,
3
]
=
numpy
.
nan
return
nodeNumber
,
badPhi
,
imagetteReturns
[
'returnStatus'
]
,
numpy
.
inf
,
0
,
numpy
.
inf
return
nodeNumber
,
badPhi
,
-
7
,
numpy
.
inf
,
0
,
numpy
.
inf
# Loop over input images
...
...
tests/test_scripts.py
View file @
d28ed01f
...
...
@@ -838,8 +838,8 @@ class testAll(unittest.TestCase):
#######################################################
### 4. 2020-09-05 EA and OS: New "extreme" test with particles touching the boundaries
#######################################################
im1
=
spam
.
kalisphera
.
makeBlurryNoisySphere
([
100
,
100
,
100
],
[[
50
,
50
,
50
],
[
50
,
10
,
10
]],
[
10
,
10
],
0.5
,
0.0
5
,
background
=
0.0
,
foreground
=
1.0
)
im2
=
spam
.
kalisphera
.
makeBlurryNoisySphere
([
100
,
100
,
100
],
[[
54
,
54
,
54
],
[
54
,
14
,
14
]],
[
10
,
10
],
0.5
,
0.0
5
,
background
=
0.0
,
foreground
=
1.0
)
im1
=
spam
.
kalisphera
.
makeBlurryNoisySphere
([
100
,
100
,
100
],
[[
50
,
50
,
50
],
[
50
,
10
,
10
]],
[
10
,
10
],
0.5
,
0.0
1
,
background
=
0.0
,
foreground
=
1.0
)
im2
=
spam
.
kalisphera
.
makeBlurryNoisySphere
([
100
,
100
,
100
],
[[
54
,
54
,
54
],
[
54
,
14
,
14
]],
[
10
,
10
],
0.5
,
0.0
1
,
background
=
0.0
,
foreground
=
1.0
)
im1lab
=
scipy
.
ndimage
.
label
(
im1
>
0.5
)[
0
]
tifffile
.
imsave
(
testFolder
+
"extreme-im1.tif"
,
im1
)
...
...
tools/deformation/deformationFunction.py
View file @
d28ed01f
...
...
@@ -186,7 +186,7 @@ def decomposeF(F, twoD=False):
# Check for NaNs if any quit
if
numpy
.
isnan
(
F
).
sum
()
>
0
:
print
(
"deformationFunction.decomposeF(): Nan value in F. Exiting"
)
#
print("deformationFunction.decomposeF(): Nan value in F. Exiting")
return
transformation
# Check for inf if any quit
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment