Skip to content

Commit 30224a9

Browse files
committed
TEST: Add doctests to new interfaces, fake data
1 parent 1512c62 commit 30224a9

7 files changed

+55
-1
lines changed

smriprep/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ def populate_namespace(doctest_namespace, tmp_path):
1313
doctest_namespace['os'] = os
1414
doctest_namespace['np'] = numpy
1515
doctest_namespace['load'] = load_resource
16-
doctest_namespace['testdir'] = tmp_path
16+
doctest_namespace['testdir'] = tmp_path

smriprep/interfaces/msm.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ class MSM(CommandLine):
124124
optimisation framework (FastPD Komodakis 2007), which significantly reduces the search
125125
space of possible deformations for each vertex, and allows flexibility with regards to the
126126
choice of similarity metric used to match the images.
127+
128+
>>> msm = MSM(
129+
... config_file=load('msm/MSMSulcStrainFinalconf'),
130+
... in_mesh='sub-01_hemi-L_sphere.surf.gii',
131+
... reference_mesh='tpl-fsaverage_hemi-L_den-164k_desc-std_sphere.surf.gii',
132+
... in_data='sub-01_hemi-L_sulc.shape.gii',
133+
... reference_data='tpl-fsaverage_hemi-L_den-164k_sulc.shape.gii',
134+
... out_base='L.',
135+
... )
136+
>>> msm.cmdline # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
137+
'msm --conf=.../MSMSulcStrainFinalconf \
138+
--indata=sub-01_hemi-L_sulc.shape.gii \
139+
--inmesh=sub-01_hemi-L_sphere.surf.gii \
140+
--out=L. \
141+
--refdata=tpl-fsaverage_hemi-L_den-164k_sulc.shape.gii \
142+
--refmesh=tpl-fsaverage_hemi-L_den-164k_desc-std_sphere.surf.gii'
143+
127144
"""
128145

129146
input_spec = MSMInputSpec

smriprep/interfaces/tests/data/sub-01_desc-warped_T1w.nii.gz

Whitespace-only changes.

smriprep/interfaces/tests/data/sub-01_hemi-L_sulc.shape.gii

Whitespace-only changes.

smriprep/interfaces/tests/data/tpl-fsaverage_hemi-L_den-164k_desc-std_sphere.surf.gii

Whitespace-only changes.

smriprep/interfaces/tests/data/tpl-fsaverage_hemi-L_den-164k_sulc.shape.gii

Whitespace-only changes.

smriprep/interfaces/workbench.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ class SurfaceAffineRegression(WBCommand):
185185
warped source surface. Note that this has a bias to shrink the surface
186186
that is being warped. The output is written as a NIFTI 'world' matrix,
187187
see -convert-affine to convert it for use in other software.
188+
189+
>>> sar = SurfaceAffineRegression()
190+
>>> sar.inputs.in_surface = 'sub-01_hemi-L_sulc.shape.gii'
191+
>>> sar.inputs.target_surface = 'tpl-fsaverage_hemi-L_den-164k_sulc.shape.gii'
192+
>>> sar.cmdline
193+
'wb_command -surface-affine-regression \
194+
sub-01_hemi-L_sulc.shape.gii \
195+
tpl-fsaverage_hemi-L_den-164k_sulc.shape.gii \
196+
sub-01_hemi-L_sulc.shape_xfm'
188197
"""
189198
input_spec = SurfaceAffineRegressionInputSpec
190199
output_spec = SurfaceAffineRegressionOutputSpec
@@ -250,6 +259,25 @@ class SurfaceApplyAffine(WBCommand):
250259
represent. If the -flirt option is not present, the affine must be a
251260
nifti 'world' affine, which can be obtained with the -convert-affine
252261
command, or aff_conv from the 4dfp suite.
262+
263+
.. testsetup::
264+
265+
>>> np.savetxt('affine.txt', np.eye(4), delimiter='\t')
266+
267+
.. doctest::
268+
269+
>>> saa = SurfaceApplyAffine()
270+
>>> saa.inputs.in_surface = 'sub-01_hemi-L_sphere.surf.gii'
271+
>>> saa.inputs.in_affine = 'affine.txt'
272+
>>> saa.cmdline
273+
'wb_command -surface-apply-affine \
274+
sub-01_hemi-L_sphere.surf.gii \
275+
affine.txt \
276+
sub-01_hemi-L_sphere.surf_xformed.surf.gii'
277+
278+
.. testcleanup::
279+
280+
>>> os.unlink('affine.txt')
253281
"""
254282
input_spec = SurfaceApplyAffineInputSpec
255283
output_spec = SurfaceApplyAffineOutputSpec
@@ -309,6 +337,15 @@ class SurfaceApplyWarpfield(WBCommand):
309337
If the -fnirt option is not present, the warpfield must be a nifti
310338
'world' warpfield, which can be obtained with the -convert-warpfield
311339
command.
340+
341+
>>> saw = SurfaceApplyWarpfield()
342+
>>> saw.inputs.in_surface = 'sub-01_hemi-L_sphere.surf.gii'
343+
>>> saw.inputs.warpfield = 'sub-01_desc-warped_T1w.nii.gz'
344+
>>> saw.cmdline
345+
'wb_command -surface-apply-warpfield \
346+
sub-01_hemi-L_sphere.surf.gii \
347+
sub-01_desc-warped_T1w.nii.gz \
348+
sub-01_hemi-L_sphere.surf_warped.surf.gii'
312349
"""
313350
input_spec = SurfaceApplyWarpfieldInputSpec
314351
output_spec = SurfaceApplyWarpfieldOutputSpec

0 commit comments

Comments
 (0)