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
49dd588f
Commit
49dd588f
authored
6 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
TEST: More comprehensive tests for extract_noise
parent
c6beb86d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_extract_noise.py
+71
-0
71 additions, 0 deletions
tests/test_extract_noise.py
with
71 additions
and
0 deletions
tests/test_extract_noise.py
+
71
−
0
View file @
49dd588f
...
...
@@ -5,6 +5,7 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import
sys
import
numpy
as
np
...
...
@@ -84,3 +85,73 @@ def test_loadConfoundFiles():
with
pytest
.
raises
(
ValueError
):
extn
.
loadConfoundFiles
(
conffiles
,
npts
)
def
test_extract_noise
():
with
tempdir
.
tempdir
()
as
td
:
# (npts, ncomps)
melmix
=
np
.
random
.
randint
(
1
,
100
,
(
100
,
20
))
np
.
savetxt
(
'
melodic_mix
'
,
melmix
)
sys
.
argv
=
[
'
extract_noise
'
,
td
]
+
'
-o out.txt 1 2 3
'
.
split
()
extn
.
main
()
assert
np
.
all
(
np
.
loadtxt
(
'
out.txt
'
)
==
melmix
[:,
:
3
])
with
open
(
'
labels.txt
'
,
'
wt
'
)
as
f
:
f
.
write
(
'
4, 5, 6, 7
'
)
extn
.
main
([
td
]
+
'
-o out.txt -ow 1 2 3 labels.txt
'
.
split
())
assert
np
.
all
(
np
.
loadtxt
(
'
out.txt
'
)
==
melmix
[:,
:
7
])
conf1
=
np
.
random
.
randint
(
1
,
100
,
(
100
,
1
))
conf2
=
np
.
random
.
randint
(
1
,
100
,
(
100
,
5
))
np
.
savetxt
(
'
conf1.txt
'
,
conf1
)
np
.
savetxt
(
'
conf2.txt
'
,
conf2
)
exp
=
np
.
hstack
((
melmix
[:,
:
3
],
conf1
,
conf2
))
extn
.
main
([
td
]
+
'
-o out.txt -c conf1.txt -c conf2.txt -ow 1 2 3
'
.
split
())
assert
np
.
all
(
np
.
loadtxt
(
'
out.txt
'
)
==
exp
)
def
test_extract_noise_usage
():
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([])
assert
e
.
value
.
code
==
0
def
test_extract_noise_badargs
():
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([
'
non-existent.ica
'
,
'
1
'
,
'
2
'
,
'
3
'
])
assert
e
.
value
.
code
!=
0
with
tempdir
.
tempdir
()
as
td
:
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([
td
,
'
non-existent.txt
'
,
'
1
'
,
'
2
'
,
'
3
'
])
assert
e
.
value
.
code
!=
0
with
open
(
'
outfile.txt
'
,
'
wt
'
)
as
f
:
f
.
write
(
'
a
'
)
# overwrite not specified
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([
td
,
'
-o
'
,
'
outfile.txt
'
,
'
1
'
,
'
2
'
,
'
3
'
])
assert
e
.
value
.
code
!=
0
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([
td
,
'
-c
'
,
'
non-existent.txt
'
,
'
1
'
,
'
2
'
,
'
3
'
])
assert
e
.
value
.
code
!=
0
# bad data
melmix
=
np
.
random
.
randint
(
1
,
100
,
(
100
,
5
))
np
.
savetxt
(
'
melodic_mix
'
,
melmix
)
with
open
(
'
labels.txt
'
,
'
wt
'
)
as
f
:
f
.
write
(
'
-1, 0, 1, 2
'
)
with
pytest
.
raises
(
SystemExit
)
as
e
:
extn
.
main
([
td
,
'
labels.txt
'
,
'
1
'
,
'
2
'
,
'
3
'
])
assert
e
.
value
.
code
!=
0
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