Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yaoyuping
nnDetection
Commits
e4274364
Commit
e4274364
authored
Jun 04, 2022
by
Baumgartner, Michael
Browse files
fix itk param check
parent
082f7221
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
13 deletions
+29
-13
nndet/utils/check.py
nndet/utils/check.py
+29
-13
No files found.
nndet/utils/check.py
View file @
e4274364
...
...
@@ -268,7 +268,7 @@ def _full_check(
def
_check_itk_params
(
img_seq
:
Sequence
[
sitk
.
Image
],
paths
:
Sequence
[
Path
],
)
->
None
:
)
->
None
:
"""
Check Dimension, Origin, Direction and Spacing of a Sequence of images
...
...
@@ -283,15 +283,31 @@ def _check_itk_params(
ValueError: raised if spacing does not match
"""
for
idx
,
img
in
enumerate
(
img_seq
[
1
:],
start
=
1
):
if
not
(
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetDimension
())
==
\
np
.
asarray
(
img
.
GetDimension
()))):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same dimensions!"
)
if
not
(
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetOrigin
())
==
\
np
.
asarray
(
img
.
GetOrigin
()))):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same origin!"
)
if
not
(
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetDirection
())
==
\
np
.
asarray
(
img
.
GetDirection
()))):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same direction!"
)
if
not
(
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetSpacing
())
==
\
np
.
asarray
(
img
.
GetSpacing
()))):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same spacing!"
)
if
not
(
np
.
asarray
(
img_seq
[
0
].
GetDimension
())
==
np
.
asarray
(
img
.
GetDimension
())
).
all
():
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same dimensions!"
)
if
not
((
np
.
asarray
(
img_seq
[
0
].
GetSize
())
==
np
.
asarray
(
img
.
GetSize
()))).
all
():
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same dimensions!"
)
if
not
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetOrigin
()),
np
.
asarray
(
img
.
GetOrigin
())
):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same origin!"
)
if
not
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetDirection
()),
np
.
asarray
(
img
.
GetDirection
())
):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same direction!"
)
if
not
np
.
allclose
(
np
.
asarray
(
img_seq
[
0
].
GetSpacing
()),
np
.
asarray
(
img
.
GetSpacing
())
):
raise
ValueError
(
f
"Expected
{
paths
[
idx
]
}
and
{
paths
[
0
]
}
to have same spacing!"
)
Write
Preview
Markdown
is supported
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