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

Support multiple input to merge (for PR in connectoflow) #761

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions scripts/scil_decompose_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def _build_arg_parser():
p = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description=__doc__)
p.add_argument('in_tractogram',
help='Tractogram filename. Format must be one of \n'
p.add_argument('in_tractograms', nargs='+',
help='Tractogram filenames. Format must be one of \n'
'trk, tck, vtk, fib, dpy.')
p.add_argument('in_labels',
help='Labels file name (nifti). Labels must have 0 as '
Expand Down Expand Up @@ -239,7 +239,7 @@ def main():
parser = _build_arg_parser()
args = parser.parse_args()

assert_inputs_exist(parser, [args.in_tractogram, args.in_labels],
assert_inputs_exist(parser, args.in_tractograms+[args.in_labels],
args.reference)
assert_outputs_exist(parser, args, args.out_hdf5)
nbr_cpu = validate_nbr_processes(parser, args)
Expand Down Expand Up @@ -277,21 +277,25 @@ def main():

logging.info('*** Loading streamlines ***')
time1 = time.time()
sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
sft_merged = None
for in_tractogram in args.in_tractograms:
if sft_merged is None:
sft = load_tractogram_with_reference(parser, args, in_tractogram)
frheault marked this conversation as resolved.
Show resolved Hide resolved
if not is_header_compatible(sft, img_labels):
raise IOError('{} and {}do not have a compatible header'.format(
in_tractogram, args.in_labels))
else:
sft += load_tractogram_with_reference(parser, args, in_tractogram)

# If loaded with invalid (bbox_check False), remove invalid streamlines
# before continuing.
if not args.bbox_check:
sft.remove_invalid_streamlines()

time2 = time.time()
logging.info(' Loading {} streamlines took {} sec.'.format(
len(sft), round(time2 - time1, 2)))

if not is_header_compatible(sft, img_labels):
raise IOError('{} and {}do not have a compatible header'.format(
args.in_tractogram, args.in_labels))

sft.to_vox()
sft.to_corner()
# Get all streamlines intersection indices
Expand Down