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

BF: correct handling of output paths in dipy_quickbundles. #915

Merged
merged 3 commits into from Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/dipy_quickbundles
Expand Up @@ -54,7 +54,7 @@ if __name__ == "__main__":


if params.out_file:
this_split = params.out_file.split('.')
this_split = os.path.splitext(params.out_file)
out_fname_clust = this_split[0] + '_%s'%(c + 1) + '.trk'
else:
out_fname_clust = split[0] + '_%s'%(c + 1) + split[1]
Expand All @@ -63,7 +63,7 @@ if __name__ == "__main__":
trackvis.write(out_fname_clust, new_streamlines, hdr)

if params.out_file:
this_split = params.out_file.split('.')
this_split = os.path.splitext(params.out_file)
out_fname_cent = this_split[0] + '_centroids' + '.trk'
else:
out_fname_cent = split[0] + '_centroids' + split[1]
Expand Down
23 changes: 23 additions & 0 deletions dipy/tests/test_scripts.py
Expand Up @@ -6,6 +6,7 @@
"""
from __future__ import division, print_function, absolute_import

import glob
import os
import shutil

Expand Down Expand Up @@ -121,3 +122,25 @@ def test_qb_commandline():
'--out_file', 'tracks300.trk']
out = run_command(cmd)
assert_equal(out[0], 0)

@nt.dec.skipif(no_mpl)
def test_qb_commandline_output_path_handling():
with InTemporaryDirectory():
# Create temporary subdirectory for input and for output
os.mkdir('work')
os.mkdir('output')

os.chdir('work')
tracks_file = get_data('fornix')

# Need to specify an output directory with a "../" style path
# to trigger old bug.
cmd = ["dipy_quickbundles", tracks_file, '--pkl_file', 'mypickle.pkl',
'--out_file', os.path.join('..', 'output', 'tracks300.trk')]
out = run_command(cmd)
assert_equal(out[0], 0)

# Make sure the files were created in the output directory
os.chdir('../')
output_files_list = glob.glob('output/tracks300_*.trk')
assert_true(output_files_list)