Skip to content

Commit

Permalink
Verify that reference is always checked
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed Mar 12, 2024
1 parent 36b97ca commit 361b993
Show file tree
Hide file tree
Showing 43 changed files with 57 additions and 48 deletions.
2 changes: 1 addition & 1 deletion scripts/scil_bundle_compute_centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundle)
assert_inputs_exist(parser, args.in_bundle, args.reference)
assert_outputs_exist(parser, args, args.out_centroid)

if args.nb_points < 2:
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_bundle_diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def main():
tmp = args.in_bundles + args.in_labels
args.in_labels = args.in_bundles[(len(tmp) // 2):] + args.in_labels
args.in_bundles = args.in_bundles[0:len(tmp) // 2]
assert_inputs_exist(parser, args.in_bundles+args.in_labels)
assert_inputs_exist(parser, args.in_bundles + args.in_labels,
args.reference)
assert_output_dirs_exist_and_empty(parser, args, [],
optional=args.save_rendering)

Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_bundle_filter_by_occurence.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundles)
assert_inputs_exist(parser, args.in_bundles, args.reference)
output_streamlines_filename = '{}streamlines.trk'.format(
args.output_prefix)
output_voxels_filename = '{}voxels.nii.gz'.format(args.output_prefix)
Expand Down
4 changes: 2 additions & 2 deletions scripts/scil_bundle_generate_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def main():
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

required = [args.in_bundle, args.in_fodf, args.in_mask]
assert_inputs_exist(parser, required)
assert_headers_compatible(parser, required)
assert_inputs_exist(parser, required, args.reference)
assert_headers_compatible(parser, required, reference=args.reference)

out_efod = os.path.join(args.out_dir,
'{0}efod.nii.gz'.format(args.out_prefix))
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_bundle_mean_fixel_afd.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_bundle, args.in_fodf])
assert_inputs_exist(parser, [args.in_bundle, args.in_fodf],
args.reference)
assert_outputs_exist(parser, args, [args.afd_mean_map])

sft = load_tractogram_with_reference(parser, args, args.in_bundle)
Expand Down
6 changes: 3 additions & 3 deletions scripts/scil_bundle_mean_fixel_bingham_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_bundle,
args.in_bingham,
args.in_bingham_metric])
assert_inputs_exist(parser, [args.in_bundle, args.in_bingham,
args.in_bingham_metric],
args.reference)
assert_outputs_exist(parser, args, [args.out_mean_map])

sft = load_tractogram_with_reference(parser, args, args.in_bundle)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_bundle_pairwise_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundles)
assert_inputs_exist(parser, args.in_bundles, args.reference)
assert_outputs_exist(parser, args, [args.out_json])

if args.ratio and not args.single_compare:
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_bundle_score_many_bundles_one_tractogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _build_arg_parser():

def load_and_verify_everything(parser, args):

assert_inputs_exist(parser, [args.gt_config])
assert_inputs_exist(parser, args.gt_config, args.reference)
if not os.path.isdir(args.bundles_dir):
parser.error("Bundles dir ({}) does not exist."
.format(args.bundles_dir))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundles)
assert_inputs_exist(parser, args.in_bundles, args.reference)
assert_outputs_exist(parser, args, args.out_json)

if (not args.streamlines_measures) and (not args.voxels_measures):
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_bundle_shape_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundles)
assert_inputs_exist(parser, args.in_bundles, args.reference)
assert_outputs_exist(parser, args, [], args.out_json)

nbr_cpu = validate_nbr_processes(parser, args)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_clean_qbx_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def keypress_callback(obj, _):
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundles)
assert_inputs_exist(parser, args.in_bundles, args.reference)
assert_outputs_exist(parser, args, [args.out_accepted, args.out_rejected])

if args.out_accepted_dir:
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_header_validate_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_files)
assert_inputs_exist(parser, args.in_files, args.reference)
assert_headers_compatible(parser, args.in_files,
verbose_all_compatible=True,
reference=args.reference)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_lesions_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main():

assert_inputs_exist(parser, [args.in_lesion],
optional=[args.bundle, args.bundle_mask,
args.bundle_labels_map])
args.bundle_labels_map, args.reference])
assert_outputs_exist(parser, args, args.out_json,
optional=[args.out_lesion_stats,
args.out_streamlines_stats])
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_outlier_rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundle)
assert_inputs_exist(parser, args.in_bundle, args.reference)
assert_outputs_exist(parser, args, args.out_bundle, args.remaining_bundle)
if args.alpha <= 0 or args.alpha > 1:
parser.error('--alpha should be ]0, 1]')
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_score_tractogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def load_and_verify_everything(parser, args):
args.json_prefix = os.path.join(args.out_dir, args.json_prefix)
json_outputs = [args.json_prefix + 'processing_stats.json',
args.json_prefix + 'results.json']
assert_inputs_exist(parser, args.gt_config)
assert_inputs_exist(parser, args.gt_config, args.reference)
assert_output_dirs_exist_and_empty(parser, args, args.out_dir,
create_dir=True)
assert_outputs_exist(parser, args, json_outputs)
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_tractogram_apply_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def main():

assert_inputs_exist(parser, [args.in_moving_tractogram,
args.in_target_file,
args.in_transfo], args.in_deformation)
args.in_transfo],
[args.in_deformation, args.reference])
assert_outputs_exist(parser, args, args.out_tractogram)

args.bbox_check = False # Adding manually bbox_check argument.
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_tractogram_apply_transform_to_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def main():
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_hdf5, args.in_target_file,
args.in_transfo], args.in_deformation)
args.in_transfo],
[args.in_deformation, args.reference])
assert_outputs_exist(parser, args, args.out_hdf5)

# HDF5 will not overwrite the file
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_assign_custom_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram,
optional=args.out_colorbar)

Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_assign_uniform_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def main():
if len(args.in_tractograms) > 1 and args.out_tractogram:
parser.error('Using multiple inputs, use --out_suffix.')

assert_inputs_exist(parser, args.in_tractograms)
assert_inputs_exist(parser, args.in_tractograms, args.reference)

if args.out_suffix:
if args.out_tractogram:
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_tractogram_cut_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_tractogram, args.in_mask])
assert_inputs_exist(parser, [args.in_tractogram, args.in_mask],
args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)
assert_headers_compatible(parser, [args.in_tractogram, args.in_mask],
reference=args.reference)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_detect_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram,
optional=args.looping_tractogram)
check_tracts_same_format(parser, [args.in_tractogram, args.out_tractogram,
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_dpp_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():
if args.verbose:
logging.getLogger().setLevel(logging.INFO)

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

# Load the input files.
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_extract_ushape.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram,
optional=args.remaining_tractogram)
check_tracts_same_format(parser, [args.in_tractogram, args.out_tractogram,
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_filter_by_anatomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def main():
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_tractogram, args.in_wmparc],
args.csf_bin)
[args.csf_bin, args.reference])
assert_output_dirs_exist_and_empty(parser, args, args.out_path,
create_dir=True)
assert_headers_compatible(parser, [args.in_tractogram, args.in_wmparc],
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_filter_by_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

if args.minL == 0 and np.isinf(args.maxL):
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_filter_by_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram, args.save_rejected)

if args.min_x == 0 and np.isinf(args.max_x) and \
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_filter_by_roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def main():

# Todo. Prepare now the names of other files (ex, ROI) and verify if
# exist and compatible.
assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram, args.save_rejected)

if overwrite_distance:
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_flip.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractograms)
assert_inputs_exist(parser, args.in_tractograms, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram,
optional=args.save_indices)

Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_print_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)

sft = load_tractogram_with_reference(parser, args, args.in_tractogram)

Expand Down
4 changes: 2 additions & 2 deletions scripts/scil_tractogram_project_map_to_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def main():
parser = _build_arg_parser()
args = parser.parse_args()

assert_inputs_exist(parser, [args.in_tractogram] + args.in_maps)

assert_inputs_exist(parser, [args.in_tractogram] + args.in_maps,
args.reference)
assert_outputs_exist(parser, args, [args.out_tractogram])

if args.verbose:
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_project_streamlines_to_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def main():

# -------- General checks ----------
assert_inputs_exist(parser, [args.in_bundle],
args.load_dps + args.load_dpp)
args.load_dps + args.load_dpp + [args.reference])

# Find all final output files (one per metric).
if args.load_dps or args.load_dpp:
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_qbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, [], optional=args.out_centroids)
assert_output_dirs_exist_and_empty(parser, args,
args.out_clusters_dir,
Expand Down
4 changes: 3 additions & 1 deletion scripts/scil_tractogram_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def main():
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.moving_tractogram,
args.static_tractogram])
args.static_tractogram],
[args.moving_tractogram_ref,
args.static_tractogram_ref])

if args.only_rigid:
matrix_filename = os.path.splitext(args.out_name)[0] + '_rigid.txt'
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def main():
args.streamline_wise_std <= 0):
parser.error('STD needs to be above 0.')

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

logging.info("Loading sft.")
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_resample_nb_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
Expand Down
4 changes: 2 additions & 2 deletions scripts/scil_tractogram_segment_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def main():
args.in_directory, x))]

assert_inputs_exist(parser, args.in_tractograms +
[args.in_config_file,
args.in_transfo])
[args.in_config_file, args.in_transfo],
args.reference)

for in_tractogram in args.in_tractograms:
ext = os.path.splitext(in_tractogram)[1]
Expand Down
3 changes: 2 additions & 1 deletion scripts/scil_tractogram_segment_one_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, [args.in_tractogram, args.in_transfo])
assert_inputs_exist(parser, [args.in_tractogram, args.in_transfo],
args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

wb_file = load_tractogram_with_reference(parser, args, args.in_tractogram)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
assert_outputs_exist(parser, args, args.out_tractogram)

sft = load_tractogram_with_reference(parser, args, args.in_tractogram)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_tractogram)
assert_inputs_exist(parser, args.in_tractogram, args.reference)
_, out_extension = os.path.splitext(args.in_tractogram)

assert_output_dirs_exist_and_empty(parser, args, [], optional=args.out_dir)
Expand Down
2 changes: 1 addition & 1 deletion scripts/scil_tractogram_uniformize_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def main():
args = parser.parse_args()
logging.getLogger().setLevel(logging.getLevelName(args.verbose))

assert_inputs_exist(parser, args.in_bundle)
assert_inputs_exist(parser, args.in_bundle, args.reference)
assert_outputs_exist(parser, args, args.out_bundle)

sft = load_tractogram_with_reference(parser, args, args.in_bundle)
Expand Down
Loading

0 comments on commit 361b993

Please sign in to comment.