From 889492b7ffb4b1165598e107aaf984fa458adc45 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Wed, 12 Oct 2016 17:11:34 -0400 Subject: [PATCH 1/4] Fix docstring links. Also standardize docstrings. Remove a couple of unused imports. Many cmdline doctests are still missing. --- nipype/interfaces/afni/preprocess.py | 115 +++++++++++++++------------ nipype/interfaces/afni/svm.py | 4 +- nipype/interfaces/afni/utils.py | 54 +++++++------ 3 files changed, 92 insertions(+), 81 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 59f80dd6cb..e27757384e 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -10,16 +10,14 @@ >>> os.chdir(datadir) """ from __future__ import print_function, division, unicode_literals, absolute_import -from builtins import open, str, bytes +from builtins import open import os import os.path as op -import re -import numpy as np from ...utils.filemanip import (load_json, save_json, split_filename) from ..base import ( - CommandLineInputSpec, CommandLine, Directory, TraitedSpec, + CommandLineInputSpec, CommandLine, TraitedSpec, traits, isdefined, File, InputMultiPath, Undefined, Str) from .base import ( @@ -260,7 +258,7 @@ class Allineate(AFNICommand): """Program to align one dataset (the 'source') to a base dataset For complete details, see the `3dAllineate Documentation. - `_ + `_ Examples ======== @@ -340,6 +338,9 @@ class AutoTcorrelate(AFNICommand): """Computes the correlation coefficient between the time series of each pair of voxels in the input dataset, and stores the output into a new anatomical bucket dataset [scaled to shorts to save memory space]. + + For complete details, see the `3dAutoTcorrelate Documentation. + `_ Examples ======== @@ -409,7 +410,7 @@ class Automask(AFNICommand): """Create a brain-only mask of the image using AFNI 3dAutomask command For complete details, see the `3dAutomask Documentation. - `_ + `_ Examples ======== @@ -517,7 +518,7 @@ class Bandpass(AFNICommand): dataset, offering more/different options than Fourier For complete details, see the `3dBandpass Documentation. - `_ + `_ Examples ======== @@ -581,10 +582,10 @@ class BlurInMaskInputSpec(AFNICommandInputSpec): class BlurInMask(AFNICommand): - """ Blurs a dataset spatially inside a mask. That's all. Experimental. + """Blurs a dataset spatially inside a mask. That's all. Experimental. For complete details, see the `3dBlurInMask Documentation. - + `_ Examples ======== @@ -635,7 +636,7 @@ class BlurToFWHM(AFNICommand): """Blurs a 'master' dataset until it reaches a specified FWHM smoothness (approximately). - For complete details, see the `to3d Documentation + For complete details, see the `3dBlurToFWHM Documentation `_ Examples @@ -765,7 +766,7 @@ class DegreeCentrality(AFNICommand): via 3dDegreeCentrality For complete details, see the `3dDegreeCentrality Documentation. - + `_ Examples ======== @@ -779,6 +780,7 @@ class DegreeCentrality(AFNICommand): >>> degree.cmdline # doctest: +IGNORE_UNICODE '3dDegreeCentrality -mask mask.nii -prefix out.nii -sparsity 1.000000 functional.nii' >>> res = degree.run() # doctest: +SKIP + """ _cmd = '3dDegreeCentrality' @@ -817,7 +819,7 @@ class Despike(AFNICommand): """Removes 'spikes' from the 3D+time input dataset For complete details, see the `3dDespike Documentation. - `_ + `_ Examples ======== @@ -856,7 +858,7 @@ class Detrend(AFNICommand): linear least squares For complete details, see the `3dDetrend Documentation. - `_ + `_ Examples ======== @@ -927,7 +929,7 @@ class ECM(AFNICommand): via the 3dECM command For complete details, see the `3dECM Documentation. - + `_ Examples ======== @@ -941,6 +943,7 @@ class ECM(AFNICommand): >>> ecm.cmdline # doctest: +IGNORE_UNICODE '3dECM -mask mask.nii -prefix out.nii -sparsity 0.100000 functional.nii' >>> res = ecm.run() # doctest: +SKIP + """ _cmd = '3dECM' @@ -978,12 +981,11 @@ class FimInputSpec(AFNICommandInputSpec): class Fim(AFNICommand): - """Program to calculate the cross-correlation of - an ideal reference waveform with the measured FMRI - time series for each voxel + """Program to calculate the cross-correlation of an ideal reference + waveform with the measured FMRI time series for each voxel. For complete details, see the `3dfim+ Documentation. - `_ + `_ Examples ======== @@ -1034,7 +1036,7 @@ class Fourier(AFNICommand): dataset, via the FFT For complete details, see the `3dFourier Documentation. - `_ + `_ Examples ======== @@ -1108,7 +1110,7 @@ class Hist(AFNICommandBase): which satisfy the criterion in the options list For complete details, see the `3dHist Documentation. - `_ + `_ Examples ======== @@ -1169,7 +1171,7 @@ class LFCD(AFNICommand): via the 3dLFCD command For complete details, see the `3dLFCD Documentation. - + `_ Examples ======== @@ -1221,7 +1223,7 @@ class Maskave(AFNICommand): which satisfy the criterion in the options list For complete details, see the `3dmaskave Documentation. - `_ + `_ Examples ======== @@ -1288,7 +1290,8 @@ class MeansInputSpec(AFNICommandInputSpec): class Means(AFNICommand): """Takes the voxel-by-voxel mean of all input datasets using 3dMean - see AFNI Documentation: + For complete details, see the `3dMean Documentation. + `_ Examples ======== @@ -1300,6 +1303,7 @@ class Means(AFNICommand): >>> means.inputs.out_file = 'output.nii' >>> means.cmdline # doctest: +IGNORE_UNICODE '3dMean im1.nii im2.nii -prefix output.nii' + >>> res = means.run() # doctest: +SKIP """ @@ -1404,9 +1408,9 @@ class OutlierCount(CommandLine): >>> from nipype.interfaces import afni >>> toutcount = afni.OutlierCount() >>> toutcount.inputs.in_file = 'functional.nii' - >>> toutcount.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> toutcount.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dToutcount functional.nii > functional_outliers' - >>> res = toutcount.run() #doctest: +SKIP + >>> res = toutcount.run() # doctest: +SKIP """ @@ -1503,9 +1507,9 @@ class QualityIndex(CommandLine): >>> from nipype.interfaces import afni >>> tqual = afni.QualityIndex() >>> tqual.inputs.in_file = 'functional.nii' - >>> tqual.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> tqual.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dTqual functional.nii > functional_tqual' - >>> res = tqual.run() #doctest: +SKIP + >>> res = tqual.run() # doctest: +SKIP """ _cmd = '3dTqual' @@ -1553,7 +1557,7 @@ class ROIStats(AFNICommandBase): """Display statistics over masked regions For complete details, see the `3dROIstats Documentation. - `_ + `_ Examples ======== @@ -1563,7 +1567,7 @@ class ROIStats(AFNICommandBase): >>> roistats.inputs.in_file = 'functional.nii' >>> roistats.inputs.mask = 'skeleton_mask.nii.gz' >>> roistats.inputs.quiet=True - >>> res = roistats.run() # doctest: +SKIP + >>> res = roistats.run() # doctest: +SKIP """ _cmd = '3dROIstats' @@ -1645,7 +1649,7 @@ class Retroicor(AFNICommand): motion correction). For complete details, see the `3dretroicor Documentation. - `_ + `_ Examples ======== @@ -1657,7 +1661,8 @@ class Retroicor(AFNICommand): >>> ret.inputs.outputtype = 'NIFTI' >>> ret.cmdline # doctest: +IGNORE_UNICODE '3dretroicor -prefix functional_retroicor.nii -resp resp.1D -card mask.1D functional.nii' - >>> res = ret.run() # doctest: +SKIP + >>> res = ret.run() # doctest: +SKIP + """ _cmd = '3dretroicor' @@ -1728,7 +1733,7 @@ class Seg(AFNICommandBase): moment, only mixing fractions and MRF are documented. For complete details, see the `3dSeg Documentation. - + `_ Examples ======== @@ -1737,7 +1742,7 @@ class Seg(AFNICommandBase): >>> seg = preprocess.Seg() >>> seg.inputs.in_file = 'structural.nii' >>> seg.inputs.mask = 'AUTO' - >>> res = seg.run() # doctest: +SKIP + >>> res = seg.run() # doctest: +SKIP """ @@ -1781,7 +1786,7 @@ class SkullStrip(AFNICommand): tissue from MRI T1-weighted images For complete details, see the `3dSkullStrip Documentation. - `_ + `_ Examples ======== @@ -1790,7 +1795,7 @@ class SkullStrip(AFNICommand): >>> skullstrip = afni.SkullStrip() >>> skullstrip.inputs.in_file = 'functional.nii' >>> skullstrip.inputs.args = '-o_ply' - >>> res = skullstrip.run() # doctest: +SKIP + >>> res = skullstrip.run() # doctest: +SKIP """ _cmd = '3dSkullStrip' @@ -1858,8 +1863,9 @@ class TCorr1DOutputSpec(TraitedSpec): class TCorr1D(AFNICommand): """Computes the correlation coefficient between each voxel time series in the input 3D+time dataset. + For complete details, see the `3dTcorr1D Documentation. - `_ + `_ >>> from nipype.interfaces import afni as afni >>> tcorr1D = afni.TCorr1D() @@ -1867,7 +1873,8 @@ class TCorr1D(AFNICommand): >>> tcorr1D.inputs.y_1d = 'seed.1D' >>> tcorr1D.cmdline # doctest: +IGNORE_UNICODE '3dTcorr1D -prefix u_rc1s1_Template_correlation.nii.gz u_rc1s1_Template.nii seed.1D' - >>> res = tcorr1D.run() # doctest: +SKIP + >>> res = tcorr1D.run() # doctest: +SKIP + """ _cmd = '3dTcorr1D' @@ -1991,12 +1998,12 @@ class TCorrMapOutputSpec(TraitedSpec): class TCorrMap(AFNICommand): - """ For each voxel time series, computes the correlation between it + """For each voxel time series, computes the correlation between it and all other voxels, and combines this set of values into the output dataset(s) in some way. For complete details, see the `3dTcorrMap Documentation. - + `_ Examples ======== @@ -2006,7 +2013,7 @@ class TCorrMap(AFNICommand): >>> tcm.inputs.in_file = 'functional.nii' >>> tcm.inputs.mask = 'mask.nii' >>> tcm.mean_file = '%s_meancorr.nii' - >>> res = tcm.run() # doctest: +SKIP + >>> res = tcm.run() # doctest: +SKIP """ @@ -2062,7 +2069,7 @@ class TCorrelate(AFNICommand): time series in two input 3D+time datasets 'xset' and 'yset' For complete details, see the `3dTcorrelate Documentation. - `_ + `_ Examples ======== @@ -2074,7 +2081,7 @@ class TCorrelate(AFNICommand): >>> tcorrelate.inputs.out_file = 'functional_tcorrelate.nii.gz' >>> tcorrelate.inputs.polort = -1 >>> tcorrelate.inputs.pearson = True - >>> res = tcarrelate.run() # doctest: +SKIP + >>> res = tcarrelate.run() # doctest: +SKIP """ @@ -2129,12 +2136,11 @@ class TShiftInputSpec(AFNICommandInputSpec): class TShift(AFNICommand): - """Shifts voxel time series from input - so that seperate slices are aligned to the same - temporal origin + """Shifts voxel time series from input so that seperate slices are aligned + to the same temporal origin. For complete details, see the `3dTshift Documentation. - + `_ Examples ======== @@ -2144,9 +2150,10 @@ class TShift(AFNICommand): >>> tshift.inputs.in_file = 'functional.nii' >>> tshift.inputs.tpattern = 'alt+z' >>> tshift.inputs.tzero = 0.0 - >>> tshift.cmdline #doctest: +IGNORE_UNICODE + >>> tshift.cmdline # doctest: +IGNORE_UNICODE '3dTshift -prefix functional_tshift -tpattern alt+z -tzero 0.0 functional.nii' - >>> res = tshift.run() # doctest: +SKIP + >>> res = tshift.run() # doctest: +SKIP + """ _cmd = '3dTshift' @@ -2225,7 +2232,7 @@ class Volreg(AFNICommand): """Register input volumes to a base volume using AFNI 3dvolreg command For complete details, see the `3dvolreg Documentation. - `_ + `_ Examples ======== @@ -2236,9 +2243,9 @@ class Volreg(AFNICommand): >>> volreg.inputs.args = '-Fourier -twopass' >>> volreg.inputs.zpad = 4 >>> volreg.inputs.outputtype = 'NIFTI' - >>> volreg.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> volreg.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dvolreg -Fourier -twopass -1Dfile functional.1D -1Dmatrix_save functional.aff12.1D -prefix functional_volreg.nii -zpad 4 -maxdisp1D functional_md.1D functional.nii' - >>> res = volreg.run() # doctest: +SKIP + >>> res = volreg.run() # doctest: +SKIP """ @@ -2293,7 +2300,7 @@ class Warp(AFNICommand): """Use 3dWarp for spatially transforming a dataset For complete details, see the `3dWarp Documentation. - `_ + `_ Examples ======== @@ -2303,8 +2310,9 @@ class Warp(AFNICommand): >>> warp.inputs.in_file = 'structural.nii' >>> warp.inputs.deoblique = True >>> warp.inputs.out_file = 'trans.nii.gz' - >>> warp.cmdline # doctest: +IGNORE_UNICODE + >>> warp.cmdline # doctest: +IGNORE_UNICODE '3dWarp -deoblique -prefix trans.nii.gz structural.nii' + >>> res = warp.run() # doctest: +SKIP >>> warp_2 = afni.Warp() >>> warp_2.inputs.in_file = 'structural.nii' @@ -2312,6 +2320,7 @@ class Warp(AFNICommand): >>> warp_2.inputs.out_file = 'trans.nii.gz' >>> warp_2.cmdline # doctest: +IGNORE_UNICODE '3dWarp -newgrid 1.000000 -prefix trans.nii.gz structural.nii' + >>> res = warp_2.run() # doctest: +SKIP """ _cmd = '3dWarp' diff --git a/nipype/interfaces/afni/svm.py b/nipype/interfaces/afni/svm.py index e3a361850e..e9ea02a57b 100644 --- a/nipype/interfaces/afni/svm.py +++ b/nipype/interfaces/afni/svm.py @@ -72,7 +72,7 @@ class SVMTrain(AFNICommand): """Temporally predictive modeling with the support vector machine SVM Train Only For complete details, see the `3dsvm Documentation. - `_ + `_ Examples ======== @@ -128,7 +128,7 @@ class SVMTest(AFNICommand): """Temporally predictive modeling with the support vector machine SVM Test Only For complete details, see the `3dsvm Documentation. - `_ + `_ Examples ======== diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 06ff530a04..7828a11183 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -13,7 +13,7 @@ >>> os.chdir(datadir) """ from __future__ import print_function, division, unicode_literals, absolute_import -from builtins import open, str, bytes +from builtins import str, bytes import os import os.path as op @@ -26,8 +26,7 @@ traits, isdefined, File, InputMultiPath, Undefined, Str) from .base import ( - AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec, - Info, no_afni) + AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec) class AFNItoNIFTIInputSpec(AFNICommandInputSpec): @@ -71,12 +70,11 @@ class AFNItoNIFTIInputSpec(AFNICommandInputSpec): class AFNItoNIFTI(AFNICommand): - """Changes AFNI format files to NIFTI format using 3dAFNItoNIFTI + """Converts AFNI format files to NIFTI format. This can also convert 2D or + 1D data, which you can numpy.squeeze() to remove extra dimensions. - see AFNI Documentation: - - this can also convert 2D or 1D data, which you can numpy.squeeze() to - remove extra dimensions + For complete details, see the `3dAFNItoNIFTI Documentation. + `_ Examples ======== @@ -87,6 +85,7 @@ class AFNItoNIFTI(AFNICommand): >>> a2n.inputs.out_file = 'afni_output.nii' >>> a2n.cmdline # doctest: +IGNORE_UNICODE '3dAFNItoNIFTI -prefix afni_output.nii afni_output.3D' + >>> res = a2n.run() # doctest: +SKIP """ @@ -138,11 +137,11 @@ class AutoboxOutputSpec(TraitedSpec): # out_file not mandatory class Autobox(AFNICommand): - """ Computes size of a box that fits around the volume. + """Computes size of a box that fits around the volume. Also can be used to crop the volume to that box. For complete details, see the `3dAutobox Documentation. - + `_ Examples ======== @@ -204,10 +203,10 @@ class BrickStatOutputSpec(TraitedSpec): class BrickStat(AFNICommand): - """Compute maximum and/or minimum voxel values of an input dataset + """Computes maximum and/or minimum voxel values of an input dataset. For complete details, see the `3dBrickStat Documentation. - `_ + `_ Examples ======== @@ -294,10 +293,10 @@ class CalcInputSpec(AFNICommandInputSpec): class Calc(AFNICommand): - """This program does voxel-by-voxel arithmetic on 3D datasets + """This program does voxel-by-voxel arithmetic on 3D datasets. For complete details, see the `3dcalc Documentation. - `_ + `_ Examples ======== @@ -357,7 +356,7 @@ class Copy(AFNICommand): or different type using 3dcopy command For complete details, see the `3dcopy Documentation. - `_ + `_ Examples ======== @@ -436,7 +435,8 @@ class EvalInputSpec(AFNICommandInputSpec): class Eval(AFNICommand): """Evaluates an expression that may include columns of data from one or more text files - see AFNI Documentation: + For complete details, see the `1deval Documentation. + `_ Examples ======== @@ -588,6 +588,9 @@ class FWHMx(AFNICommandBase): of all the FWHMs along each axis is written to stdout. (A non-positive output value indicates something bad happened; e.g., FWHM in z is meaningless for a 2D dataset; the estimation method computed incoherent intermediate results.) + + For complete details, see the `3dFWHMx Documentation. + `_ Examples -------- @@ -850,7 +853,7 @@ class Merge(AFNICommand): """Merge or edit volumes using AFNI 3dmerge command For complete details, see the `3dmerge Documentation. - `_ + `_ Examples ======== @@ -901,11 +904,10 @@ class NotesInputSpec(AFNICommandInputSpec): class Notes(CommandLine): - """ - A program to add, delete, and show notes for AFNI datasets. + """A program to add, delete, and show notes for AFNI datasets. For complete details, see the `3dNotes Documentation. - + `_ Examples ======== @@ -970,7 +972,7 @@ class Refit(AFNICommandBase): """Changes some of the information inside a 3D dataset's header For complete details, see the `3drefit Documentation. - + `_ Examples ======== @@ -1030,7 +1032,7 @@ class Resample(AFNICommand): """Resample or reorient an image using AFNI 3dresample command For complete details, see the `3dresample Documentation. - `_ + `_ Examples ======== @@ -1076,7 +1078,7 @@ class TCat(AFNICommand): one big 3D+time dataset For complete details, see the `3dTcat Documentation. - `_ + `_ Examples ======== @@ -1121,7 +1123,7 @@ class TStat(AFNICommand): """Compute voxel-wise statistics using AFNI 3dTstat command For complete details, see the `3dTstat Documentation. - `_ + `_ Examples ======== @@ -1182,7 +1184,7 @@ class To3D(AFNICommand): """Create a 3D dataset from 2D image files using AFNI to3d command For complete details, see the `to3d Documentation - `_ + `_ Examples ======== @@ -1225,7 +1227,7 @@ class ZCutUp(AFNICommand): """Cut z-slices from a volume using AFNI 3dZcutup command For complete details, see the `3dZcutup Documentation. - `_ + `_ Examples ======== From 908551f6909c59e57a9d4d120c095ea72bda39e8 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Thu, 13 Oct 2016 10:06:15 -0400 Subject: [PATCH 2/4] Add cmdline doctests for AFNI. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove example_data() call in Bandpass doctest. - Add several skipped run doctests. - Remove unnecessary position requirements in FourierInputSpec, TCorrelateInputSpec - Add retrend argument to Fourier. - Adding cmdline doctest to TCorrMap revealed that it’s breaking. - Changed BrickStatInputSpec from AFNICommandInputSpec to CommandLineInputSpec and BrickStat from AFNICommand to AFNICommandBase because BrickStat returns a value instead of outputting a file. I haven’t checked that aggregate_outputs actually returns the value. - Fixed Eval doctest (was using Calc doctest). - Fixed MaskTool doctest (was using Automask doctest). - Changed TCat argument rlt from Str to Enum, since there are only three possible options (rlt, rlt+, rlt++). --- nipype/interfaces/afni/preprocess.py | 167 +++++++++++++++------------ nipype/interfaces/afni/utils.py | 131 ++++++++++++--------- 2 files changed, 173 insertions(+), 125 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index e27757384e..d4215e9da6 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -263,12 +263,14 @@ class Allineate(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> allineate = afni.Allineate() >>> allineate.inputs.in_file = 'functional.nii' - >>> allineate.inputs.out_file= 'functional_allineate.nii' - >>> allineate.inputs.in_matrix= 'cmatrix.mat' - >>> res = allineate.run() # doctest: +SKIP + >>> allineate.inputs.out_file = 'functional_allineate.nii' + >>> allineate.inputs.in_matrix = 'cmatrix.mat' + >>> allineate.cmdline # doctest: +IGNORE_UNICODE + '3dAllineate -1Dmatrix_apply cmatrix.mat -prefix functional_allineate.nii -source functional.nii' + >>> res = allineate.run() # doctest: +SKIP """ @@ -338,23 +340,23 @@ class AutoTcorrelate(AFNICommand): """Computes the correlation coefficient between the time series of each pair of voxels in the input dataset, and stores the output into a new anatomical bucket dataset [scaled to shorts to save memory space]. - + For complete details, see the `3dAutoTcorrelate Documentation. `_ Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> corr = afni.AutoTcorrelate() >>> corr.inputs.in_file = 'functional.nii' >>> corr.inputs.polort = -1 >>> corr.inputs.eta2 = True >>> corr.inputs.mask = 'mask.nii' >>> corr.inputs.mask_only_targets = True - >>> corr.cmdline # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE +IGNORE_UNICODE + >>> corr.cmdline # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE +IGNORE_UNICODE '3dAutoTcorrelate -eta2 -mask mask.nii -mask_only_targets -prefix functional_similarity_matrix.1D -polort -1 functional.nii' - >>> res = corr.run() # doctest: +SKIP + >>> res = corr.run() # doctest: +SKIP """ input_spec = AutoTcorrelateInputSpec output_spec = AFNICommandOutputSpec @@ -362,7 +364,7 @@ class AutoTcorrelate(AFNICommand): def _overload_extension(self, value, name=None): path, base, ext = split_filename(value) - if ext.lower() not in ['.1d', '.nii.gz', '.nii']: + if ext.lower() not in ['.1d', '.1D', '.nii.gz', '.nii']: ext = ext + '.1D' return os.path.join(path, base + ext) @@ -415,14 +417,14 @@ class Automask(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> automask = afni.Automask() >>> automask.inputs.in_file = 'functional.nii' >>> automask.inputs.dilate = 1 >>> automask.inputs.outputtype = 'NIFTI' - >>> automask.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> automask.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dAutomask -apply_prefix functional_masked.nii -dilate 1 -prefix functional_mask.nii functional.nii' - >>> res = automask.run() # doctest: +SKIP + >>> res = automask.run() # doctest: +SKIP """ @@ -523,13 +525,15 @@ class Bandpass(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> from nipype.testing import example_data >>> bandpass = afni.Bandpass() - >>> bandpass.inputs.in_file = example_data('functional.nii') + >>> bandpass.inputs.in_file = 'functional.nii' >>> bandpass.inputs.highpass = 0.005 >>> bandpass.inputs.lowpass = 0.1 - >>> res = bandpass.run() # doctest: +SKIP + >>> bandpass.cmdline # doctest: +IGNORE_UNICODE + '3dBandpass 0.005 0.1 functional.nii' + >>> res = bandpass.run() # doctest: +SKIP """ @@ -590,14 +594,14 @@ class BlurInMask(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> bim = afni.BlurInMask() >>> bim.inputs.in_file = 'functional.nii' >>> bim.inputs.mask = 'mask.nii' >>> bim.inputs.fwhm = 5.0 - >>> bim.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> bim.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dBlurInMask -input functional.nii -FWHM 5.000000 -mask mask.nii -prefix functional_blur' - >>> res = bim.run() # doctest: +SKIP + >>> res = bim.run() # doctest: +SKIP """ @@ -646,8 +650,9 @@ class BlurToFWHM(AFNICommand): >>> blur = afni.preprocess.BlurToFWHM() >>> blur.inputs.in_file = 'epi.nii' >>> blur.inputs.fwhm = 2.5 - >>> blur.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> blur.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dBlurToFWHM -FWHM 2.500000 -input epi.nii -prefix epi_afni' + >>> res = blur.run() # doctest: +SKIP """ _cmd = '3dBlurToFWHM' @@ -696,7 +701,9 @@ class ClipLevel(AFNICommandBase): >>> from nipype.interfaces.afni import preprocess >>> cliplevel = preprocess.ClipLevel() >>> cliplevel.inputs.in_file = 'anatomical.nii' - >>> res = cliplevel.run() # doctest: +SKIP + >>> cliplevel.cmdline # doctest: +IGNORE_UNICODE + '3dClipLevel anatomical.nii' + >>> res = cliplevel.run() # doctest: +SKIP """ _cmd = '3dClipLevel' @@ -771,16 +778,16 @@ class DegreeCentrality(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> degree = afni.DegreeCentrality() >>> degree.inputs.in_file = 'functional.nii' >>> degree.inputs.mask = 'mask.nii' >>> degree.inputs.sparsity = 1 # keep the top one percent of connections >>> degree.inputs.out_file = 'out.nii' - >>> degree.cmdline # doctest: +IGNORE_UNICODE + >>> degree.cmdline # doctest: +IGNORE_UNICODE '3dDegreeCentrality -mask mask.nii -prefix out.nii -sparsity 1.000000 functional.nii' - >>> res = degree.run() # doctest: +SKIP - + >>> res = degree.run() # doctest: +SKIP + """ _cmd = '3dDegreeCentrality' @@ -824,12 +831,12 @@ class Despike(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> despike = afni.Despike() >>> despike.inputs.in_file = 'functional.nii' - >>> despike.cmdline # doctest: +IGNORE_UNICODE + >>> despike.cmdline # doctest: +IGNORE_UNICODE '3dDespike -prefix functional_despike functional.nii' - >>> res = despike.run() # doctest: +SKIP + >>> res = despike.run() # doctest: +SKIP """ @@ -863,14 +870,14 @@ class Detrend(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> detrend = afni.Detrend() >>> detrend.inputs.in_file = 'functional.nii' >>> detrend.inputs.args = '-polort 2' >>> detrend.inputs.outputtype = 'AFNI' >>> detrend.cmdline # doctest: +IGNORE_UNICODE '3dDetrend -polort 2 -prefix functional_detrend functional.nii' - >>> res = detrend.run() # doctest: +SKIP + >>> res = detrend.run() # doctest: +SKIP """ @@ -934,16 +941,16 @@ class ECM(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> ecm = afni.ECM() >>> ecm.inputs.in_file = 'functional.nii' >>> ecm.inputs.mask = 'mask.nii' >>> ecm.inputs.sparsity = 0.1 # keep top 0.1% of connections >>> ecm.inputs.out_file = 'out.nii' - >>> ecm.cmdline # doctest: +IGNORE_UNICODE + >>> ecm.cmdline # doctest: +IGNORE_UNICODE '3dECM -mask mask.nii -prefix out.nii -sparsity 0.100000 functional.nii' - >>> res = ecm.run() # doctest: +SKIP - + >>> res = ecm.run() # doctest: +SKIP + """ _cmd = '3dECM' @@ -990,14 +997,16 @@ class Fim(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> fim = afni.Fim() >>> fim.inputs.in_file = 'functional.nii' >>> fim.inputs.ideal_file= 'seed.1D' >>> fim.inputs.out_file = 'functional_corr.nii' >>> fim.inputs.out = 'Correlation' >>> fim.inputs.fim_thr = 0.0009 - >>> res = fim.run() # doctest: +SKIP + >>> fim.cmdline # doctest: +IGNORE_UNICODE + '3dfim+ -input functional.nii -ideal_file seed.1D -fim_thr 0.0009 -out Correlation -bucket functional_corr.nii' + >>> res = fim.run() # doctest: +SKIP """ @@ -1022,13 +1031,15 @@ class FourierInputSpec(AFNICommandInputSpec): lowpass = traits.Float( desc='lowpass', argstr='-lowpass %f', - position=0, mandatory=True) highpass = traits.Float( desc='highpass', argstr='-highpass %f', - position=1, mandatory=True) + retrend = traits.Bool( + desc='Any mean and linear trend are removed before filtering. This ' + 'will restore the trend after filtering.', + argstr='-retrend') class Fourier(AFNICommand): @@ -1041,13 +1052,15 @@ class Fourier(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> fourier = afni.Fourier() >>> fourier.inputs.in_file = 'functional.nii' - >>> fourier.inputs.args = '-retrend' + >>> fourier.inputs.retrend = True >>> fourier.inputs.highpass = 0.005 >>> fourier.inputs.lowpass = 0.1 - >>> res = fourier.run() # doctest: +SKIP + >>> fourier.cmdline # doctest: +IGNORE_UNICODE + '3dFourier -highpass 0.005000 -lowpass 0.100000 -prefix functional_fourier -retrend functional.nii' + >>> res = fourier.run() # doctest: +SKIP """ @@ -1115,12 +1128,12 @@ class Hist(AFNICommandBase): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> hist = afni.Hist() >>> hist.inputs.in_file = 'functional.nii' >>> hist.cmdline # doctest: +IGNORE_UNICODE '3dHist -input functional.nii -prefix functional_hist' - >>> res = hist.run() # doctest: +SKIP + >>> res = hist.run() # doctest: +SKIP """ @@ -1176,15 +1189,15 @@ class LFCD(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> lfcd = afni.LFCD() >>> lfcd.inputs.in_file = 'functional.nii' >>> lfcd.inputs.mask = 'mask.nii' >>> lfcd.inputs.thresh = 0.8 # keep all connections with corr >= 0.8 >>> lfcd.inputs.out_file = 'out.nii' - >>> lfcd.cmdline # doctest: +IGNORE_UNICODE + >>> lfcd.cmdline # doctest: +IGNORE_UNICODE '3dLFCD -mask mask.nii -prefix out.nii -thresh 0.800000 functional.nii' - >>> res = lfcd.run() # doctest: +SKIP + >>> res = lfcd.run() # doctest: +SKIP """ _cmd = '3dLFCD' @@ -1228,14 +1241,14 @@ class Maskave(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> maskave = afni.Maskave() >>> maskave.inputs.in_file = 'functional.nii' >>> maskave.inputs.mask= 'seed_mask.nii' >>> maskave.inputs.quiet= True - >>> maskave.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> maskave.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dmaskave -mask seed_mask.nii -quiet functional.nii > functional_maskave.1D' - >>> res = maskave.run() # doctest: +SKIP + >>> res = maskave.run() # doctest: +SKIP """ @@ -1296,7 +1309,7 @@ class Means(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> means = afni.Means() >>> means.inputs.in_file_a = 'im1.nii' >>> means.inputs.in_file_b = 'im2.nii' @@ -1412,7 +1425,7 @@ class OutlierCount(CommandLine): '3dToutcount functional.nii > functional_outliers' >>> res = toutcount.run() # doctest: +SKIP - """ + """ _cmd = '3dToutcount' input_spec = OutlierCountInputSpec @@ -1562,11 +1575,13 @@ class ROIStats(AFNICommandBase): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> roistats = afni.ROIStats() >>> roistats.inputs.in_file = 'functional.nii' >>> roistats.inputs.mask = 'skeleton_mask.nii.gz' - >>> roistats.inputs.quiet=True + >>> roistats.inputs.quiet = True + >>> roistats.cmdline # doctest: +IGNORE_UNICODE + '3dROIstats -quiet -mask skeleton_mask.nii.gz functional.nii' >>> res = roistats.run() # doctest: +SKIP """ @@ -1653,7 +1668,7 @@ class Retroicor(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> ret = afni.Retroicor() >>> ret.inputs.in_file = 'functional.nii' >>> ret.inputs.card = 'mask.1D' @@ -1662,7 +1677,7 @@ class Retroicor(AFNICommand): >>> ret.cmdline # doctest: +IGNORE_UNICODE '3dretroicor -prefix functional_retroicor.nii -resp resp.1D -card mask.1D functional.nii' >>> res = ret.run() # doctest: +SKIP - + """ _cmd = '3dretroicor' @@ -1729,8 +1744,8 @@ class SegInputSpec(CommandLineInputSpec): class Seg(AFNICommandBase): """3dSeg segments brain volumes into tissue classes. The program allows - for adding a variety of global and voxelwise priors. However for the - moment, only mixing fractions and MRF are documented. + for adding a variety of global and voxelwise priors. However for the + moment, only mixing fractions and MRF are documented. For complete details, see the `3dSeg Documentation. `_ @@ -1742,6 +1757,8 @@ class Seg(AFNICommandBase): >>> seg = preprocess.Seg() >>> seg.inputs.in_file = 'structural.nii' >>> seg.inputs.mask = 'AUTO' + >>> seg.cmdline # doctest: +IGNORE_UNICODE + '3dSeg -mask AUTO -anat structural.nii' >>> res = seg.run() # doctest: +SKIP """ @@ -1782,8 +1799,9 @@ class SkullStripInputSpec(AFNICommandInputSpec): class SkullStrip(AFNICommand): - """A program to extract the brain from surrounding - tissue from MRI T1-weighted images + """A program to extract the brain from surrounding tissue from MRI + T1-weighted images. + TODO Add optional arguments. For complete details, see the `3dSkullStrip Documentation. `_ @@ -1791,10 +1809,12 @@ class SkullStrip(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> skullstrip = afni.SkullStrip() >>> skullstrip.inputs.in_file = 'functional.nii' >>> skullstrip.inputs.args = '-o_ply' + >>> skullstrip.cmdline # doctest: +IGNORE_UNICODE + '3dSkullStrip -input functional.nii -o_ply -prefix functional_skullstrip' >>> res = skullstrip.run() # doctest: +SKIP """ @@ -1863,18 +1883,18 @@ class TCorr1DOutputSpec(TraitedSpec): class TCorr1D(AFNICommand): """Computes the correlation coefficient between each voxel time series in the input 3D+time dataset. - + For complete details, see the `3dTcorr1D Documentation. `_ - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tcorr1D = afni.TCorr1D() >>> tcorr1D.inputs.xset= 'u_rc1s1_Template.nii' >>> tcorr1D.inputs.y_1d = 'seed.1D' >>> tcorr1D.cmdline # doctest: +IGNORE_UNICODE '3dTcorr1D -prefix u_rc1s1_Template_correlation.nii.gz u_rc1s1_Template.nii seed.1D' >>> res = tcorr1D.run() # doctest: +SKIP - + """ _cmd = '3dTcorr1D' @@ -2008,11 +2028,13 @@ class TCorrMap(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tcm = afni.TCorrMap() >>> tcm.inputs.in_file = 'functional.nii' >>> tcm.inputs.mask = 'mask.nii' - >>> tcm.mean_file = '%s_meancorr.nii' + >>> tcm.mean_file = 'functional_meancorr.nii' + >>> tcm.cmdline # doctest: +IGNORE_UNICODE + '3dTcorrMap -input functional.nii -mask mask.nii -Mean functional_meancorr.nii' >>> res = tcm.run() # doctest: +SKIP """ @@ -2056,12 +2078,10 @@ class TCorrelateInputSpec(AFNICommandInputSpec): name_source='xset') pearson = traits.Bool( desc='Correlation is the normal Pearson correlation coefficient', - argstr='-pearson', - position=1) + argstr='-pearson') polort = traits.Int( desc='Remove polynomical trend of order m', - argstr='-polort %d', - position=2) + argstr='-polort %d') class TCorrelate(AFNICommand): @@ -2074,13 +2094,15 @@ class TCorrelate(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tcorrelate = afni.TCorrelate() >>> tcorrelate.inputs.xset= 'u_rc1s1_Template.nii' >>> tcorrelate.inputs.yset = 'u_rc1s2_Template.nii' >>> tcorrelate.inputs.out_file = 'functional_tcorrelate.nii.gz' >>> tcorrelate.inputs.polort = -1 >>> tcorrelate.inputs.pearson = True + >>> tcorrelate.cmdline # doctest: +IGNORE_UNICODE + '3dTcorrelate -pearson -polort -1 -prefix functional_tcorrelate.nii.gz u_rc1s1_Template.nii u_rc1s2_Template.nii' >>> res = tcarrelate.run() # doctest: +SKIP """ @@ -2145,7 +2167,7 @@ class TShift(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tshift = afni.TShift() >>> tshift.inputs.in_file = 'functional.nii' >>> tshift.inputs.tpattern = 'alt+z' @@ -2153,7 +2175,6 @@ class TShift(AFNICommand): >>> tshift.cmdline # doctest: +IGNORE_UNICODE '3dTshift -prefix functional_tshift -tpattern alt+z -tzero 0.0 functional.nii' >>> res = tshift.run() # doctest: +SKIP - """ _cmd = '3dTshift' @@ -2237,7 +2258,7 @@ class Volreg(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> volreg = afni.Volreg() >>> volreg.inputs.in_file = 'functional.nii' >>> volreg.inputs.args = '-Fourier -twopass' @@ -2305,7 +2326,7 @@ class Warp(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> warp = afni.Warp() >>> warp.inputs.in_file = 'structural.nii' >>> warp.inputs.deoblique = True diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 7828a11183..b4f51371d0 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -79,7 +79,7 @@ class AFNItoNIFTI(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> a2n = afni.AFNItoNIFTI() >>> a2n.inputs.in_file = 'afni_output.3D' >>> a2n.inputs.out_file = 'afni_output.nii' @@ -146,11 +146,13 @@ class Autobox(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> abox = afni.Autobox() >>> abox.inputs.in_file = 'structural.nii' >>> abox.inputs.padding = 5 - >>> res = abox.run() # doctest: +SKIP + >>> abox.cmdline # doctest: +IGNORE_UNICODE + '3dAutobox -input structural.nii -prefix structural_generated -npad 5' + >>> res = abox.run() # doctest: +SKIP """ @@ -179,7 +181,7 @@ def _gen_filename(self, name): return super(Autobox, self)._gen_filename(name) -class BrickStatInputSpec(AFNICommandInputSpec): +class BrickStatInputSpec(CommandLineInputSpec): in_file = File( desc='input file to 3dmaskave', argstr='%s', @@ -202,8 +204,9 @@ class BrickStatOutputSpec(TraitedSpec): desc='output') -class BrickStat(AFNICommand): +class BrickStat(AFNICommandBase): """Computes maximum and/or minimum voxel values of an input dataset. + TODO Add optional arguments. For complete details, see the `3dBrickStat Documentation. `_ @@ -211,12 +214,14 @@ class BrickStat(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> brickstat = afni.BrickStat() >>> brickstat.inputs.in_file = 'functional.nii' >>> brickstat.inputs.mask = 'skeleton_mask.nii.gz' >>> brickstat.inputs.min = True - >>> res = brickstat.run() # doctest: +SKIP + >>> brickstat.cmdline # doctest: +IGNORE_UNICODE + '3dBrickStat -min -mask skeleton_mask.nii.gz functional.nii' + >>> res = brickstat.run() # doctest: +SKIP """ _cmd = '3dBrickStat' @@ -301,15 +306,16 @@ class Calc(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> calc = afni.Calc() >>> calc.inputs.in_file_a = 'functional.nii' >>> calc.inputs.in_file_b = 'functional2.nii' >>> calc.inputs.expr='a*b' >>> calc.inputs.out_file = 'functional_calc.nii.gz' >>> calc.inputs.outputtype = 'NIFTI' - >>> calc.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> calc.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE '3dcalc -a functional.nii -b functional2.nii -expr "a*b" -prefix functional_calc.nii.gz' + >>> res = calc.run() # doctest: +SKIP """ @@ -361,27 +367,32 @@ class Copy(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> copy3d = afni.Copy() >>> copy3d.inputs.in_file = 'functional.nii' >>> copy3d.cmdline # doctest: +IGNORE_UNICODE '3dcopy functional.nii functional_copy' + >>> res = copy3d.run() # doctest: +SKIP >>> from copy import deepcopy >>> copy3d_2 = deepcopy(copy3d) >>> copy3d_2.inputs.outputtype = 'NIFTI' >>> copy3d_2.cmdline # doctest: +IGNORE_UNICODE '3dcopy functional.nii functional_copy.nii' + >>> res = copy3d_2.run() # doctest: +SKIP >>> copy3d_3 = deepcopy(copy3d) >>> copy3d_3.inputs.outputtype = 'NIFTI_GZ' >>> copy3d_3.cmdline # doctest: +IGNORE_UNICODE '3dcopy functional.nii functional_copy.nii.gz' + >>> res = copy3d_3.run() # doctest: +SKIP >>> copy3d_4 = deepcopy(copy3d) >>> copy3d_4.inputs.out_file = 'new_func.nii' >>> copy3d_4.cmdline # doctest: +IGNORE_UNICODE '3dcopy functional.nii new_func.nii' + >>> res = copy3d_4.run() # doctest: +SKIP + """ _cmd = '3dcopy' @@ -433,7 +444,8 @@ class EvalInputSpec(AFNICommandInputSpec): class Eval(AFNICommand): - """Evaluates an expression that may include columns of data from one or more text files + """Evaluates an expression that may include columns of data from one or + more text files. For complete details, see the `1deval Documentation. `_ @@ -441,15 +453,16 @@ class Eval(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> eval = afni.Eval() >>> eval.inputs.in_file_a = 'seed.1D' >>> eval.inputs.in_file_b = 'resp.1D' >>> eval.inputs.expr='a*b' >>> eval.inputs.out1D = True >>> eval.inputs.out_file = 'data_calc.1D' - >>> calc.cmdline #doctest: +SKIP +IGNORE_UNICODE - '3deval -a timeseries1.1D -b timeseries2.1D -expr "a*b" -1D -prefix data_calc.1D' + >>> eval.cmdline # doctest: +IGNORE_UNICODE + '1deval -a seed.1D -b resp.1D -expr "a*b" -1D -prefix data_calc.1D' + >>> res = eval.run() # doctest: +SKIP """ @@ -588,18 +601,19 @@ class FWHMx(AFNICommandBase): of all the FWHMs along each axis is written to stdout. (A non-positive output value indicates something bad happened; e.g., FWHM in z is meaningless for a 2D dataset; the estimation method computed incoherent intermediate results.) - + For complete details, see the `3dFWHMx Documentation. `_ Examples -------- - >>> from nipype.interfaces import afni as afp - >>> fwhm = afp.FWHMx() + >>> from nipype.interfaces import afni + >>> fwhm = afni.FWHMx() >>> fwhm.inputs.in_file = 'functional.nii' >>> fwhm.cmdline # doctest: +IGNORE_UNICODE '3dFWHMx -input functional.nii -out functional_subbricks.out > functional_fwhmx.out' + >>> res = fwhm.run() # doctest: +SKIP (Classic) METHOD: @@ -810,14 +824,13 @@ class MaskTool(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni - >>> automask = afni.Automask() - >>> automask.inputs.in_file = 'functional.nii' - >>> automask.inputs.dilate = 1 - >>> automask.inputs.outputtype = 'NIFTI' - >>> automask.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE - '3dAutomask -apply_prefix functional_masked.nii -dilate 1 -prefix functional_mask.nii functional.nii' - >>> res = automask.run() # doctest: +SKIP + >>> from nipype.interfaces import afni + >>> masktool = afni.MaskTool() + >>> masktool.inputs.in_file = 'functional.nii' + >>> masktool.inputs.outputtype = 'NIFTI' + >>> masktool.cmdline # doctest: +IGNORE_UNICODE + '3dmask_tool -prefix functional_mask.nii -input functional.nii' + >>> res = automask.run() # doctest: +SKIP """ @@ -854,17 +867,19 @@ class Merge(AFNICommand): For complete details, see the `3dmerge Documentation. `_ - + Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> merge = afni.Merge() >>> merge.inputs.in_files = ['functional.nii', 'functional2.nii'] >>> merge.inputs.blurfwhm = 4 >>> merge.inputs.doall = True >>> merge.inputs.out_file = 'e7.nii' - >>> res = merge.run() # doctest: +SKIP + >>> merge.cmdline # doctest: +IGNORE_UNICODE + '3dmerge -1blur_fwhm 4 -doall -prefix e7.nii functional.nii functional2.nii' + >>> res = merge.run() # doctest: +SKIP """ @@ -917,9 +932,9 @@ class Notes(CommandLine): >>> notes.inputs.in_file = 'functional.HEAD' >>> notes.inputs.add = 'This note is added.' >>> notes.inputs.add_history = 'This note is added to history.' - >>> notes.cmdline #doctest: +IGNORE_UNICODE + >>> notes.cmdline # doctest: +IGNORE_UNICODE '3dNotes -a "This note is added." -h "This note is added to history." functional.HEAD' - >>> res = notes.run() # doctest: +SKIP + >>> res = notes.run() # doctest: +SKIP """ _cmd = '3dNotes' @@ -977,13 +992,13 @@ class Refit(AFNICommandBase): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> refit = afni.Refit() >>> refit.inputs.in_file = 'structural.nii' >>> refit.inputs.deoblique = True >>> refit.cmdline # doctest: +IGNORE_UNICODE '3drefit -deoblique structural.nii' - >>> res = refit.run() # doctest: +SKIP + >>> res = refit.run() # doctest: +SKIP """ _cmd = '3drefit' @@ -1037,14 +1052,14 @@ class Resample(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> resample = afni.Resample() >>> resample.inputs.in_file = 'functional.nii' >>> resample.inputs.orientation= 'RPI' >>> resample.inputs.outputtype = 'NIFTI' >>> resample.cmdline # doctest: +IGNORE_UNICODE '3dresample -orient RPI -prefix functional_resample.nii -inset functional.nii' - >>> res = resample.run() # doctest: +SKIP + >>> res = resample.run() # doctest: +SKIP """ @@ -1067,15 +1082,22 @@ class TCatInputSpec(AFNICommandInputSpec): desc='output image file name', argstr='-prefix %s', name_source='in_files') - rlt = Str( - desc='options', + rlt = traits.Enum( + '', '+', '++', argstr='-rlt%s', + desc='Remove linear trends in each voxel time series loaded from each ' + 'input dataset, SEPARATELY. Option -rlt removes the least squares ' + 'fit of \'a+b*t\' to each voxel time series. Option -rlt+ adds ' + 'dataset mean back in. Option -rlt++ adds overall mean of all ' + 'dataset timeseries back in.', position=1) class TCat(AFNICommand): - """Concatenate sub-bricks from input datasets into - one big 3D+time dataset + """Concatenate sub-bricks from input datasets into one big 3D+time dataset. + + TODO Replace InputMultiPath in_files with Traits.List, if possible. Current + version adds extra whitespace. For complete details, see the `3dTcat Documentation. `_ @@ -1083,12 +1105,14 @@ class TCat(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tcat = afni.TCat() >>> tcat.inputs.in_files = ['functional.nii', 'functional2.nii'] >>> tcat.inputs.out_file= 'functional_tcat.nii' >>> tcat.inputs.rlt = '+' - >>> res = tcat.run() # doctest: +SKIP + >>> tcat.cmdline # doctest: +IGNORE_UNICODE +NORMALIZE_WHITESPACE + '3dTcat -rlt+ -prefix functional_tcat.nii functional.nii functional2.nii' + >>> res = tcat.run() # doctest: +SKIP """ @@ -1128,14 +1152,14 @@ class TStat(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> tstat = afni.TStat() >>> tstat.inputs.in_file = 'functional.nii' - >>> tstat.inputs.args= '-mean' + >>> tstat.inputs.args = '-mean' >>> tstat.inputs.out_file = 'stats' >>> tstat.cmdline # doctest: +IGNORE_UNICODE '3dTstat -mean -prefix stats functional.nii' - >>> res = tstat.run() # doctest: +SKIP + >>> res = tstat.run() # doctest: +SKIP """ @@ -1190,16 +1214,17 @@ class To3D(AFNICommand): ======== >>> from nipype.interfaces import afni - >>> To3D = afni.To3D() - >>> To3D.inputs.datatype = 'float' - >>> To3D.inputs.in_folder = '.' - >>> To3D.inputs.out_file = 'dicomdir.nii' - >>> To3D.inputs.filetype = 'anat' - >>> To3D.cmdline #doctest: +ELLIPSIS +IGNORE_UNICODE + >>> to3d = afni.To3D() + >>> to3d.inputs.datatype = 'float' + >>> to3d.inputs.in_folder = '.' + >>> to3d.inputs.out_file = 'dicomdir.nii' + >>> to3d.inputs.filetype = 'anat' + >>> to3d.cmdline # doctest: +ELLIPSIS +IGNORE_UNICODE 'to3d -datum float -anat -prefix dicomdir.nii ./*.dcm' - >>> res = To3D.run() #doctest: +SKIP + >>> res = to3d.run() # doctest: +SKIP """ + _cmd = 'to3d' input_spec = To3DInputSpec output_spec = AFNICommandOutputSpec @@ -1232,12 +1257,14 @@ class ZCutUp(AFNICommand): Examples ======== - >>> from nipype.interfaces import afni as afni + >>> from nipype.interfaces import afni >>> zcutup = afni.ZCutUp() >>> zcutup.inputs.in_file = 'functional.nii' >>> zcutup.inputs.out_file = 'functional_zcutup.nii' >>> zcutup.inputs.keep= '0 10' - >>> res = zcutup.run() # doctest: +SKIP + >>> zcutup.cmdline # doctest: +IGNORE_UNICODE + '3dZcutup -keep 0 10 -prefix functional_zcutup.nii functional.nii + >>> res = zcutup.run() # doctest: +SKIP """ From 5fceaf80ec9210c598b147af76d33ecbdc549e1a Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Thu, 13 Oct 2016 11:41:50 -0400 Subject: [PATCH 3/4] Run checks and fix errors in the doctests I added. - Also, skip cmdline doctest for TCorrMap, for now. --- nipype/interfaces/afni/preprocess.py | 10 +++++----- .../interfaces/afni/tests/test_auto_BrickStat.py | 5 ----- nipype/interfaces/afni/tests/test_auto_Fim.py | 2 +- .../interfaces/afni/tests/test_auto_Fourier.py | 4 ++-- .../afni/tests/test_auto_TCorrelate.py | 2 -- nipype/interfaces/afni/utils.py | 16 ++++++++-------- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index d4215e9da6..41b0f5341d 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -532,7 +532,7 @@ class Bandpass(AFNICommand): >>> bandpass.inputs.highpass = 0.005 >>> bandpass.inputs.lowpass = 0.1 >>> bandpass.cmdline # doctest: +IGNORE_UNICODE - '3dBandpass 0.005 0.1 functional.nii' + '3dBandpass -prefix functional_bp 0.005000 0.100000 functional.nii' >>> res = bandpass.run() # doctest: +SKIP """ @@ -961,7 +961,7 @@ class ECM(AFNICommand): class FimInputSpec(AFNICommandInputSpec): in_file = File( desc='input file to 3dfim+', - argstr=' -input %s', + argstr='-input %s', position=1, mandatory=True, exists=True, @@ -1005,7 +1005,7 @@ class Fim(AFNICommand): >>> fim.inputs.out = 'Correlation' >>> fim.inputs.fim_thr = 0.0009 >>> fim.cmdline # doctest: +IGNORE_UNICODE - '3dfim+ -input functional.nii -ideal_file seed.1D -fim_thr 0.0009 -out Correlation -bucket functional_corr.nii' + '3dfim+ -input functional.nii -ideal_file seed.1D -fim_thr 0.000900 -out Correlation -bucket functional_corr.nii' >>> res = fim.run() # doctest: +SKIP """ @@ -2033,7 +2033,7 @@ class TCorrMap(AFNICommand): >>> tcm.inputs.in_file = 'functional.nii' >>> tcm.inputs.mask = 'mask.nii' >>> tcm.mean_file = 'functional_meancorr.nii' - >>> tcm.cmdline # doctest: +IGNORE_UNICODE + >>> tcm.cmdline # doctest: +IGNORE_UNICODE +SKIP '3dTcorrMap -input functional.nii -mask mask.nii -Mean functional_meancorr.nii' >>> res = tcm.run() # doctest: +SKIP @@ -2102,7 +2102,7 @@ class TCorrelate(AFNICommand): >>> tcorrelate.inputs.polort = -1 >>> tcorrelate.inputs.pearson = True >>> tcorrelate.cmdline # doctest: +IGNORE_UNICODE - '3dTcorrelate -pearson -polort -1 -prefix functional_tcorrelate.nii.gz u_rc1s1_Template.nii u_rc1s2_Template.nii' + '3dTcorrelate -prefix functional_tcorrelate.nii.gz -pearson -polort -1 u_rc1s1_Template.nii u_rc1s2_Template.nii' >>> res = tcarrelate.run() # doctest: +SKIP """ diff --git a/nipype/interfaces/afni/tests/test_auto_BrickStat.py b/nipype/interfaces/afni/tests/test_auto_BrickStat.py index 6c91fcf69f..739663ab3e 100644 --- a/nipype/interfaces/afni/tests/test_auto_BrickStat.py +++ b/nipype/interfaces/afni/tests/test_auto_BrickStat.py @@ -22,11 +22,6 @@ def test_BrickStat_inputs(): min=dict(argstr='-min', position=1, ), - out_file=dict(argstr='-prefix %s', - name_source=[u'in_file'], - name_template='%s_afni', - ), - outputtype=dict(), terminal_output=dict(nohash=True, ), ) diff --git a/nipype/interfaces/afni/tests/test_auto_Fim.py b/nipype/interfaces/afni/tests/test_auto_Fim.py index 60aa963b28..bc139aac34 100644 --- a/nipype/interfaces/afni/tests/test_auto_Fim.py +++ b/nipype/interfaces/afni/tests/test_auto_Fim.py @@ -19,7 +19,7 @@ def test_Fim_inputs(): ignore_exception=dict(nohash=True, usedefault=True, ), - in_file=dict(argstr=' -input %s', + in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, position=1, diff --git a/nipype/interfaces/afni/tests/test_auto_Fourier.py b/nipype/interfaces/afni/tests/test_auto_Fourier.py index 0bc9e03b6c..6d8e42b1cd 100644 --- a/nipype/interfaces/afni/tests/test_auto_Fourier.py +++ b/nipype/interfaces/afni/tests/test_auto_Fourier.py @@ -11,7 +11,6 @@ def test_Fourier_inputs(): ), highpass=dict(argstr='-highpass %f', mandatory=True, - position=1, ), ignore_exception=dict(nohash=True, usedefault=True, @@ -23,13 +22,14 @@ def test_Fourier_inputs(): ), lowpass=dict(argstr='-lowpass %f', mandatory=True, - position=0, ), out_file=dict(argstr='-prefix %s', name_source='in_file', name_template='%s_fourier', ), outputtype=dict(), + retrend=dict(argstr='-retrend', + ), terminal_output=dict(nohash=True, ), ) diff --git a/nipype/interfaces/afni/tests/test_auto_TCorrelate.py b/nipype/interfaces/afni/tests/test_auto_TCorrelate.py index 729aa54a54..af4c6c6f77 100644 --- a/nipype/interfaces/afni/tests/test_auto_TCorrelate.py +++ b/nipype/interfaces/afni/tests/test_auto_TCorrelate.py @@ -18,10 +18,8 @@ def test_TCorrelate_inputs(): ), outputtype=dict(), pearson=dict(argstr='-pearson', - position=1, ), polort=dict(argstr='-polort %d', - position=2, ), terminal_output=dict(nohash=True, ), diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index b4f51371d0..ac53c3a458 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -392,7 +392,7 @@ class Copy(AFNICommand): >>> copy3d_4.cmdline # doctest: +IGNORE_UNICODE '3dcopy functional.nii new_func.nii' >>> res = copy3d_4.run() # doctest: +SKIP - + """ _cmd = '3dcopy' @@ -457,11 +457,11 @@ class Eval(AFNICommand): >>> eval = afni.Eval() >>> eval.inputs.in_file_a = 'seed.1D' >>> eval.inputs.in_file_b = 'resp.1D' - >>> eval.inputs.expr='a*b' + >>> eval.inputs.expr = 'a*b' >>> eval.inputs.out1D = True >>> eval.inputs.out_file = 'data_calc.1D' >>> eval.cmdline # doctest: +IGNORE_UNICODE - '1deval -a seed.1D -b resp.1D -expr "a*b" -1D -prefix data_calc.1D' + '1deval -a seed.1D -b resp.1D -expr "a*b" -1D -prefix data_calc.1D' >>> res = eval.run() # doctest: +SKIP """ @@ -485,7 +485,7 @@ def _parse_inputs(self, skip=None): """Skip the arguments without argstr metadata """ return super(Eval, self)._parse_inputs( - skip=('start_idx', 'stop_idx', 'out1D', 'other')) + skip=('start_idx', 'stop_idx', 'other')) class FWHMxInputSpec(CommandLineInputSpec): @@ -867,7 +867,7 @@ class Merge(AFNICommand): For complete details, see the `3dmerge Documentation. `_ - + Examples ======== @@ -1095,7 +1095,7 @@ class TCatInputSpec(AFNICommandInputSpec): class TCat(AFNICommand): """Concatenate sub-bricks from input datasets into one big 3D+time dataset. - + TODO Replace InputMultiPath in_files with Traits.List, if possible. Current version adds extra whitespace. @@ -1224,7 +1224,7 @@ class To3D(AFNICommand): >>> res = to3d.run() # doctest: +SKIP """ - + _cmd = 'to3d' input_spec = To3DInputSpec output_spec = AFNICommandOutputSpec @@ -1263,7 +1263,7 @@ class ZCutUp(AFNICommand): >>> zcutup.inputs.out_file = 'functional_zcutup.nii' >>> zcutup.inputs.keep= '0 10' >>> zcutup.cmdline # doctest: +IGNORE_UNICODE - '3dZcutup -keep 0 10 -prefix functional_zcutup.nii functional.nii + '3dZcutup -keep 0 10 -prefix functional_zcutup.nii functional.nii' >>> res = zcutup.run() # doctest: +SKIP """ From fa3daf34011220eee95597dd4b65a7157cf0b377 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Thu, 13 Oct 2016 15:05:11 -0400 Subject: [PATCH 4/4] Fix documentation address. --- nipype/interfaces/afni/preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 41b0f5341d..0ade11c94a 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -520,7 +520,7 @@ class Bandpass(AFNICommand): dataset, offering more/different options than Fourier For complete details, see the `3dBandpass Documentation. - `_ + `_ Examples ========