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
82083da2
Commit
82083da2
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up eddy and fugue modules. Add sean as author.
parent
eea41c8e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
fsl/wrappers/bet.py
+1
-0
1 addition, 0 deletions
fsl/wrappers/bet.py
fsl/wrappers/eddy.py
+67
-101
67 additions, 101 deletions
fsl/wrappers/eddy.py
fsl/wrappers/flirt.py
+1
-0
1 addition, 0 deletions
fsl/wrappers/flirt.py
fsl/wrappers/fugue.py
+35
-24
35 additions, 24 deletions
fsl/wrappers/fugue.py
with
104 additions
and
125 deletions
fsl/wrappers/bet.py
+
1
−
0
View file @
82083da2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#
#
# bet.py - Wrapper for the FSL bet command.
# bet.py - Wrapper for the FSL bet command.
#
#
# Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
This module provides the :func:`bet` function, a wrapper for the FSL
"""
This module provides the :func:`bet` function, a wrapper for the FSL
...
...
This diff is collapsed.
Click to expand it.
fsl/wrappers/eddy.py
+
67
−
101
View file @
82083da2
#!/usr/bin/env python
#!/usr/bin/env python
#
#
# eddy.py -
# eddy.py -
Wrappers for topup and eddy.
#
#
# Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
This module provides wrapper functions for the FSL `TOPUP
<https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup>`_ and `EDDY
<https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy>`_ tools, for field map
estimation and eddy-current distortion correction.
.. autosummary::
:nosignatures:
eddy_cuda
topup
"""
import
fsl.utils.run
as
run
import
fsl.utils.assertions
as
asrt
from
.
import
wrapperutils
as
wutils
@wutils.fileOrImage
(
'
imain
'
,
'
mask
'
,
'
field
'
)
@wutils.fileOrArray
(
'
index
'
,
'
acqp
'
,
'
bvecs
'
,
'
bvals
'
,
'
field_mat
'
)
def
eddy_cuda
(
imain
,
mask
,
index
,
acqp
,
bvecs
,
bvals
,
out
,
**
kwargs
):
"""
Wrapper for the ``eddy_cuda`` command.
"""
valmap
=
{
'
fep
'
:
wutils
.
SHOW_IF_TRUE
,
'
initrand
'
:
wutils
.
SHOW_IF_TRUE
,
'
repol
'
:
wutils
.
SHOW_IF_TRUE
,
'
ol_pos
'
:
wutils
.
SHOW_IF_TRUE
,
'
ol_sqr
'
:
wutils
.
SHOW_IF_TRUE
,
'
dont_sep_offs_move
'
:
wutils
.
SHOW_IF_TRUE
,
'
dont_peas
'
:
wutils
.
SHOW_IF_TRUE
,
'
data_is_shelled
'
:
wutils
.
SHOW_IF_TRUE
,
'
b0_only
'
:
wutils
.
SHOW_IF_TRUE
,
'
dont_mask_output
'
:
wutils
.
SHOW_IF_TRUE
,
'
cnr_maps
'
:
wutils
.
SHOW_IF_TRUE
,
'
residuals
'
:
wutils
.
SHOW_IF_TRUE
,
'
estimate_move_by_susceptibility
'
:
wutils
.
SHOW_IF_TRUE
,
'
verbose
'
:
wutils
.
SHOW_IF_TRUE
,
'
very_verbose
'
:
wutils
.
SHOW_IF_TRUE
,
}
def
eddy_cuda
(
imain
,
mask
,
index
,
acqp
,
bvecs
,
bvals
,
out
,
very_verbose
=
False
,
niter
=
None
,
fwhm
=
None
,
s2v_niter
=
None
,
mporder
=
None
,
nvoxhp
=
None
,
slspec
=
None
,
b0_only
=
False
,
topup
=
None
,
field
=
None
,
field_mat
=
None
,
debug
=
None
,
s2v_fwhm
=
None
,
interp
=
None
,
dont_mask_output
=
False
,
s2v_interp
=
None
,
ref_scan_no
=
None
,
data_is_shelled
=
False
,
estimate_move_by_susceptibility
=
False
,
mbs_niter
=
None
,
mbs_lambda
=
None
,
mbs_ksp
=
None
,
s2v_lambda
=
None
,
cnr_maps
=
False
,
residuals
=
False
):
"""
Correct eddy current-induced distortions and subject movements.
"""
asrt
.
assertFileExists
(
imain
,
mask
,
index
,
acqp
,
bvecs
,
bvals
)
asrt
.
assertFileExists
(
imain
,
mask
,
index
,
acqp
,
bvecs
,
bvals
)
asrt
.
assertIsNifti
(
imain
,
mask
)
asrt
.
assertIsNifti
(
imain
,
mask
)
assert
not
(
topup
and
field
),
"
topup and field arguments are incompatible
"
kwargs
.
update
({
'
imain
'
:
imain
,
'
mask
'
:
mask
,
out
=
img
.
splitext
(
out
)[
0
]
'
index
'
:
index
,
'
acqp
'
:
acqp
,
opts
=
"
--imain={0} --mask={1} --index={2} --bvals={3}
"
\
'
bvecs
'
:
bvecs
,
"
--bvecs={4} --acqp={5} --out={6}
"
.
format
(
imain
,
mask
,
index
,
bvals
,
'
bvals
'
:
bvals
,
bvecs
,
acqp
,
out
)
'
out
'
:
out
})
cmd
=
op
.
join
(
os
.
getenv
(
'
DHCP_EDDY_PATH
'
,
''
),
'
eddy_cuda
'
)
cmd
=
[
'
eddy_cuda
'
]
+
wutils
.
applyArgStyle
(
'
--=
'
,
valmap
=
valmap
,
**
kwargs
)
# cmd = 'eddy_cuda'
return
run
.
runfsl
(
cmd
)
cmd
=
cmd
+
opts
if
very_verbose
:
@wutils.fileOrImage
(
'
imain
'
,
'
fout
'
,
'
iout
'
)
cmd
+=
"
--very_verbose
"
@wutils.fileOrArray
(
'
datain
'
)
if
estimate_move_by_susceptibility
:
def
topup
(
imain
,
datain
,
**
kwargs
):
cmd
+=
"
--estimate_move_by_susceptibility
"
"""
Wrapper for the ``topup`` command.
"""
if
data_is_shelled
:
cmd
+=
"
--data_is_shelled
"
valmap
=
{
if
mbs_niter
is
not
None
:
'
verbose
'
:
wutils
.
SHOW_IF_TRUE
cmd
+=
"
--mbs_niter={0}
"
.
format
(
mbs_niter
)
}
if
mbs_lambda
is
not
None
:
cmd
+=
"
--mbs_lambda={0}
"
.
format
(
mbs_lambda
)
asrt
.
assertFileExists
(
datain
)
if
mbs_ksp
is
not
None
:
cmd
+=
"
--mbs_ksp={0}
"
.
format
(
mbs_ksp
)
if
niter
is
not
None
:
cmd
+=
"
--niter={0}
"
.
format
(
niter
)
if
fwhm
is
not
None
:
cmd
+=
"
--fwhm={0}
"
.
format
(
fwhm
)
if
s2v_fwhm
is
not
None
:
cmd
+=
"
--s2v_fwhm={0}
"
.
format
(
s2v_fwhm
)
if
s2v_niter
is
not
None
:
cmd
+=
"
--s2v_niter={0}
"
.
format
(
s2v_niter
)
if
s2v_interp
is
not
None
:
cmd
+=
"
--s2v_interp={0}
"
.
format
(
s2v_interp
)
if
interp
is
not
None
:
cmd
+=
"
--interp={0}
"
.
format
(
interp
)
if
mporder
is
not
None
:
cmd
+=
"
--mporder={0}
"
.
format
(
mporder
)
if
nvoxhp
is
not
None
:
cmd
+=
"
--nvoxhp={0}
"
.
format
(
nvoxhp
)
if
slspec
is
not
None
:
cmd
+=
"
--slspec={0}
"
.
format
(
slspec
)
if
topup
is
not
None
:
cmd
+=
"
--topup={0}
"
.
format
(
topup
)
if
field
is
not
None
:
field
=
img
.
splitext
(
field
)[
0
]
cmd
+=
"
--field={0}
"
.
format
(
field
)
if
b0_only
:
cmd
+=
"
--b0_only
"
if
field_mat
is
not
None
:
cmd
+=
"
--field_mat={0}
"
.
format
(
field_mat
)
if
debug
is
not
None
:
cmd
+=
"
--debug={0}
"
.
format
(
debug
)
if
dont_mask_output
:
cmd
+=
"
--dont_mask_output
"
if
ref_scan_no
is
not
None
:
cmd
+=
"
--ref_scan_no={0}
"
.
format
(
ref_scan_no
)
if
s2v_lambda
is
not
None
:
cmd
+=
"
--s2v_lambda={0}
"
.
format
(
s2v_lambda
)
if
cnr_maps
:
cmd
+=
"
--cnr_maps
"
if
residuals
:
cmd
+=
"
--residuals
"
shops
.
run
(
cmd
)
def
topup
(
imain
,
datain
,
config
=
None
,
fout
=
None
,
iout
=
None
,
out
=
None
,
verbose
=
False
,
subsamp
=
None
,
logout
=
None
):
"""
Estimate and correct susceptibility induced distortions.
"""
asrt
.
assertFileExists
(
imain
,
datain
)
asrt
.
assertIsNifti
(
imain
)
asrt
.
assertIsNifti
(
imain
)
cmd
=
"
topup --imain={0} --datain={1}
"
.
format
(
imain
,
datain
)
cmd
=
[
'
topup
'
,
'
--imain={}
'
.
format
(
imain
),
'
--datain={}
'
.
format
(
datain
)]
cmd
+=
wutils
.
applyArgStyle
(
'
--=
'
,
valmap
=
valmap
,
**
kwargs
)
if
config
is
not
None
:
cmd
+=
"
--config={0}
"
.
format
(
config
)
return
run
.
runfsl
(
cmd
)
if
fout
is
not
None
:
cmd
+=
"
--fout={0}
"
.
format
(
fout
)
if
iout
is
not
None
:
cmd
+=
"
--iout={0}
"
.
format
(
iout
)
if
out
is
not
None
:
cmd
+=
"
--out={0}
"
.
format
(
out
)
if
subsamp
is
not
None
:
cmd
+=
"
--subsamp={0}
"
.
format
(
subsamp
)
if
logout
is
not
None
:
cmd
+=
"
--logout={0}
"
.
format
(
logout
)
if
verbose
:
cmd
+=
"
-v
"
shops
.
run
(
cmd
)
This diff is collapsed.
Click to expand it.
fsl/wrappers/flirt.py
+
1
−
0
View file @
82083da2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#
#
# flirt.py - Wrappers for FLIRT commands.
# flirt.py - Wrappers for FLIRT commands.
#
#
# Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
This module provides wrapper functions for the FSL `FLIRT
"""
This module provides wrapper functions for the FSL `FLIRT
...
...
This diff is collapsed.
Click to expand it.
fsl/wrappers/fugue.py
+
35
−
24
View file @
82083da2
#!/usr/bin/env python
#!/usr/bin/env python
#
#
# fugue.py -
# fugue.py -
Wrappers for fugue/field map tools.
#
#
# Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
#
"""
"""
This module contains wrappers for the FSL `FUGUE
<https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FUGUE>`_ tools, for EPI field map
processing and distortion correction.
"""
"""
import
fsl.utils.run
as
run
import
fsl.utils.run
as
run
from
.
import
wrapperutils
as
wutils
@wutils.fileOrImage
(
'
in
'
,
'
unwarp
'
,
'
warp
'
,
'
phasemap
'
,
'
savefmap
'
,
'
loadfmap
'
,
'
saveshift
'
,
'
loadshift
'
,
'
mask
'
)
def
fugue
(
**
kwargs
):
def
fugue
(
**
kwargs
):
"""
FMRIB
'
s Utility for Geometric Unwarping of EPIs.
"""
"""
Wrapper for the ``fugue`` command.
"""
cmd
=
"
fugue
"
valmap
=
{
'
dwelltoasym
'
:
wutils
.
SHOW_IF_TRUE
,
if
kwargs
.
pop
(
'
unmaskshift
'
,
False
):
'
median
'
:
wutils
.
SHOW_IF_TRUE
,
cmd
+=
"
--unmaskshift
"
'
despike
'
:
wutils
.
SHOW_IF_TRUE
,
if
kwargs
.
pop
(
'
despike
'
,
False
):
'
nofill
'
:
wutils
.
SHOW_IF_TRUE
,
cmd
+=
"
--despike
"
'
noextend
'
:
wutils
.
SHOW_IF_TRUE
,
if
kwargs
.
pop
(
'
unmaskfmap
'
,
False
):
'
pava
'
:
wutils
.
SHOW_IF_TRUE
,
cmd
+=
"
--unmaskfmap
"
'
phaseconj
'
:
wutils
.
SHOW_IF_TRUE
,
'
icorr
'
:
wutils
.
SHOW_IF_TRUE
,
cmd
+=
'
'
.
join
([
'
--{}={}
'
.
format
(
k
,
v
)
for
k
,
v
in
kwargs
.
items
()])
'
icorronly
'
:
wutils
.
SHOW_IF_TRUE
,
'
unmaskfmap
'
:
wutils
.
SHOW_IF_TRUE
,
'
unmaskshift
'
:
wutils
.
SHOW_IF_TRUE
,
'
nokspace
'
:
wutils
.
SHOW_IF_TRUE
,
'
nocheck
'
:
wutils
.
SHOW_IF_TRUE
,
'
verbose
'
:
wutils
.
SHOW_IF_TRUE
,
}
cmd
=
[
'
fugue
'
]
+
wutils
.
applyArgStyle
(
'
--=
'
,
valmap
=
valmap
,
**
kwargs
)
return
run
.
runfsl
(
cmd
)
return
run
.
runfsl
(
cmd
)
def
sigloss
(
input
,
output
,
te
=
None
,
slicedir
=
None
,
mask
=
None
):
def
sigloss
(
input
,
sigloss
,
**
kwargs
):
"""
Estimate signal loss from a field map (in rad/s).
"""
"""
Wrapper for the ``sigloss`` command.
"""
cmd
=
"
sigloss -i {0} -s {1}
"
.
format
(
input
,
output
)
valmap
=
{
'
verbose
'
:
wutils
.
SHOW_IF_TRUE
}
if
te
is
not
None
:
cmd
=
[
'
sigloss
'
,
'
--in
'
,
input
,
'
--sigloss
'
,
sigloss
]
cmd
+=
"
--te={0}
"
.
format
(
te
)
cmd
+=
wutils
.
applyArgStyle
(
'
--
'
,
valmap
=
valmap
,
**
kwargs
)
if
slicedir
is
not
None
:
cmd
+=
"
--slicedir={0}
"
.
format
(
slicedir
)
if
mask
is
not
None
:
cmd
+=
"
--mask={0}
"
.
format
(
mask
)
return
run
.
runfsl
(
cmd
)
return
run
.
runfsl
(
cmd
)
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