Пример #1
0
def test_flm_reporting(use_method):
    with InTemporaryDirectory():
        shapes, rk = ((7, 8, 7, 15), (7, 8, 7, 16)), 3
        mask, fmri_data, design_matrices = write_fake_fmri_data_and_design(shapes, rk)
        flm = FirstLevelModel(mask_img=mask).fit(
            fmri_data, design_matrices=design_matrices)
        contrast = np.eye(3)[1]
        if use_method:
            report_flm = flm.generate_report(
                contrast, plot_type='glass', height_control=None,
                min_distance=15, alpha=0.001, threshold=2.78)
        else:
            report_flm = glmr.make_glm_report(flm, contrast, plot_type='glass',
                                              height_control=None,
                                              min_distance=15,
                                              alpha=0.001, threshold=2.78,
            )
        '''
        catches & raises UnicodeEncodeError in HTMLDocument.get_iframe()
        Python2's limited unicode support causes  HTMLDocument.get_iframe() to
        mishandle certain unicode characters, like the greek alpha symbol
        and raises this error.
        Calling HTMLDocument.get_iframe() here causes the tests
        to fail on Python2, alerting us if such a situation arises
        due to future modifications.
        '''
        report_iframe = report_flm.get_iframe()
        # So flake8 doesn't complain about not using variable (F841)
        report_iframe
        del mask, flm, fmri_data
Пример #2
0
def test_masking_first_level_model():
    """
    Checks that using NiftiMasker when instantiating
    FirstLevelModel doesn't raise Error when calling
    generate_report().
    """
    with InTemporaryDirectory():
        shapes, rk = ((7, 8, 7, 15), (7, 8, 7, 16)), 3
        mask, fmri_data, design_matrices =\
            write_fake_fmri_data_and_design(shapes, rk)
        masker = NiftiMasker(mask_img=mask)
        masker.fit(fmri_data)
        flm = FirstLevelModel(mask_img=masker).fit(
            fmri_data, design_matrices=design_matrices
        )
        contrast = np.eye(3)[1]

        report_flm = flm.generate_report(
            contrast, plot_type='glass', height_control=None,
            min_distance=15, alpha=0.001, threshold=2.78
        )

        report_iframe = report_flm.get_iframe()
        # So flake8 doesn't complain about not using variable (F841)
        report_iframe

        del mask, flm, fmri_data, masker