当前位置: 首页>>代码示例>>Python>>正文


Python NiftiMasker.fit_transform方法代码示例

本文整理汇总了Python中nilearn.input_data.nifti_masker.NiftiMasker.fit_transform方法的典型用法代码示例。如果您正苦于以下问题:Python NiftiMasker.fit_transform方法的具体用法?Python NiftiMasker.fit_transform怎么用?Python NiftiMasker.fit_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nilearn.input_data.nifti_masker.NiftiMasker的用法示例。


在下文中一共展示了NiftiMasker.fit_transform方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dtype

# 需要导入模块: from nilearn.input_data.nifti_masker import NiftiMasker [as 别名]
# 或者: from nilearn.input_data.nifti_masker.NiftiMasker import fit_transform [as 别名]
def test_dtype():
    data_32 = np.zeros((9, 9, 9), dtype=np.float32)
    data_64 = np.zeros((9, 9, 9), dtype=np.float64)
    data_32[2:-2, 2:-2, 2:-2] = 10
    data_64[2:-2, 2:-2, 2:-2] = 10

    affine_32 = np.eye(4, dtype=np.float32)
    affine_64 = np.eye(4, dtype=np.float64)

    img_32 = Nifti1Image(data_32, affine_32)
    img_64 = Nifti1Image(data_64, affine_64)

    masker_1 = NiftiMasker(dtype='auto')
    assert(masker_1.fit_transform(img_32).dtype == np.float32)
    assert(masker_1.fit_transform(img_64).dtype == np.float32)

    masker_2 = NiftiMasker(dtype='float64')
    assert(masker_2.fit_transform(img_32).dtype == np.float64)
    assert(masker_2.fit_transform(img_64).dtype == np.float64)
开发者ID:jeromedockes,项目名称:nilearn,代码行数:21,代码来源:test_nifti_masker.py

示例2: test_detrend

# 需要导入模块: from nilearn.input_data.nifti_masker import NiftiMasker [as 别名]
# 或者: from nilearn.input_data.nifti_masker.NiftiMasker import fit_transform [as 别名]
def test_detrend():
    # Check that detrending doesn't do something stupid with 3D images
    data = np.zeros((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    mask = data.astype(np.int)
    mask_img = Nifti1Image(mask, np.eye(4))
    masker = NiftiMasker(mask_img=mask_img, detrend=True)
    # Smoke test the fit
    X = masker.fit_transform(img)
    assert_true(np.any(X != 0))
开发者ID:bcipolli,项目名称:nilearn,代码行数:13,代码来源:test_nifti_masker.py

示例3: test_resample

# 需要导入模块: from nilearn.input_data.nifti_masker import NiftiMasker [as 别名]
# 或者: from nilearn.input_data.nifti_masker.NiftiMasker import fit_transform [as 别名]
def test_resample():
    # Check that target_affine triggers the right resampling
    data = np.zeros((9, 9, 9))
    data[3:-3, 3:-3, 3:-3] = 10
    img = Nifti1Image(data, np.eye(4))
    mask = data.astype(np.int)
    mask_img = Nifti1Image(mask, np.eye(4))
    masker = NiftiMasker(mask_img=mask_img, target_affine=2 * np.eye(3))
    # Smoke test the fit
    X = masker.fit_transform(img)
    assert_true(np.any(X != 0))
开发者ID:jeromedockes,项目名称:nilearn,代码行数:13,代码来源:test_nifti_masker.py

示例4: test_matrix_orientation

# 需要导入模块: from nilearn.input_data.nifti_masker import NiftiMasker [as 别名]
# 或者: from nilearn.input_data.nifti_masker.NiftiMasker import fit_transform [as 别名]
def test_matrix_orientation():
    """Test if processing is performed along the correct axis."""

    # the "step" kind generate heavyside-like signals for each voxel.
    # all signals being identical, standardizing along the wrong axis
    # would leave a null signal. Along the correct axis, the step remains.
    fmri, mask = testing.generate_fake_fmri(shape=(40, 41, 42), kind="step")
    masker = NiftiMasker(mask_img=mask, standardize=True, detrend=True)
    timeseries = masker.fit_transform(fmri)
    assert(timeseries.shape[0] == fmri.shape[3])
    assert(timeseries.shape[1] == mask.get_data().sum())
    std = timeseries.std(axis=0)
    assert(std.shape[0] == timeseries.shape[1])  # paranoid
    assert(not np.any(std < 0.1))

    # Test inverse transform
    masker = NiftiMasker(mask_img=mask, standardize=False, detrend=False)
    masker.fit()
    timeseries = masker.transform(fmri)
    recovered = masker.inverse_transform(timeseries)
    np.testing.assert_array_almost_equal(recovered.get_data(), fmri.get_data())
开发者ID:bcipolli,项目名称:nilearn,代码行数:23,代码来源:test_nifti_masker.py


注:本文中的nilearn.input_data.nifti_masker.NiftiMasker.fit_transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。