Skip to content

Commit 94f44fb

Browse files
committed
tst: add doctest
1 parent cef50e1 commit 94f44fb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

niworkflows/interfaces/cifti.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ def _create_cifti_image(bold_file, label_file, bold_surfs, annotation_files, tr,
322322
label_orient = nb.aff2axcodes(label_img.affine)
323323
if bold_orient != label_orient:
324324
bold_img = _reorient_image(bold_img, bold_orient, label_orient)
325+
assert nb.aff2axcodes(bold_img) == label_orient == tuple('LAS')
325326

326327
bold_data = bold_img.get_fdata(dtype='float32')
327328
timepoints = bold_img.shape[3]
@@ -443,6 +444,21 @@ def _reorient_image(img, orient_img, orient_target):
443444
axis direction codes
444445
orient_target : tuple
445446
axis direction codes
447+
448+
.. testsetup::
449+
>>> img = nb.load(Path(test_data) / 'testRobustMNINormalizationRPTMovingWarpedImage.nii.gz')
450+
451+
Examples
452+
--------
453+
>>> nimg = _reorient_image(img, ('R', 'A', 'S'), ('L', 'A', 'S'))
454+
>>> nb.aff2axcodes(nimg.affine)
455+
('L', 'A', 'S')
456+
457+
>>> _reorient_image(img, ('R', 'A', 'S'), ('L', 'P', 'I'))
458+
Traceback (most recent call last):
459+
...
460+
NotImplementedError: Cannot reorient ...
461+
446462
"""
447463
if orient_img == tuple('RAS') and orient_target == tuple('LAS'): # RAS -> LAS
448464
return img.as_reoriented([[0, -1], [1, 1], [2, 1]])

0 commit comments

Comments
 (0)