@@ -322,6 +322,7 @@ def _create_cifti_image(bold_file, label_file, bold_surfs, annotation_files, tr,
322
322
label_orient = nb .aff2axcodes (label_img .affine )
323
323
if bold_orient != label_orient :
324
324
bold_img = _reorient_image (bold_img , bold_orient , label_orient )
325
+ assert nb .aff2axcodes (bold_img ) == label_orient == tuple ('LAS' )
325
326
326
327
bold_data = bold_img .get_fdata (dtype = 'float32' )
327
328
timepoints = bold_img .shape [3 ]
@@ -443,6 +444,21 @@ def _reorient_image(img, orient_img, orient_target):
443
444
axis direction codes
444
445
orient_target : tuple
445
446
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
+
446
462
"""
447
463
if orient_img == tuple ('RAS' ) and orient_target == tuple ('LAS' ): # RAS -> LAS
448
464
return img .as_reoriented ([[0 , - 1 ], [1 , 1 ], [2 , 1 ]])
0 commit comments