Skip to content

Commit

Permalink
Fix for pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentBeaud committed Sep 10, 2024
1 parent c0c5a9f commit 0b8d327
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 137 deletions.
112 changes: 0 additions & 112 deletions scripts/scil_ft_fibers_metrics.py

This file was deleted.

41 changes: 22 additions & 19 deletions scripts/scil_ft_reconstruction_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def _build_arg_parser():
formatter_class=argparse.RawTextHelpFormatter)

p.add_argument('in_fibertubes',
help='Path to the tractogram file containing the \n'
'fibertubes with their respective diameter saved \n'
'data_per_streamline (must be .trk). \n'
'The fibertubes must be void of any collision \n'
'(see scil_filter_intersections.py). \n')
help='Path to the tractogram file containing the \n'
'fibertubes with their respective diameter saved \n'
'data_per_streamline (must be .trk). \n'
'The fibertubes must be void of any collision \n'
'(see scil_filter_intersections.py). \n')

p.add_argument('in_tractogram',
help='Path to a text file containing the ground-truth \n'
Expand Down Expand Up @@ -134,22 +134,29 @@ def main():
our_origin = Origin('center')

logging.debug('Loading centerline tractogram & diameters')
truth_sft = load_tractogram(args.in_fibertubes, 'same', our_space, our_origin)
truth_sft = load_tractogram(args.in_fibertubes, 'same', our_space,
our_origin)
centerlines = truth_sft.get_streamlines_copy()
centerlines, centerlines_length = get_streamlines_as_fixed_array(centerlines)
centerlines, centerlines_length = get_streamlines_as_fixed_array(
centerlines)

if "diameters" not in truth_sft.data_per_streamline:
parser.error('No diameters found as data per streamline on ' + args.in_fibertubes)
diameters = np.reshape(truth_sft.data_per_streamline['diameters'], len(centerlines))
parser.error('No diameters found as data per streamline on ' +
args.in_fibertubes)
diameters = np.reshape(truth_sft.data_per_streamline['diameters'],
len(centerlines))

logging.debug('Loading reconstructed tractogram')
in_sft = load_tractogram(args.in_tractogram, 'same', our_space, our_origin)
in_sft = load_tractogram(args.in_tractogram, 'same', our_space,
our_origin)
streamlines = in_sft.get_streamlines_copy()
streamlines, streamlines_length = get_streamlines_as_fixed_array(streamlines)
streamlines, streamlines_length = get_streamlines_as_fixed_array(
streamlines)

logging.debug("Loading seeds")
if "seeds" not in in_sft.data_per_streamline:
parser.error('No seeds found as data per streamline on ' + args.in_tractogram)
parser.error('No seeds found as data per streamline on ' +
args.in_tractogram)

seeds = in_sft.data_per_streamline['seeds']
seeds_fiber = resolve_origin_seeding(seeds, centerlines, diameters)
Expand All @@ -176,13 +183,9 @@ def main():
seeds_fiber, rand_gen)

logging.debug("Computing reconstruction error")
(mean_errors,
error_tractogram) = mean_reconstruction_error(centerlines, centerlines_length,
diameters,
streamlines,
streamlines_length,
seeds_fiber,
args.save_error_tractogram)
(mean_errors, error_tractogram) = mean_reconstruction_error(
centerlines, centerlines_length, diameters, streamlines,
streamlines_length, seeds_fiber, args.save_error_tractogram)

metrics = {
'truth_vc_ratio': len(truth_vc)/len(streamlines),
Expand Down
5 changes: 3 additions & 2 deletions scripts/scil_ft_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _build_arg_parser():
'Note that points obtained after an invalid direction \n'
'(based on the propagator\'s definition of invalid) \n'
'are never added.')

seed_group = p.add_argument_group(
'Seeding options',
'When no option is provided, uses --nb_seeds_per_fiber 5.')
Expand Down Expand Up @@ -198,7 +198,8 @@ def main():
logging.debug('Loading tractogram & diameters')
in_sft = load_tractogram(args.in_fibertubes, 'same', our_space, our_origin)
centerlines = list(in_sft.get_streamlines_copy())
diameters = np.reshape(in_sft.data_per_streamline['diameters'], len(centerlines))
diameters = np.reshape(in_sft.data_per_streamline['diameters'],
len(centerlines))

logging.debug("Instantiating datavolumes")
fake_mask_data = np.ones(in_sft.dimensions)
Expand Down
4 changes: 2 additions & 2 deletions scripts/scil_ft_visualize_collisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main():
"(must be trk): {0}".format(args.invalid))

invalid_sft = load_tractogram(args.invalid, 'same',
bbox_valid_check=False)
bbox_valid_check=False)
invalid_sft.to_voxmm()
invalid_sft.to_center()

Expand All @@ -94,7 +94,7 @@ def main():
# Make display objects and add them to canvas
s = window.Scene()
invalid_actor = actor.line(invalid_sft.streamlines,
colors=[1., 0., 0.])
colors=[1., 0., 0.])
s.add(invalid_actor)

if (args.obstacle):
Expand Down
3 changes: 1 addition & 2 deletions scripts/scil_tractogram_filter_collisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def main():
streamlines = streamlines[indexes]
diameters = diameters[indexes]
in_sft = StatefulTractogram.from_sft(streamlines, in_sft)

# Casting ArraySequence as a list to improve speed
streamlines = list(streamlines[indexes])

Expand Down Expand Up @@ -256,6 +256,5 @@ def main():
max_voxel_rotated_transform)



if __name__ == "__main__":
main()

0 comments on commit 0b8d327

Please sign in to comment.