Exemplo n.º 1
0
def test_auto_response_msmt():
    gtab, data, _, _ = get_test_data()

    with warnings.catch_warnings(record=True) as w:
        response_auto_wm, response_auto_gm, response_auto_csf = \
            auto_response_msmt(gtab, data, tol=20,
                               roi_center=None, roi_radii=(1, 1, 0),
                               wm_fa_thr=0.7, gm_fa_thr=0.3, csf_fa_thr=0.15,
                               gm_md_thr=0.001, csf_md_thr=0.0032)

        npt.assert_(issubclass(w[0].category, UserWarning))
        npt.assert_("""Some b-values are higher than 1200.
        The DTI fit might be affected. It is advised to use
        mask_for_response_msmt with bvalues lower than 1200, followed by
        response_from_mask_msmt with all bvalues to overcome this."""
                    in str(w[0].message))

        mask_wm, mask_gm, mask_csf = mask_for_response_msmt(gtab, data,
                                                            roi_center=None,
                                                            roi_radii=(1, 1, 0),
                                                            wm_fa_thr=0.7,
                                                            gm_fa_thr=0.3,
                                                            csf_fa_thr=0.15,
                                                            gm_md_thr=0.001,
                                                            csf_md_thr=0.0032)

        response_from_mask_wm, response_from_mask_gm, response_from_mask_csf = \
            response_from_mask_msmt(gtab, data,
                                    mask_wm, mask_gm, mask_csf,
                                    tol=20)

        npt.assert_array_equal(response_auto_wm, response_from_mask_wm)
        npt.assert_array_equal(response_auto_gm, response_from_mask_gm)
        npt.assert_array_equal(response_auto_csf, response_from_mask_csf)
Exemplo n.º 2
0
Then, the ``response_from_mask`` function will return the msmt response
functions using precalculated tissue masks.
"""

response_wm, response_gm, response_csf = response_from_mask_msmt(
    gtab, data, mask_wm, mask_gm, mask_csf)
"""
Note that we can also get directly the response functions by calling the
``auto_response_msmt`` function, which internally calls
``mask_for_response_msmt`` followed by ``response_from_mask``. By doing so, we
don't have access to the masks and we might have problems with high bvalues
tensor fit.
"""

auto_response_wm, auto_response_gm, auto_response_csf = \
    auto_response_msmt(gtab, data, roi_radii=10)
"""
As we can see below, adding the tissue segmentation can change the results
of the response functions.
"""

print("Responses")
print(response_wm)
print(response_gm)
print(response_csf)
print("Auto responses")
print(auto_response_wm)
print(auto_response_gm)
print(auto_response_csf)
"""
At this point, there are two options on how to use those response functions. We