def test_csd_tracking(): for sh_order in [4, 8, 10]: fname = fit_csd(fdata, fbval, fbvec, response=((0.0015, 0.0003, 0.0003), 100), sh_order=8, lambda_=1, tau=0.1, mask=None, out_dir=tmpdir.name) for directions in ["det", "prob"]: sl_serial = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, seeds=seeds, stop_mask=None, stop_threshold=0.2, step_size=0.5, n_jobs=1) npt.assert_equal(sl_serial[0].shape[-1], 3) for engine in ["dask"]: for backend in ["threading"]: sl_parallel = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, seeds=seeds, stop_mask=None, stop_threshold=0.2, step_size=0.5, n_jobs=2, engine=engine, backend=backend) npt.assert_equal(sl_parallel[0].shape[-1], 3) if directions == 'det': npt.assert_almost_equal(sl_parallel[0], sl_serial[0])
def test_fit_csd(): fdata, fbval, fbvec = dpd.get_data('small_64D') with nbtmp.InTemporaryDirectory() as tmpdir: # Convert from npy to txt: bvals = np.load(fbval) bvecs = np.load(fbvec) np.savetxt(op.join(tmpdir, 'bvals.txt'), bvals) np.savetxt(op.join(tmpdir, 'bvecs.txt'), bvecs) for sh_order in [4, 6]: fname = csd.fit_csd(fdata, op.join(tmpdir, 'bvals.txt'), op.join(tmpdir, 'bvecs.txt'), out_dir=tmpdir, sh_order=sh_order) npt.assert_(op.exists(fname)) sh_coeffs_img = nib.load(fname) npt.assert_equal(sh_order, calculate_max_order(sh_coeffs_img.shape[-1]))
def test_csd_tracking(): for sh_order in [4, 8, 10]: fname = fit_csd(fdata, fbval, fbvec, response=((0.0015, 0.0003, 0.0003), 100), sh_order=8, lambda_=1, tau=0.1, mask=None, out_dir=tmpdir.name) for directions in ["det", "prob"]: sl = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, seeds=seeds, stop_mask=None, step_size=0.5) npt.assert_(len(sl[0]) > 10)
def test_csd_tracking(): for sh_order in [4, 8, 10]: fname = fit_csd(fdata, fbval, fbvec, response=((0.0015, 0.0003, 0.0003), 100), sh_order=8, lambda_=1, tau=0.1, mask=None, out_dir=tmpdir.name) for directions in ["det", "prob"]: sl = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, n_seeds=seeds, stop_mask=None, step_size=0.5, min_length=10) npt.assert_(len(sl[0]) > 10)
def test_csd_tracking(): for sh_order in [4, 8, 10]: fname = fit_csd(fdata, fbval, fbvec, response=((0.0015, 0.0003, 0.0003), 100), sh_order=8, lambda_=1, tau=0.1, mask=None, out_dir=tmpdir.name) for directions in ["det", "prob"]: sl_serial = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, seeds=seeds, stop_mask=None, stop_threshold=0.2, step_size=0.5, n_jobs=1, engine="serial") npt.assert_equal(sl_serial[0].shape[-1], 3) for engine in ["dask", "joblib"]: for backend in ["threading"]: sl_parallel = track(fname, directions, max_angle=30., sphere=None, seed_mask=None, seeds=seeds, stop_mask=None, stop_threshold=0.2, step_size=0.5, n_jobs=2, engine=engine, backend=backend) npt.assert_equal(sl_parallel[0].shape[-1], 3) if directions == 'det': npt.assert_almost_equal(sl_parallel[0], sl_serial[0])