def test_get_neuroquery_data_dir():
    with tempfile.TemporaryDirectory() as tmp_dir:
        target_dir = str(pathlib.Path(tmp_dir) / "neuroquery_data_1")
        nq_dir = datasets.get_neuroquery_data_dir(target_dir)
        assert nq_dir == target_dir
        assert pathlib.Path(nq_dir).is_dir()
        with mock.patch("os.environ.get", return_value=tmp_dir):
            nq_dir = datasets.get_neuroquery_data_dir()
            assert nq_dir == str(pathlib.Path(tmp_dir) / "neuroquery_data")
            assert pathlib.Path(nq_dir).is_dir()
예제 #2
0
def test_get_neuroquery_data_dir():
    with tempfile.TemporaryDirectory() as tmp_dir:
        target_dir = str(pathlib.Path(tmp_dir) / "neuroquery_data_1")
        nq_dir = datasets.get_neuroquery_data_dir(target_dir)
        assert nq_dir == target_dir
        assert pathlib.Path(nq_dir).is_dir()
        env = {"HOME": tmp_dir}
        with mock.patch("os.environ", env):
            nq_dir = datasets.get_neuroquery_data_dir()
            assert nq_dir == str(pathlib.Path(tmp_dir) / "neuroquery_data")
            assert pathlib.Path(nq_dir).is_dir()
        env_data_dir = str(pathlib.Path(tmp_dir) / "env_data_dir")
        env = {"HOME": tmp_dir, "NEUROQUERY_DATA_DIR": env_data_dir}
        with mock.patch("os.environ", env):
            nq_dir = datasets.get_neuroquery_data_dir()
            assert nq_dir == env_data_dir
            assert pathlib.Path(nq_dir).is_dir()
예제 #3
0
import pathlib

import requests
from neuroquery import datasets

datasets.fetch_neuroquery_model()
datasets.fetch_peak_coordinates()
datasets.fetch_neuroquery_model(model_name="ensemble_model_2020-02-12")
maps_url = "https://osf.io/n5avm/download"
data_dir = datasets.get_neuroquery_data_dir()
extra_data = pathlib.Path(data_dir) / "extra"
extra_data.mkdir(exist_ok=True, parents=True)
maps_file = extra_data / "masked_term_maps.npy"
if not maps_file.is_file():
    print("downloading neuroquery maps...")
    resp = requests.get(maps_url)
    with open(str(maps_file), "wb") as f:
        f.write(resp.content)
    print("done")
    del resp