def test_ALESubtraction_smoke_lowmem(testdata_cbma, tmp_path_factory): """Smoke test for ALESubtraction with low memory settings.""" tmpdir = tmp_path_factory.mktemp("test_ALESubtraction_smoke_lowmem") out_file = os.path.join(tmpdir, "file.pkl.gz") sub_meta = ale.ALESubtraction(n_iters=10, memory_limit="1gb") sub_meta.fit(testdata_cbma, testdata_cbma) assert isinstance(sub_meta.results, nimare.results.MetaResult) assert "z_desc-group1MinusGroup2" in sub_meta.results.maps.keys() assert isinstance( sub_meta.results.get_map("z_desc-group1MinusGroup2", return_type="image"), nib.Nifti1Image ) assert isinstance( sub_meta.results.get_map("z_desc-group1MinusGroup2", return_type="array"), np.ndarray ) sub_meta.save(out_file) assert os.path.isfile(out_file)
def test_ALESubtraction_ma_map_reuse(testdata_cbma, tmp_path_factory, caplog): """Test that MA maps are re-used when appropriate.""" from nimare.meta import kernel tmpdir = tmp_path_factory.mktemp("test_ALESubtraction_ma_map_reuse") testdata_cbma.update_path(tmpdir) # ALEKernel cannot extract sample_size from a Dataset, # so we need to set it for this kernel and for the later meta-analyses. kern = kernel.ALEKernel(sample_size=20) dset = kern.transform(testdata_cbma, return_type="dataset") # The Dataset without the images will generate them from scratch. sub_meta = ale.ALESubtraction(n_iters=10, kernel__sample_size=20) with caplog.at_level(logging.DEBUG, logger="nimare.meta.cbma.base"): sub_meta.fit(testdata_cbma, testdata_cbma) assert "Loading pre-generated MA maps" not in caplog.text # The Dataset with the images will re-use them, # as evidenced by the logger message. with caplog.at_level(logging.DEBUG, logger="nimare.meta.cbma.base"): sub_meta.fit(dset, dset) assert "Loading pre-generated MA maps" in caplog.text