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
FSL
fslpy
Commits
160e2226
Commit
160e2226
authored
Mar 29, 2019
by
Paul McCarthy
🚵
Browse files
Merge branch 'mnt/v2.0' into 'v2.0'
Mnt/v2.0 See merge request fsl/fslpy!110
parents
eab4ee98
68cb0e0a
Pipeline
#3511
passed with stages
in 2 minutes and 17 seconds
Changes
8
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
COPYRIGHT
View file @
160e2226
Copyright 2016-201
8
University of Oxford, Oxford, UK
Copyright 2016-201
9
University of Oxford, Oxford, UK
LICENSE
View file @
160e2226
The fslpy library
Copyright 2016-201
7
University of Oxford, Oxford, UK.
Copyright 2016-201
9
University of Oxford, Oxford, UK.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
...
...
MANIFEST.in
View file @
160e2226
include AUTHOR
include LICENSE
include COPYRIGHT
include CHANGELOG.rst
include README.rst
include requirements.txt
include requirements-dev.txt
include requirements-extra.txt
include
pytest.ini
include
setup.cfg
recursive-include doc *
recursive-exclude doc/html *
recursive-include tests *
README.rst
View file @
160e2226
...
...
@@ -59,13 +59,14 @@ Some extra dependencies are listed in `requirements.txt
If you are using Linux, you need to install wxPython first, as binaries are
not available on PyPI. Change the URL for your specific platform::
not available on PyPI. Install wxPython like so, changing the URL for your
specific platform::
pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk2/ubuntu-16.04/ wxpython
Once wxPython has been installed, you can
simply
type the following to install
the
rest of the extra dependencies::
Once wxPython has been installed, you can type the following to install
the
rest of the extra dependencies::
pip install fslpy[extras]
...
...
fsl/utils/filetree/filetree.py
View file @
160e2226
...
...
@@ -185,7 +185,7 @@ class FileTree(object):
"""
return
tuple
(
self
.
extract_variables
(
short_name
,
fn
)
for
fn
in
self
.
get_all
(
short_name
,
glob_vars
=
glob_vars
))
def
get_all_trees
(
self
,
short_name
:
str
,
glob_vars
=
())
->
Tuple
[
"FileTree"
]:
def
get_all_trees
(
self
,
short_name
:
str
,
glob_vars
=
()
,
set_parent
=
True
)
->
Tuple
[
"FileTree"
]:
"""
Gets all the trees that generate the existing files matching the pattern
...
...
@@ -195,23 +195,31 @@ class FileTree(object):
:param glob_vars: sequence of undefined variables that can take any possible values when looking for matches on the disk.
Any defined variables in `glob_vars` will be ignored.
If glob_vars is set to 'all', all undefined variables will be used to look up matches.
:param set_parent: Update the variables of the top-level rather than current tree if True.
Ony relevant if `self` is a sub-tree.
:return: sequence of FileTrees used to generate each file on disk matching the pattern of `short_name`
"""
return
tuple
(
self
.
update
(
**
vars
)
for
vars
in
self
.
get_all_vars
(
short_name
,
glob_vars
=
glob_vars
))
return
tuple
(
self
.
update
(
set_parent
=
set_parent
,
**
vars
)
for
vars
in
self
.
get_all_vars
(
short_name
,
glob_vars
=
glob_vars
))
def
update
(
self
,
**
variables
)
->
"FileTree"
:
def
update
(
self
,
set_parent
=
True
,
**
variables
)
->
"FileTree"
:
"""
Creates a new FileTree with updated variables
:param set_parent: Update the variables of the top-level rather than current tree if True.
Ony relevant if `self` is a sub-tree.
:param variables: new values for the variables
Setting a variable to None will cause the variable to be unset
:return: New FileTree with same templates for directory names and filenames, but updated variables
"""
new_tree
=
deepcopy
(
self
)
new_tree
.
variables
.
update
(
variables
)
set_tree
=
new_tree
while
set_parent
and
set_tree
.
parent
is
not
None
:
set_tree
=
set_tree
.
parent
set_tree
.
variables
.
update
(
variables
)
for
key
,
value
in
variables
.
items
():
if
value
is
None
:
del
new
_tree
.
variables
[
key
]
del
set
_tree
.
variables
[
key
]
return
new_tree
def
extract_variables
(
self
,
short_name
:
str
,
filename
:
str
)
->
Dict
[
str
,
str
]:
...
...
fsl/version.py
View file @
160e2226
...
...
@@ -47,7 +47,7 @@ import re
import
string
__version__
=
'2.0.0
.dev0
'
__version__
=
'2.0.0'
"""Current version number, as a string. """
...
...
tests/test_filetree/test_read.py
View file @
160e2226
...
...
@@ -58,6 +58,17 @@ def test_parent_tree():
with
pytest
.
raises
(
KeyError
):
tree
.
get
(
'sub_var/basename'
)
# test updating in parent tree
sub0_tree
=
tree
.
sub_trees
[
'sub0'
]
same_path
(
sub0_tree
.
update
(
subvar
=
'test'
).
get
(
'../subvar/basename'
),
'subvar_test'
)
with
pytest
.
raises
(
KeyError
):
sub0_tree
.
update
(
subvar
=
'test'
,
set_parent
=
False
).
get
(
'../subvar/basename'
)
sub0_tree
=
tree
.
update
(
subvar
=
'grot'
).
sub_trees
[
'sub0'
]
same_path
(
sub0_tree
.
update
(
subvar
=
'test'
).
get
(
'../subvar/basename'
),
'subvar_test'
)
same_path
(
sub0_tree
.
update
(
subvar
=
'test'
,
set_parent
=
False
).
get
(
'../subvar/basename'
),
'subvar_grot'
)
same_path
(
sub0_tree
.
get
(
'../subvar/basename'
),
'subvar_grot'
)
def
test_custom_tree
():
directory
=
op
.
split
(
__file__
)[
0
]
...
...
tests/test_wrappers.py
View file @
160e2226
...
...
@@ -288,3 +288,18 @@ def test_fast():
expected
=
[
cmd
,
'-v'
,
'--out=myseg'
,
'--class=3'
,
'in1'
,
'in2'
,
'in3'
]
assert
result
.
output
[
0
]
==
' '
.
join
(
expected
)
def
test_fsl_anat
():
with
asrt
.
disabled
(),
\
run
.
dryrun
(),
\
mockFSLDIR
(
bin
=
(
'fsl_anat'
,))
as
fsldir
:
cmd
=
op
.
join
(
fsldir
,
'bin'
,
'fsl_anat'
)
result
=
fw
.
fsl_anat
(
't1'
,
out
=
'fsl_anat'
,
bias_smoothing
=
25
)
expected
=
[
cmd
,
'-i'
,
't1'
,
'-o'
,
'fsl_anat'
,
'-t'
,
'T1'
,
'-s'
,
'25'
]
assert
result
.
output
[
0
]
==
' '
.
join
(
expected
)
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