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
3c2cd7f7
Commit
3c2cd7f7
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted atlas unit tests
parent
3e4fe718
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pytest.ini
+0
-3
0 additions, 3 deletions
pytest.ini
setup.cfg
+5
-1
5 additions, 1 deletion
setup.cfg
tests/test_atlases.py
+28
-18
28 additions, 18 deletions
tests/test_atlases.py
with
33 additions
and
22 deletions
pytest.ini
deleted
100644 → 0
+
0
−
3
View file @
3e4fe718
[pytest]
testpaths
=
tests
addopts
=
-s -v --niters=50 --cov=fsl --cov-report=html --html=report.html --cov-append
This diff is collapsed.
Click to expand it.
setup.cfg
+
5
−
1
View file @
3c2cd7f7
...
@@ -2,4 +2,8 @@
...
@@ -2,4 +2,8 @@
test
=
pytest
test
=
pytest
[bdist_wheel]
[bdist_wheel]
universal
=
1
universal
=
1
\ No newline at end of file
[tool:pytest]
testpaths
=
tests
addopts
=
-s -v --niters=50 --cov=fsl
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_atlases.py
+
28
−
18
View file @
3c2cd7f7
...
@@ -156,7 +156,10 @@ def test_add_remove_atlas():
...
@@ -156,7 +156,10 @@ def test_add_remove_atlas():
assert
val
.
atlasID
==
'
mla
'
assert
val
.
atlasID
==
'
mla
'
removed
[
0
]
=
True
removed
[
0
]
=
True
xmlfile
=
_make_dummy_atlas
(
testdir
,
'
My Little Atlas
'
,
'
MLA
'
,
'
MyLittleAtlas
'
)
xmlfile
=
_make_dummy_atlas
(
testdir
,
'
My Little Atlas
'
,
'
MLA
'
,
'
MyLittleAtlas
'
)
reg
.
register
(
'
added
'
,
atlas_added
,
topic
=
'
add
'
)
reg
.
register
(
'
added
'
,
atlas_added
,
topic
=
'
add
'
)
reg
.
register
(
'
removed
'
,
atlas_removed
,
topic
=
'
remove
'
)
reg
.
register
(
'
removed
'
,
atlas_removed
,
topic
=
'
remove
'
)
...
@@ -180,8 +183,10 @@ def test_extra_atlases():
...
@@ -180,8 +183,10 @@ def test_extra_atlases():
with
tests
.
testdir
()
as
testdir
:
with
tests
.
testdir
()
as
testdir
:
atlas1spec
=
_make_dummy_atlas
(
testdir
,
'
My atlas 1
'
,
'
myatlas1
'
,
'
MyAtlas1
'
)
atlas1spec
=
_make_dummy_atlas
(
atlas2spec
=
_make_dummy_atlas
(
testdir
,
'
My atlas 2
'
,
'
myatlas2
'
,
'
MyAtlas2
'
)
testdir
,
'
My atlas 1
'
,
'
myatlas1
'
,
'
MyAtlas1
'
)
atlas2spec
=
_make_dummy_atlas
(
testdir
,
'
My atlas 2
'
,
'
myatlas2
'
,
'
MyAtlas2
'
)
badspec
=
op
.
join
(
testdir
,
'
badSpec.xml
'
)
badspec
=
op
.
join
(
testdir
,
'
badSpec.xml
'
)
with
open
(
badspec
,
'
wt
'
)
as
f
:
with
open
(
badspec
,
'
wt
'
)
as
f
:
...
@@ -194,8 +199,10 @@ def test_extra_atlases():
...
@@ -194,8 +199,10 @@ def test_extra_atlases():
'
badatlas2={}
'
.
format
(
badspec
)
'
badatlas2={}
'
.
format
(
badspec
)
])
])
with
mock
.
patch
(
'
fsl.data.atlases.fslsettings.read
'
,
return_value
=
extraAtlases
),
\
with
mock
.
patch
(
'
fsl.data.atlases.fslsettings.read
'
,
mock
.
patch
(
'
fsl.data.atlases.fslsettings.write
'
,
return_value
=
None
):
return_value
=
extraAtlases
),
\
mock
.
patch
(
'
fsl.data.atlases.fslsettings.write
'
,
return_value
=
None
):
reg
=
atlases
.
registry
reg
=
atlases
.
registry
reg
.
rescanAtlases
()
reg
.
rescanAtlases
()
...
@@ -245,11 +252,11 @@ def test_label_atlas_coord():
...
@@ -245,11 +252,11 @@ def test_label_atlas_coord():
# Summary atlas (a thresholded probabilistic atlas)
# Summary atlas (a thresholded probabilistic atlas)
atlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
atlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
loadSummary
=
True
)
hoctests
=
[
hoctests
=
[
([
-
23
,
58
,
20
],
0
),
([
-
23
,
58
,
20
],
1
),
([
-
23
,
27
,
-
20
],
3
2
),
([
-
23
,
27
,
-
20
],
3
3
),
([
-
37
,
-
75
,
29
],
2
1
),
([
-
37
,
-
75
,
29
],
2
2
),
([
-
1
,
37
,
6
],
2
8
),
([
-
1
,
37
,
6
],
2
9
),
([
54
,
-
44
,
-
27
],
1
5
)]
([
54
,
-
44
,
-
27
],
1
6
)]
for
coords
,
expected
in
hoctests
:
for
coords
,
expected
in
hoctests
:
assert
atlas
.
label
(
coords
)
==
expected
assert
atlas
.
label
(
coords
)
==
expected
...
@@ -307,17 +314,20 @@ def test_prob_atlas_mask():
...
@@ -307,17 +314,20 @@ def test_prob_atlas_mask():
atlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
resolution
=
res
)
atlas
=
reg
.
loadAtlas
(
'
harvardoxford-cortical
'
,
resolution
=
res
)
mask
=
fslimage
.
Image
(
maskfile
)
mask
=
fslimage
.
Image
(
maskfile
)
labels
,
props
=
atlas
.
maskProportions
(
mask
)
props
=
atlas
.
maskProportions
(
mask
)
labels2
,
props2
=
atlas
.
proportions
(
mask
)
props2
=
atlas
.
proportions
(
mask
)
expected
=
np
.
loadtxt
(
resultsfile
)
expected
=
np
.
loadtxt
(
resultsfile
)
exp
labe
ls
=
expected
[:,
0
]
exp
vo
ls
=
list
(
expected
[:,
0
]
)
expprops
=
expected
[:,
1
]
expprops
=
list
(
expected
[:,
1
]
)
assert
np
.
all
(
np
.
isclose
(
labels
,
labels2
))
assert
np
.
all
(
np
.
isclose
(
props
,
props2
))
assert
np
.
all
(
np
.
isclose
(
props
,
props2
))
assert
np
.
all
(
np
.
isclose
(
labels
,
explabels
))
for
i
in
range
(
len
(
props
)):
assert
np
.
all
(
np
.
isclose
(
props
,
expprops
))
try
:
expi
=
expvols
.
index
(
i
)
assert
np
.
isclose
(
props
[
i
],
expprops
[
expi
])
except
ValueError
:
assert
np
.
isclose
(
props
[
i
],
0
)
def
test_label_atlas_mask
():
def
test_label_atlas_mask
():
...
...
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