Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
fslpy
Commits
a51c0bd6
Commit
a51c0bd6
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Tests for 2D images and for bad s/qforms
parent
c428f937
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_image.py
+43
-0
43 additions, 0 deletions
tests/test_image.py
with
43 additions
and
0 deletions
tests/test_image.py
+
43
−
0
View file @
a51c0bd6
...
@@ -184,4 +184,47 @@ def test_Image_orientation(testdir):
...
@@ -184,4 +184,47 @@ def test_Image_orientation(testdir):
assert
radio
.
getOrientation
(
1
,
radio
.
worldToVoxMat
)
==
constants
.
ORIENT_P2A
assert
radio
.
getOrientation
(
1
,
radio
.
worldToVoxMat
)
==
constants
.
ORIENT_P2A
assert
radio
.
getOrientation
(
2
,
radio
.
worldToVoxMat
)
==
constants
.
ORIENT_I2S
assert
radio
.
getOrientation
(
2
,
radio
.
worldToVoxMat
)
==
constants
.
ORIENT_I2S
def
test_Image_sqforms
(
testdir
):
benchmark
=
fslimage
.
Image
(
op
.
join
(
testdir
,
'
MNI152_T1_2mm.nii.gz
'
))
nosform
=
fslimage
.
Image
(
op
.
join
(
testdir
,
'
MNI152_T1_2mm_nosform.nii.gz
'
))
noqform
=
fslimage
.
Image
(
op
.
join
(
testdir
,
'
MNI152_T1_2mm_noqform.nii.gz
'
))
nosqform
=
fslimage
.
Image
(
op
.
join
(
testdir
,
'
MNI152_T1_2mm_nosqform.nii.gz
'
))
scalemat
=
np
.
diag
([
2
,
2
,
2
,
1
])
invScalemat
=
np
.
diag
([
0.5
,
0.5
,
0.5
,
1
])
assert
np
.
all
(
np
.
isclose
(
nosform
.
voxToWorldMat
,
benchmark
.
voxToWorldMat
))
assert
np
.
all
(
np
.
isclose
(
nosform
.
worldToVoxMat
,
benchmark
.
worldToVoxMat
))
assert
np
.
all
(
np
.
isclose
(
noqform
.
voxToWorldMat
,
benchmark
.
voxToWorldMat
))
assert
np
.
all
(
np
.
isclose
(
noqform
.
worldToVoxMat
,
benchmark
.
worldToVoxMat
))
assert
np
.
all
(
np
.
isclose
(
nosqform
.
voxToWorldMat
,
scalemat
))
assert
np
.
all
(
np
.
isclose
(
nosqform
.
worldToVoxMat
,
invScalemat
))
def
test_2D_images
(
testdir
):
tests
=
[(
'
MNI152_T1_2mm_sliceXY.nii.gz
'
,
(
91
,
109
,
1
),
(
2.0
,
2.0
,
2.0
)),
(
'
MNI152_T1_2mm_sliceXZ.nii.gz
'
,
(
91
,
1
,
91
),
(
2.0
,
2.0
,
2.0
)),
(
'
MNI152_T1_2mm_sliceYZ.nii.gz
'
,
(
1
,
109
,
91
),
(
2.0
,
2.0
,
2.0
)),
(
'
MNI152_T1_2mm_sliceXY_4D.nii.gz
'
,
(
91
,
109
,
1
,
5
),
(
2.0
,
2.0
,
2.0
,
1.0
)),
# When you create an XY slice with
# fslroi, it sets nifti/dim0 to 2.
# This should still be read in as
# a 3D image.
(
'
MNI152_T1_2mm_sliceXY_bad_dim0.nii.gz
'
,
(
91
,
109
,
1
),
(
2.0
,
2.0
,
2.0
))]
for
fname
,
shape
,
pixdim
in
tests
:
fname
=
op
.
join
(
testdir
,
'
nifti2D
'
,
fname
)
image
=
fslimage
.
Image
(
fname
)
assert
len
(
shape
)
==
len
(
image
.
shape
)
assert
len
(
shape
)
==
len
(
image
[:].
shape
)
assert
len
(
pixdim
)
==
len
(
image
.
pixdim
)
assert
tuple
(
map
(
float
,
shape
))
==
tuple
(
map
(
float
,
image
.
shape
))
assert
tuple
(
map
(
float
,
shape
))
==
tuple
(
map
(
float
,
image
[:].
shape
))
assert
tuple
(
map
(
float
,
pixdim
))
==
tuple
(
map
(
float
,
image
.
pixdim
))
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