Skip to content

Commit a28008c

Browse files
committed
added afni 3dUnifize to utils
1 parent c6d24b8 commit a28008c

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy,
2121
Eval, FWHMx,
2222
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
23-
ZCutUp,)
23+
Unifize, ZCutUp,)

nipype/interfaces/afni/utils.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,116 @@ class To3D(AFNICommand):
12301230
output_spec = AFNICommandOutputSpec
12311231

12321232

1233+
class UnifizeInputSpec(AFNICommandInputSpec):
1234+
in_file = File(
1235+
desc='input file to 3dUnifize',
1236+
argstr='-input %s',
1237+
position=-1,
1238+
mandatory=True,
1239+
exists=True,
1240+
copyfile=False)
1241+
out_file = File(
1242+
name_template='%s_unif',
1243+
desc='output image file name',
1244+
argstr='-prefix %s',
1245+
name_source='in_file')
1246+
t2 = traits.Bool(
1247+
desc='Treat the input as if it were T2-weighted, rather than '
1248+
'T1-weighted. This processing is done simply by inverting '
1249+
'the image contrast, processing it as if that result were '
1250+
'T1-weighted, and then re-inverting the results '
1251+
'counts of voxel overlap, i.e., each voxel will contain the '
1252+
'number of masks that it is set in.',
1253+
argstr='-T2')
1254+
gm = traits.Bool(
1255+
desc='Also scale to unifize \'gray matter\' = lower intensity voxels '
1256+
'(to aid in registering images from different scanners).',
1257+
argstr='-GM')
1258+
urad = traits.Float(
1259+
desc='Sets the radius (in voxels) of the ball used for the sneaky '
1260+
'trick. Default value is 18.3, and should be changed '
1261+
'proportionally if the dataset voxel size differs significantly '
1262+
'from 1 mm.',
1263+
argstr='-Urad %s')
1264+
ssave = File(
1265+
name_template='%s_scale',
1266+
desc='output file name to save the scale factor used at each voxel ',
1267+
argstr='-ssave %s')
1268+
no_duplo = traits.Bool(
1269+
desc='Do NOT use the \'duplo down\' step; this can be useful for '
1270+
'lower resolution datasets.',
1271+
argstr='-noduplo')
1272+
epi = traits.Bool(
1273+
desc='Assume the input dataset is a T2 (or T2*) weighted EPI time '
1274+
'series. After computing the scaling, apply it to ALL volumes '
1275+
'(TRs) in the input dataset. That is, a given voxel will be '
1276+
'scaled by the same factor at each TR. '
1277+
'This option also implies \'-noduplo\' and \'-T2\'.'
1278+
'This option turns off \'-GM\' if you turned it on.',
1279+
argstr='-EPI',
1280+
requires=['no_duplo', 't2'],
1281+
xor=['gm'])
1282+
1283+
1284+
class UnifizeOutputSpec(TraitedSpec):
1285+
out_file = File(desc='unifized file',
1286+
exists=True)
1287+
1288+
1289+
class Unifize(AFNICommand):
1290+
"""3dUnifize - for uniformizing image intensity
1291+
1292+
* The input dataset is supposed to be a T1-weighted volume,
1293+
possibly already skull-stripped (e.g., via 3dSkullStrip).
1294+
However, this program can be a useful step to take BEFORE
1295+
3dSkullStrip, since the latter program can fail if the input
1296+
volume is strongly shaded -- 3dUnifize will (mostly) remove
1297+
such shading artifacts.
1298+
1299+
* The output dataset has the white matter (WM) intensity approximately
1300+
uniformized across space, and scaled to peak at about 1000.
1301+
1302+
* The output dataset is always stored in float format!
1303+
1304+
* If the input dataset has more than 1 sub-brick, only sub-brick
1305+
#0 will be processed!
1306+
1307+
* Want to correct EPI datasets for nonuniformity?
1308+
You can try the new and experimental [Mar 2017] '-EPI' option.
1309+
1310+
* Method: Obi-Wan's personal variant of Ziad's sneaky trick.
1311+
(If you want to know what his trick is, you'll have to ask him, or
1312+
read Obi-Wan's source code [which is a world of ecstasy and exaltation],
1313+
or just read all the way to the end of this help output.)
1314+
1315+
* The principal motive for this program is for use in an image
1316+
registration script, and it may or may not be useful otherwise.
1317+
1318+
* This program replaces the older (and very different) 3dUniformize,
1319+
which is no longer maintained and may sublimate at any moment.
1320+
(In other words, we do not recommend the use of 3dUniformize.)
1321+
1322+
For complete details, see the `3dUnifize Documentation.
1323+
<https://afni.nimh.nih.gov/pub../pub/dist/doc/program_help/3dUnifize.html>`_
1324+
1325+
Examples
1326+
========
1327+
1328+
>>> from nipype.interfaces import afni
1329+
>>> unifize = afni.Unifize()
1330+
>>> unifize.inputs.in_file = 't1.nii'
1331+
>>> unifize.inputs.out_file = 't1_unifized.nii'
1332+
>>> unifize.cmdline # doctest: +ALLOW_UNICODE
1333+
'3dUnifize -prefix t1_unifized.nii -input t1.nii'
1334+
>>> res = unifize.run() # doctest: +SKIP
1335+
1336+
"""
1337+
1338+
_cmd = '3dUnifize'
1339+
input_spec = UnifizeInputSpec
1340+
output_spec = UnifizeOutputSpec
1341+
1342+
12331343
class ZCutUpInputSpec(AFNICommandInputSpec):
12341344
in_file = File(
12351345
desc='input file to 3dZcutup',

0 commit comments

Comments
 (0)