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
Remove invalid streamlines (out of bbox) #42
Merged
arnaudbore
merged 5 commits into
scilus:master
from
frheault:remove_invalid_streamlines
Sep 17, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6b55a8a
New scripts to remove streamlines that are invalid in vox space
7e7d82b
Changed the script docstring
a8228c9
Merge branch 'master' of https://github.com/scilus/scilpy into remove…
2e65618
Merge branch 'master' of https://github.com/scilus/scilpy into remove…
71cc910
Fix script following master update
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
|
||
from dipy.io.streamline import save_tractogram | ||
|
||
from scilpy.io.utils import (add_overwrite_arg, add_reference, | ||
assert_inputs_exist, assert_outputs_exist, | ||
load_tractogram_with_reference) | ||
|
||
DESCRIPTION = """ | ||
Removal of streamlines that are out of the volume bounding box. In voxel space | ||
no negative coordinate and no above volume dimension coordinate are possible. | ||
Any streamlines that do not respect these two conditions are removed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
""" | ||
|
||
|
||
def _build_args_parser(): | ||
p = argparse.ArgumentParser(description=DESCRIPTION, | ||
formatter_class=argparse.RawTextHelpFormatter) | ||
|
||
p.add_argument('in_tractogram', metavar='IN_TRACTOGRAM', | ||
help='Tractogram filename. Format must be one of \n' | ||
'trk, tck, vtk, fib, dpy.') | ||
|
||
p.add_argument('output_name', metavar='OUTPUT_NAME', | ||
help='Output filename. Format must be one of \n' | ||
'trk, tck, vtk, fib, dpy.') | ||
|
||
add_reference(p) | ||
|
||
add_overwrite_arg(p) | ||
|
||
return p | ||
|
||
|
||
def main(): | ||
parser = _build_args_parser() | ||
args = parser.parse_args() | ||
|
||
assert_inputs_exist(parser, args.in_tractogram, args.reference) | ||
assert_outputs_exist(parser, args, args.output_name) | ||
|
||
sft = load_tractogram_with_reference(parser, args, args.in_tractogram, | ||
bbox_check=False) | ||
sft.remove_invalid_streamlines() | ||
save_tractogram(sft, args.output_name) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should probably go in
scilpy.io.streamlines
.