diff --git a/nimare/reports/base.py b/nimare/reports/base.py index 317bcf0b3..706459a3a 100644 --- a/nimare/reports/base.py +++ b/nimare/reports/base.py @@ -32,6 +32,7 @@ from nimare.meta.cbma.base import CBMAEstimator, PairwiseCBMAEstimator from nimare.reports.figures import ( + _plot_dof_map, _plot_relcov_map, _plot_ridgeplot, gen_table, @@ -478,12 +479,19 @@ def __init__( ids_ = self.results.estimator.inputs_["id"] x_label = "Z" if key_maps == "z_maps" else "Beta" - _plot_relcov_map( - maps_arr, - self.results.estimator.masker, - self.results.estimator.inputs_["aggressive_mask"], - self.fig_dir / f"preliminary_dset-{dset_i+1}_figure-relcov.png", - ) + if self.results.estimator.aggressive_mask: + _plot_relcov_map( + maps_arr, + self.results.estimator.masker, + self.results.estimator.inputs_["aggressive_mask"], + self.fig_dir / f"preliminary_dset-{dset_i+1}_figure-relcov.png", + ) + else: + dof_map = self.results.get_map("dof") + _plot_dof_map( + dof_map, + self.fig_dir / f"preliminary_dset-{dset_i+1}_figure-dof.png", + ) _plot_ridgeplot( maps_arr, diff --git a/nimare/reports/default.yml b/nimare/reports/default.yml index 5c76fd021..b33d5de10 100644 --- a/nimare/reports/default.yml +++ b/nimare/reports/default.yml @@ -53,6 +53,8 @@ sections: iframe: True - bids: {value: preliminary, dset: 1, suffix: figure-relcov} title: Relative Coverage Map + - bids: {value: preliminary, dset: 1, suffix: figure-dof} + title: DoF Map - bids: {value: preliminary, dset: 1, suffix: figure-ridgeplot} title: Ridge Plot - bids: {value: preliminary, dset: 1, suffix: figure-similarity} diff --git a/nimare/reports/figures.py b/nimare/reports/figures.py index 7c526ca53..791e81db8 100644 --- a/nimare/reports/figures.py +++ b/nimare/reports/figures.py @@ -488,3 +488,31 @@ def _plot_relcov_map(maps_arr, masker, aggressive_mask, out_filename): ) fig.savefig(out_filename, dpi=300) fig.close() + + +def _plot_dof_map(dof_map, out_filename): + """Plot DoF map. + + .. versionadded:: 0.2.1 + + """ + _check_extention(out_filename, [".png", ".pdf", ".svg"]) + + epsilon = 1e-05 + + # Plot coverage map + template = datasets.load_mni152_template(resolution=1) + fig = plot_img( + dof_map, + bg_img=template, + black_bg=False, + draw_cross=False, + threshold=epsilon, + alpha=0.7, + colorbar=True, + cmap="YlOrRd", + vmin=0, + display_mode="mosaic", + ) + fig.savefig(out_filename, dpi=300) + fig.close() diff --git a/nimare/tests/test_reports.py b/nimare/tests/test_reports.py index b52723666..e7785b52a 100644 --- a/nimare/tests/test_reports.py +++ b/nimare/tests/test_reports.py @@ -6,6 +6,7 @@ from nimare.correct import FWECorrector from nimare.diagnostics import FocusCounter, Jackknife from nimare.meta.cbma import ALESubtraction +from nimare.meta.ibma import Stouffers from nimare.reports.base import run_reports from nimare.workflows import CBMAWorkflow, IBMAWorkflow, PairwiseCBMAWorkflow @@ -27,13 +28,11 @@ FocusCounter(voxel_thresh=0.01, display_second_group=True), "pairwise_cbma", ), - ("stouffers", "fdr", "jackknife", "ibma"), ], ) def test_reports_function_smoke( tmp_path_factory, testdata_cbma_full, - testdata_ibma, estimator, corrector, diagnostics, @@ -63,14 +62,26 @@ def test_reports_function_smoke( ) results = workflow.fit(dset1, dset2) - elif meta_type == "ibma": - workflow = IBMAWorkflow( - estimator=estimator, - corrector=corrector, - diagnostics=diagnostics, - output_dir=tmpdir, - ) - results = workflow.fit(testdata_ibma) + run_reports(results, tmpdir) + + filename = "report.html" + outpath = op.join(tmpdir, filename) + assert op.isfile(outpath) + + +@pytest.mark.parametrize("aggressive_mask", [True, False], ids=["aggressive", "liberal"]) +def test_reports_ibma_smoke(tmp_path_factory, testdata_ibma, aggressive_mask): + """Smoke test for IBMA reports.""" + tmpdir = tmp_path_factory.mktemp("test_reports_ibma_smoke") + + workflow = IBMAWorkflow( + estimator=Stouffers(aggressive_mask=aggressive_mask), + corrector="fdr", + diagnostics="jackknife", + voxel_thresh=3.2, + output_dir=tmpdir, + ) + results = workflow.fit(testdata_ibma) run_reports(results, tmpdir)