Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
346147da
Commit
346147da
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: make option dicts class attributes
parent
2583c861
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
fsl/wrappers/fslstats.py
+52
-52
52 additions, 52 deletions
fsl/wrappers/fslstats.py
with
52 additions
and
52 deletions
fsl/wrappers/fslstats.py
+
52
−
52
View file @
346147da
...
@@ -20,53 +20,6 @@ import fsl.data.image as fslimage
...
@@ -20,53 +20,6 @@ import fsl.data.image as fslimage
from
.
import
wrapperutils
as
wutils
from
.
import
wrapperutils
as
wutils
OPTIONS
=
{
'
robust_minmax
'
:
'
r
'
,
'
minmax
'
:
'
R
'
,
'
mean_entropy
'
:
'
e
'
,
'
mean_entropy_nz
'
:
'
E
'
,
'
volume
'
:
'
v
'
,
'
volume_nz
'
:
'
V
'
,
'
mean
'
:
'
m
'
,
'
mean_nz
'
:
'
M
'
,
'
stddev
'
:
'
s
'
,
'
stddev_nz
'
:
'
S
'
,
'
smallest_roi
'
:
'
w
'
,
'
max_vox
'
:
'
x
'
,
'
min_vox
'
:
'
X
'
,
'
cog_mm
'
:
'
c
'
,
'
cog_vox
'
:
'
C
'
,
'
abs
'
:
'
a
'
,
'
zero_naninf
'
:
'
n
'
,
}
"""
This dict contains options which do not require any additional arguments.
They are set via attribute access on the ``fslstats`` object.
"""
ARG_OPTIONS
=
{
'
lower_threshold
'
:
'
l
'
,
'
upper_threshold
'
:
'
u
'
,
'
percentile
'
:
'
p
'
,
'
percentile_nz
'
:
'
P
'
,
'
mask
'
:
'
k
'
,
'
diff
'
:
'
d
'
,
'
hist
'
:
'
h
'
,
'
hist_bounded
'
:
'
H
'
,
}
"""
This dict contains options which require additional arguments.
They are set via method calls on the ``fslstats`` object (with the
additional arguments passed into the method call).
"""
# add {shortopt : shortopt} mappings
# for all options to simplify code in
# the fslstats class
OPTIONS
.
update
({
v
:
v
for
v
in
OPTIONS
.
values
()})
ARG_OPTIONS
.
update
({
v
:
v
for
v
in
ARG_OPTIONS
.
values
()})
class
fslstats
(
object
):
class
fslstats
(
object
):
"""
The ``fslstats`` class is a wrapper around the ``fslstats`` command-line
"""
The ``fslstats`` class is a wrapper around the ``fslstats`` command-line
tool. It provides an object-oriented interface - options are specified by
tool. It provides an object-oriented interface - options are specified by
...
@@ -106,6 +59,53 @@ class fslstats(object):
...
@@ -106,6 +59,53 @@ class fslstats(object):
imgmin, imgmax = fslstats(
'
image.nii.gz
'
).k(
'
mask.nii.gz
'
).r.run()
imgmin, imgmax = fslstats(
'
image.nii.gz
'
).k(
'
mask.nii.gz
'
).r.run()
"""
"""
OPTIONS
=
{
'
robust_minmax
'
:
'
r
'
,
'
minmax
'
:
'
R
'
,
'
mean_entropy
'
:
'
e
'
,
'
mean_entropy_nz
'
:
'
E
'
,
'
volume
'
:
'
v
'
,
'
volume_nz
'
:
'
V
'
,
'
mean
'
:
'
m
'
,
'
mean_nz
'
:
'
M
'
,
'
stddev
'
:
'
s
'
,
'
stddev_nz
'
:
'
S
'
,
'
smallest_roi
'
:
'
w
'
,
'
max_vox
'
:
'
x
'
,
'
min_vox
'
:
'
X
'
,
'
cog_mm
'
:
'
c
'
,
'
cog_vox
'
:
'
C
'
,
'
abs
'
:
'
a
'
,
'
zero_naninf
'
:
'
n
'
,
}
"""
This dict contains options which do not require any additional
arguments. They are set via attribute access on the ``fslstats``
object.
"""
ARG_OPTIONS
=
{
'
lower_threshold
'
:
'
l
'
,
'
upper_threshold
'
:
'
u
'
,
'
percentile
'
:
'
p
'
,
'
percentile_nz
'
:
'
P
'
,
'
mask
'
:
'
k
'
,
'
diff
'
:
'
d
'
,
'
hist
'
:
'
h
'
,
'
hist_bounded
'
:
'
H
'
,
}
"""
This dict contains options which require additional arguments.
They are set via method calls on the ``fslstats`` object (with the
additional arguments passed into the method call).
"""
# add {shortopt : shortopt} mappings
# for all options to simplify code in
# the fslstats class
OPTIONS
.
update
({
v
:
v
for
v
in
OPTIONS
.
values
()})
ARG_OPTIONS
.
update
({
v
:
v
for
v
in
ARG_OPTIONS
.
values
()})
def
__init__
(
self
,
def
__init__
(
self
,
input
,
input
,
...
@@ -168,17 +168,17 @@ class fslstats(object):
...
@@ -168,17 +168,17 @@ class fslstats(object):
# options which take no args
# options which take no args
# are called as attributes
# are called as attributes
if
name
in
OPTIONS
:
if
name
in
fslstats
.
OPTIONS
:
flag
=
OPTIONS
[
name
]
flag
=
fslstats
.
OPTIONS
[
name
]
args
=
False
args
=
False
# options which take args
# options which take args
# are called as methods
# are called as methods
elif
name
in
ARG_OPTIONS
:
elif
name
in
fslstats
.
ARG_OPTIONS
:
flag
=
ARG_OPTIONS
[
name
]
flag
=
fslstats
.
ARG_OPTIONS
[
name
]
args
=
True
args
=
True
else
:
else
:
raise
AttributeError
()
raise
AttributeError
(
name
)
addFlag
=
ft
.
partial
(
self
.
__addFlag
,
flag
)
addFlag
=
ft
.
partial
(
self
.
__addFlag
,
flag
)
...
...
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