Skip to content
Snippets Groups Projects
Commit 7f4202fa authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT,ENH: Rename cluster module so I can mock things within. New smoothest

wrapper function
parent 10718588
No related branches found
No related tags found
No related merge requests found
...@@ -101,7 +101,8 @@ from fsl.wrappers.wrapperutils import (LOAD, ...@@ -101,7 +101,8 @@ from fsl.wrappers.wrapperutils import (LOAD,
fslwrapper, fslwrapper,
funcwrapper) funcwrapper)
from fsl.wrappers import (tbss,) from fsl.wrappers import (tbss,)
from fsl.wrappers.cluster import (cluster,) from fsl.wrappers.cluster_commands import (cluster,
smoothest)
from fsl.wrappers.bet import (bet, from fsl.wrappers.bet import (bet,
robustfov) robustfov)
from fsl.wrappers.eddy import (eddy, from fsl.wrappers.eddy import (eddy,
......
...@@ -66,3 +66,59 @@ def _cluster(infile, thresh, **kwargs): ...@@ -66,3 +66,59 @@ def _cluster(infile, thresh, **kwargs):
cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs) cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
return cmd return cmd
def smoothest(inimg=None, **kwargs):
"""Wrapper for the ``smoothest`` command.
The residual or zstatistic image may be passed as the first positional
argument (``inimg``) - its type is inferred from the image file name if
possible. If this is not possible (e.g. non-standard file names or
in-memory images), you must specify residual images via ``res``, or
zstatistic images via ``zstat``.
Returns a dictionary containing the parameters estimated by ``smoothest``,
e.g.::
{
'DLH' : 1.25903,
'VOLUME' : 239991,
'RESELS' : 3.69574,
'FWHMvoxel' : [1.57816, 1.64219, 1.42603],
'FWHMmm' : [3.15631, 3.28437, 2.85206]
}
"""
result = _smoothest(**kwargs)
result = result.stdout[0]
result = result.strip().split('\n')[-5:]
values = {}
for line in result:
key, vals = line.split(maxsplit=1)
vals = [float(v) for v in vals.split()]
if len(vals) == 1:
vals = vals[0]
values[key] = vals
return values
@wutils.fileOrImage('inimg', 'r', 'res', 'z', 'zstat', 'm', 'mask')
@wutils.fslwrapper
def _smoothest(inimg=None, **kwargs):
"""Actual wrapper for the ``smoothest`` command."""
if inimg is not None:
if 'res4d' in inimg: kwargs['res'] = inimg
elif 'zstat' in inimg: kwargs['zstat'] = inimg
else: raise RuntimeError('Cannot infer type of input '
f'image {inimg.name}')
valmap = {
'V' : wutils.SHOW_IF_TRUE,
'verbose' : wutils.SHOW_IF_TRUE,
}
return ['smoothest'] + wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment