Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frheault committed Feb 4, 2025
1 parent dba593f commit 23d65e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions scripts/scil_bundle_label_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def main():
optional=args.reference)
assert_output_dirs_exist_and_empty(parser, args, args.out_dir)

if args.streamlines_thr < 0:
parser.error('streamlines_thr must be greater than 0.')
if args.streamlines_thr is not None and args.streamlines_thr < 1:
parser.error('streamlines_thr must be greater than 1.')

if args.correlation_thr < 1:
parser.error('correlation_thr must be greater than 1.')
if args.correlation_thr < 0:
parser.error('correlation_thr must be greater than 0')

sft_centroid = load_tractogram_with_reference(parser, args,
args.in_centroid)
Expand Down Expand Up @@ -264,7 +264,6 @@ def main():
logging.debug(
f'Chop bundle(s) in {round(time.time() - timer, 3)} seconds.')

# Here
method = 'hyperplane' if args.hyperplane else 'centerline'
args.nb_pts = len(sft_centroid.streamlines[0]) if args.nb_pts is None \
else args.nb_pts
Expand All @@ -281,17 +280,16 @@ def main():
ratio = count[1] / np.sum(count[1:])

# 0.9 is arbitrary, but we want a vast majority of the voxels to be
# contiguous, otherwise it is a weird bundle
# contiguous, otherwise it is a weird bundle so we recompute the labels
# using the centerline method.
print(len(unique), ratio)
if len(unique) > 2 and ratio < 0.9:
binary_mask = np.max(binary_list, axis=0)
labels_map = subdivide_bundles(concat_sft, sft_centroid, binary_mask,
args.nb_pts, method='centerline',
fix_jumps=False)
logging.warning('Warning: Some labels were not contiguous. '
'Recomputing labels to centerline method.')
else:
raise ValueError('Labels are not contiguous after subdivision. '
'Please check the input data.')

timer = time.time()
distance_map = compute_distance_map(labels_map, binary_mask, args.nb_pts,
Expand Down
6 changes: 3 additions & 3 deletions scripts/tests/test_bundle_label_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def test_help_option(script_runner):
ret = script_runner.run('scil_compute_bundle_voxel_label_map.py', '--help')
ret = script_runner.run('scil_bundle_label_map.py', '--help')
assert ret.success


Expand All @@ -24,7 +24,7 @@ def test_execution_tractometry_euclidian(script_runner):
'IFGWM.trk')
in_centroid = os.path.join(SCILPY_HOME, 'tractometry',
'IFGWM_uni_c_10.trk')
ret = script_runner.run('scil_compute_bundle_voxel_label_map.py',
ret = script_runner.run('scil_bundle_label_map.py',
in_bundle, in_centroid,
'results_euc/',
'--colormap', 'viridis')
Expand All @@ -37,7 +37,7 @@ def test_execution_tractometry_hyperplane(script_runner):
'IFGWM.trk')
in_centroid = os.path.join(SCILPY_HOME, 'tractometry',
'IFGWM_uni_c_10.trk')
ret = script_runner.run('scil_compute_bundle_voxel_label_map.py',
ret = script_runner.run('scil_bundle_label_map.py',
in_bundle, in_centroid,
'results_man/',
'--colormap', 'viridis',
Expand Down

0 comments on commit 23d65e5

Please sign in to comment.