Skip to content

Commit

Permalink
Merge pull request #646 from EmmaRenauld/fix_bbox_score_bundles
Browse files Browse the repository at this point in the history
Add check_bbox_false (only in scil_score_bundles)
  • Loading branch information
arnaudbore authored Nov 9, 2022
2 parents 4714ce3 + 2430b1d commit e838867
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions scripts/scil_score_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def _build_arg_parser():
"file are considered \nas absolute paths.")

g = p.add_argument_group("Preprocessing")
g.add_argument("--remove_invalid", action="store_true",
help="Remove invalid streamlines before scoring.")
g.add_argument("--ignore_invalid", action="store_true",
help="Ignore invalid streamlines in loaded tractograms.")

add_json_args(p)
add_overwrite_arg(p)
Expand All @@ -84,6 +84,7 @@ def _build_arg_parser():


def load_and_verify_everything(parser, args):
bbox_check = False if args.ignore_invalid else True

assert_inputs_exist(parser, [args.gt_config])
if not os.path.isdir(args.bundles_dir):
Expand Down Expand Up @@ -137,7 +138,7 @@ def load_and_verify_everything(parser, args):
for bundle in bundle_names:
vb_name = os.path.join(vb_path, bundle + '_VS.trk')
if os.path.isfile(vb_name):
sft = load_tractogram(vb_name, 'same')
sft = load_tractogram(vb_name, 'same', bbox_valid_check=bbox_check)
vb_sft_list.append(sft)
if ref_sft is None:
ref_sft = sft
Expand All @@ -150,7 +151,7 @@ def load_and_verify_everything(parser, args):
if wpc_path is not None:
logging.info("Loading WPC bundles")
for bundle in glob.glob(wpc_path + '/*'):
sft = load_tractogram(bundle, 'same')
sft = load_tractogram(bundle, 'same', bbox_valid_check=bbox_check)
wpc_sft_list.append(sft)
if ref_sft is None:
ref_sft = sft
Expand All @@ -164,7 +165,7 @@ def load_and_verify_everything(parser, args):
logging.info("Loading invalid bundles")
for bundle in glob.glob(ib_path + '/*'):
ib_names.append(os.path.basename(bundle))
sft = load_tractogram(bundle, 'same')
sft = load_tractogram(bundle, 'same', bbox_valid_check=bbox_check)
ib_sft_list.append(ref_sft)
if ref_sft is None:
ref_sft = sft
Expand All @@ -173,7 +174,8 @@ def load_and_verify_everything(parser, args):

# Load either NC or IS
if nc_filename is not None:
nc_sft = load_tractogram(nc_filename, 'same')
nc_sft = load_tractogram(nc_filename, 'same',
bbox_valid_check=bbox_check)
ref_sft = nc_sft
else:
nc_sft = None
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/test_score_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ def test_score_bundles(script_runner):
json.dump(json_contents, f)

ret = script_runner.run('scil_score_bundles.py',
"config_file.json", "./")
"config_file.json", "./", '--ignore_invalid')

assert ret.success

0 comments on commit e838867

Please sign in to comment.