Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.
nilearn.image.swap_img_hemispheres¶
- nilearn.image.swap_img_hemispheres(img)[source]¶
Perform swapping of hemispheres in the indicated NIfTI image.
Use case: synchronizing ROIs across hemispheres.
- Parameters:
- imgNiimg-like object
Images to swap (see Input and output: neuroimaging data representation for a detailed description of the valid input types).
- Returns:
Nifti1ImageHemispherically swapped image.
Notes
Assumes that the image is sagitally aligned.
Should be used with caution (confusion might be caused with radio/neuro conventions)
Note that this does not require a change of the affine matrix.
Examples
>>> from nilearn.plotting import plot_stat_map, show >>> from nilearn.datasets import load_sample_motor_activation_image >>> from nilearn.image import swap_img_hemispheres >>> >>> motor_activation_image = load_sample_motor_activation_image() >>> >>> swapped_image = swap_img_hemispheres(motor_activation_image) >>> >>> fig1 = plot_stat_map(motor_activation_image, title="original") >>> fig2 = plot_stat_map( ... swapped_image, title="swapped", cut_coords=fig1.cut_coords ... ) >>> >>> show()