Example #1
0
def test_register_dwi_to_template():
    # Default is syn registration:
    warped_b0, mapping = register_dwi_to_template(subset_dwi_data, gtab,
                                                  template=subset_t2_img,
                                                  level_iters=[5, 5, 5],
                                                  sigma_diff=2.0,
                                                  radius=1)
    npt.assert_(isinstance(mapping, DiffeomorphicMap))
    npt.assert_equal(warped_b0.shape, subset_t2_img.shape)

    # Use affine registration (+ don't provide a template and inputs as
    # strings):
    fdata, fbval, fbvec = dpd.get_fnames('small_64D')
    warped_data, affine_mat = register_dwi_to_template(fdata, (fbval, fbvec),
                                                       reg_method="aff",
                                                       level_iters=[5, 5, 5],
                                                       sigmas=[3, 1, 0],
                                                       factors=[4, 2, 1])
    npt.assert_(isinstance(affine_mat, np.ndarray))
    npt.assert_(affine_mat.shape == (4, 4))
Example #2
0
"""
"""
Alternatively, you can also use the `register_dwi_to_template` function that
needs to also know about the gradient table of the DWI data, provided as a
tuple of (bvals_file, bvecs_file). In this case, we are going to move the
diffusion data to the B0 image (the opposite of the previous examples), which
reverses what is the "moving" image and what is "static".

"""

xformed_dwi, reg_affine = register_dwi_to_template(
    dwi=static_img,
    gtab=(pjoin(folder, 'HARDI150.bval'), pjoin(folder, 'HARDI150.bvec')),
    template=moving_img,
    reg_method="aff",
    nbins=32,
    metric='MI',
    pipeline=pipeline,
    level_iters=level_iters,
    sigmas=sigmas,
    factors=factors)

regtools.overlay_slices(moving, xformed_dwi, None, 0, "Static", "Transformed",
                        "xformed_dwi_0.png")
regtools.overlay_slices(moving, xformed_dwi, None, 1, "Static", "Transformed",
                        "xformed_dwi_1.png")
regtools.overlay_slices(moving, xformed_dwi, None, 2, "Static", "Transformed",
                        "xformed_dwi_2.png")
"""

.. figure:: xformed_dwi_0.png