Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphere subdivide #731

Merged
merged 11 commits into from
Aug 17, 2023
7 changes: 5 additions & 2 deletions scripts/scil_compute_local_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def _build_arg_parser():
choices=['det', 'prob', 'eudx'],
help='Algorithm to use. [%(default)s]')
add_sphere_arg(track_g, symmetric_only=True)

track_g.add_argument('--sub_sphere',
type=int, default=0,
help='Subdivides each face of the sphere into 4^s new faces. '
'[%(default)s]')
add_seeding_options(p)
out_g = add_out_options(p)

Expand All @@ -78,7 +81,7 @@ def _build_arg_parser():

def _get_direction_getter(args):
odf_data = nib.load(args.in_odf).get_fdata(dtype=np.float32)
sphere = HemiSphere.from_sphere(get_sphere(args.sphere))
sphere = HemiSphere.from_sphere(get_sphere(args.sphere)).subdivide(args.sub_sphere)
theta = get_theta(args.theta, args.algo)

non_zeros_count = np.count_nonzero(np.sum(odf_data, axis=-1))
Expand Down
15 changes: 15 additions & 0 deletions scripts/tests/test_compute_local_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ def test_execution_tracking_fodf(script_runner):
assert ret.success


def test_execution_sphere_subdivide(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))
in_fodf = os.path.join(get_home(), 'tracking',
'fodf.nii.gz')
in_mask = os.path.join(get_home(), 'tracking',
'seeding_mask.nii.gz')

ret = script_runner.run('scil_compute_local_tracking.py', in_fodf,
in_mask, in_mask, 'local_sphere.trk', '--nt', '1000',
'--compress', '0.1', '--sh_basis', 'descoteaux07',
'--min_length', '20', '--max_length', '200',
'--sub_sphere', '2')
assert ret.success


def test_execution_tracking_fodf_no_compression(script_runner):
os.chdir(os.path.expanduser(tmp_dir.name))
in_fodf = os.path.join(get_home(), 'tracking',
Expand Down