Alignment check - usage

Usage of the different methods are shown below:

The purpose of checkerboard, voxelwise_diff and color_mix functions in mrivis is to offer different ways of checking alignment between two two given images (either from the same modality or different modalities possibly with different contrast properties).

To use them is simply a matter of importing them e.g. checkerboard, and passing the two images to compare (NOTE: you have to change the values for variables path1 and path2 to valid images on your system):

from mrivis import checkerboard

# REPLACE the paths with actual existing paths on your system
# If you don't have any data, some example data are provided in example_datasets folder of the mrivis repo
path1 = '/folder/image.nii'
path2 = '/folder/another.nii'

checkerboard(path1, path2) # square patches

You could customize them further in various ways using different parameters to fit your needs:

checkerboard(path1, path2, patch_size=5)

checkerboard(path1, path2, rescale_method=(0, 256) )

checkerboard(path1, path2, patch_size=10,
             num_rows=1, num_cols=3) # 1 row per dimension, with 3 columns

checkerboard(path1, path2, patch_size=[10, 20], # rectangular patches
             num_rows=2, # 2 rows per dimension (6 rows in total)
             num_cols=5) # 5 panels per row

You can use the other methods voxelwise_diff and color_mix in a very similar manner:

from mrivis import voxelwise_diff, color_mix

voxelwise_diff(path1, path2)
voxelwise_diff(path1, path2, abs_value=False)

color_mix(path1, path2, alpha_channels=(1, 1))
color_mix(path1, path2, alpha_channels=(0.7, 1))

Comparing two BOLD images

flyer\_haxby\_mean\_BOLD\_subj\_1\_2

Sample outputs for checkerboard plots

When the two scans are mismatched:

vis\_all3

When the mismatch is low (here a smoothed image is comapred to its original), you can see the differences in intensity (due to smoothing), but you can also see that they are both spatially aligned accurately:

flyer2\_low\_mismatch

With really low patch-sizes (e.g. 1, which is voxel-wise alternation), you can see the alignment even better:

vis\_voxelwise\_axial

When there is mismatch, you can clearly see it (patch size 15 voxels square):

vis\_all3\_mismatch\_ps15

Let’s make the patches a bit bigger (patch size 25 voxels square):

_images/vis_all3_mismatch_ps25_axial.png

Let’s make the patches a even bigger (50 voxels square):

vis\_all3\_mismatch\_ps50

Let’s use a rectangular patch (10 voxels high and 30 voxels wide):

_images/vis_all3_mismatch__rect_ps10_30_sagittal.png
_images/vis_all3_mismatch__rect_ps10_30_axial.png

If they were identical (no mismatch at all), you won’t see any edges or borders:

identical

identical

Full layout with 6x6 pangels can be seen in this folder.