Skip to content

Commit

Permalink
Merge pull request #1211 from MRtrix3/interface_name_changes
Browse files Browse the repository at this point in the history
Interface name changes, some user docs updated.
  • Loading branch information
thijsdhollander committed Dec 18, 2017
2 parents 1d50444 + dc91854 commit d9cb4f3
Show file tree
Hide file tree
Showing 898 changed files with 5,527 additions and 5,017 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -37,7 +37,6 @@ after_failure:
- cat memalign.log
- cat configure.log
- cat build.log
- cat pylint.log
- cat testing.log
- cat pylint.log
- cat gitdiff.log
Expand Down
4 changes: 2 additions & 2 deletions bin/dwi2response
Expand Up @@ -81,9 +81,9 @@ app.makeTempDir()

# Get standard input data into the temporary directory
if alg.needsSingleShell() or shells_option:
run.command('mrconvert ' + path.fromUser(app.args.input, True) + ' - -stride 0,0,0,1' + grad_import_option + ' | dwiextract - ' + path.toTemp('dwi.mif', True) + shells_option + singleshell_option)
run.command('mrconvert ' + path.fromUser(app.args.input, True) + ' - -strides 0,0,0,1' + grad_import_option + ' | dwiextract - ' + path.toTemp('dwi.mif', True) + shells_option + singleshell_option)
else: # Don't discard b=0 in multi-shell algorithms
run.command('mrconvert ' + path.fromUser(app.args.input, True) + ' ' + path.toTemp('dwi.mif', True) + ' -stride 0,0,0,1' + grad_import_option)
run.command('mrconvert ' + path.fromUser(app.args.input, True) + ' ' + path.toTemp('dwi.mif', True) + ' -strides 0,0,0,1' + grad_import_option)
if app.args.mask:
run.command('mrconvert ' + path.fromUser(app.args.mask, True) + ' ' + path.toTemp('mask.mif', True) + ' -datatype bit')
else:
Expand Down
6 changes: 3 additions & 3 deletions bin/dwibiascorrect
Expand Up @@ -91,7 +91,7 @@ run.command('dwiextract in.mif - -bzero | mrmath - mean mean_bzero.mif -axis 3')
if app.args.fsl:

# FAST doesn't accept a mask input; therefore need to explicitly mask the input image
run.command('mrcalc mean_bzero.mif mask.mif -mult - | mrconvert - mean_bzero_masked.nii -stride -1,+2,+3')
run.command('mrcalc mean_bzero.mif mask.mif -mult - | mrconvert - mean_bzero_masked.nii -strides -1,+2,+3')
run.command(fast_cmd + ' -t 2 -o fast -n 3 -b mean_bzero_masked.nii')
bias_path = fsl.findImage('fast_bias')

Expand All @@ -105,8 +105,8 @@ elif app.args.ants:

# Use the brain mask as a weights image rather than a mask; means that voxels at the edge of the mask
# will have a smoothly-varying bias field correction applied, rather than multiplying by 1.0 outside the mask
run.command('mrconvert mean_bzero.mif mean_bzero.nii -stride +1,+2,+3')
run.command('mrconvert mask.mif mask.nii -stride +1,+2,+3')
run.command('mrconvert mean_bzero.mif mean_bzero.nii -strides +1,+2,+3')
run.command('mrconvert mask.mif mask.nii -strides +1,+2,+3')
bias_path = 'bias.nii'
run.command('N4BiasFieldCorrection -d 3 -i mean_bzero.nii -w mask.nii -o [corrected.nii,' + bias_path + '] -s 4 -b [100,3] -c [1000,0.0]')

Expand Down
7 changes: 4 additions & 3 deletions bin/dwigradcheck
Expand Up @@ -43,7 +43,7 @@ num_volumes = image_dimensions[3]
app.makeTempDir()

# Make sure the image data can be memory-mapped
run.command('mrconvert ' + app.args.input + ' ' + path.toTemp('data.mif', True) + ' -stride 0,0,0,1 -datatype float32')
run.command('mrconvert ' + app.args.input + ' ' + path.toTemp('data.mif', True) + ' -strides 0,0,0,1 -datatype float32')

if app.args.grad:
shutil.copy(path.fromUser(app.args.grad, False), path.toTemp('grad.b', False))
Expand Down Expand Up @@ -91,15 +91,16 @@ if not len(grad_fsl) == 3 or not len(grad_fsl[0]) == num_volumes:


# Generate a brain mask if we weren't provided with one
# Note that gradient table must be explicitly loaded, since there may not
# be one in the image header (user may be relying on -grad or -fslgrad input options)
if not os.path.exists('mask.mif'):
run.command('dwi2mask data.mif mask.mif -grad grad.b')

# How many tracks are we going to generate?
number_option = ' -select ' + str(app.args.number)


#
# What variations of gradient errors can we conceive?
# What variations of gradient errors can we conceive?

# Done:
# * Has an axis been flipped? (none, 0, 1, 2)
Expand Down
2 changes: 1 addition & 1 deletion bin/dwiintensitynorm
Expand Up @@ -39,7 +39,7 @@ app.cmdline.add_argument('output_dir', help='The output directory containing all
app.cmdline.add_argument('fa_template', help='The output population specific FA template, which is threshold to estimate a white matter mask')
app.cmdline.add_argument('wm_mask', help='The output white matter mask (in template space), used to estimate the median b=0 white matter value for normalisation')
options = app.cmdline.add_argument_group('Options for the dwiintensitynorm script')
options.add_argument('-fa_threshold', default='0.4', help='The threshold applied to the Fractional Anisotropy group template used to derive an approximate white matter mask')
options.add_argument('-fa_threshold', default='0.4', help='The threshold applied to the Fractional Anisotropy group template used to derive an approximate white matter mask (default: 0.4)')
app.parse()

app.args.input_dir = relpath(app.args.input_dir)
Expand Down
12 changes: 6 additions & 6 deletions bin/dwipreproc
Expand Up @@ -733,7 +733,7 @@ if do_topup:


# Do the conversion in preparation for topup
run.command('mrconvert ' + se_epi_path + ' topup_in.nii' + import_se_epi_manual_pe_table_option + ' -stride -1,+2,+3,+4 -export_pe_table topup_datain.txt')
run.command('mrconvert ' + se_epi_path + ' topup_in.nii' + import_se_epi_manual_pe_table_option + ' -strides -1,+2,+3,+4 -export_pe_table topup_datain.txt')
file.delTemporary(se_epi_path)

# Run topup
Expand Down Expand Up @@ -776,9 +776,9 @@ if do_topup:

# Use the initial corrected volumes to derive a brain mask for eddy
if len(applytopup_image_list) == 1:
run.command('dwi2mask ' + applytopup_image_list[0] + ' - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -stride -1,+2,+3')
run.command('dwi2mask ' + applytopup_image_list[0] + ' - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3')
else:
run.command('mrcat ' + ' '.join(applytopup_image_list) + ' - -axis 3 | dwi2mask - - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -stride -1,+2,+3')
run.command('mrcat ' + ' '.join(applytopup_image_list) + ' - -axis 3 | dwi2mask - - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3')

for entry in applytopup_image_list:
file.delTemporary(entry)
Expand All @@ -788,7 +788,7 @@ if do_topup:
else:

# Generate a processing mask for eddy based on the uncorrected input DWIs
run.command('dwi2mask ' + dwi_path + ' - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -stride -1,+2,+3')
run.command('dwi2mask ' + dwi_path + ' - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3')


# Generate the text file containing slice timing / grouping information if necessary
Expand Down Expand Up @@ -827,7 +827,7 @@ eddy_manual_options = (' ' + ' '.join(eddy_manual_options)) if eddy_manual_optio


# Run eddy
run.command('mrconvert ' + dwi_path + import_dwi_pe_table_option + dwi_permute_volumes_pre_eddy_option + ' eddy_in.nii -stride -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt')
run.command('mrconvert ' + dwi_path + import_dwi_pe_table_option + dwi_permute_volumes_pre_eddy_option + ' eddy_in.nii -strides -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt')
file.delTemporary(dwi_path)
run.command(eddy_cmd + ' --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals' + eddy_in_topup_option + eddy_manual_options + ' --out=dwi_post_eddy')
file.delTemporary('eddy_in.nii')
Expand All @@ -838,7 +838,7 @@ eddy_output_image_path = fsl.findImage('dwi_post_eddy')


# Get the axis strides from the input series, so the output image can be modified to match
stride_option = ' -stride ' + ','.join([str(i) for i in dwi_header.stride()])
stride_option = ' -strides ' + ','.join([str(i) for i in dwi_header.strides()])


# Check to see whether or not eddy has provided a rotated bvecs file;
Expand Down
4 changes: 2 additions & 2 deletions bin/dwishellmath
Expand Up @@ -22,10 +22,10 @@ HELP_PAGE
fi

tmpfiles=""
for b in $(mrinfo "$1" -shellvalues);
for b in $(mrinfo "$1" -shell_bvalues);
do
echo "Extracting $2 of the b=$b shell."
tmpfiles="$tmpfiles "$(dwiextract -shell $b "$1" - -quiet | mrmath -axis 3 - $2 - -quiet)
tmpfiles="$tmpfiles "$(dwiextract -shells $b "$1" - -quiet | mrmath -axis 3 - $2 - -quiet)
done
mrcat -axis 3 $tmpfiles "$3" -quiet

Expand Down
6 changes: 3 additions & 3 deletions bin/labelsgmfix
Expand Up @@ -75,9 +75,9 @@ app.makeTempDir()
# Get the parcellation and T1 images into the temporary directory, with conversion of the T1 into the correct format for FSL
run.command('mrconvert ' + path.fromUser(app.args.parc, True) + ' ' + path.toTemp('parc.mif', True))
if upsample_for_first:
run.command('mrresize ' + path.fromUser(app.args.t1, True) + ' - -voxel 1.0 -interp sinc | mrcalc - 0.0 -max - | mrconvert - ' + path.toTemp('T1.nii', True) + ' -stride -1,+2,+3')
run.command('mrresize ' + path.fromUser(app.args.t1, True) + ' - -voxel 1.0 -interp sinc | mrcalc - 0.0 -max - | mrconvert - ' + path.toTemp('T1.nii', True) + ' -strides -1,+2,+3')
else:
run.command('mrconvert ' + path.fromUser(app.args.t1, True) + ' ' + path.toTemp('T1.nii', True) + ' -stride -1,+2,+3')
run.command('mrconvert ' + path.fromUser(app.args.t1, True) + ' ' + path.toTemp('T1.nii', True) + ' -strides -1,+2,+3')

app.gotoTempDir()

Expand Down Expand Up @@ -121,7 +121,7 @@ for key, value in structure_map.items():
mask_list.append(image_path)
vtk_in_path = 'first-' + key + '_first.vtk'
run.command('meshconvert ' + vtk_in_path + ' first-' + key + '_transformed.vtk -transform first2real T1.nii')
run.command('mesh2pve first-' + key + '_transformed.vtk parc.mif - | mrthreshold - ' + image_path + ' -abs 0.5')
run.command('mesh2voxel first-' + key + '_transformed.vtk parc.mif - | mrthreshold - ' + image_path + ' -abs 0.5')
# Add to the SGM image; don't worry about overlap for now
node_index = sgm_lut[value]
run.command('mrcalc ' + image_path + ' ' + node_index + ' sgm.mif -if sgm_new.mif')
Expand Down
13 changes: 5 additions & 8 deletions bin/population_template
Expand Up @@ -43,23 +43,20 @@ try:
except ImportError:
app.console("numpy not found; using replacement functions")
def loadtxt(fname, delimiter=" ", dtype=float):
with open(fname, "r") as f:
return [[dtype(a) for a in l.rstrip().split(delimiter)] for l in f.readlines()]
with open(fname, "rb") as f:
return [[dtype(a) for a in l.decode(errors='ignore').rstrip().split(delimiter)] for l in f.readlines()]

def savetxt(fname, X, delimiter=" ", fmt="%.14e"):
try:
if sys.version_info[0] >= 3:
fh = open(fname, 'wb')
else:
fh = open(fname, 'w')
fh = open(fname, 'wb')
if len(X) == 1:
ncol = 1
else:
ncol = len(X[0])
fmt = [fmt, ] * ncol
row_format = delimiter.join(fmt)
for row in X:
fh.write((row_format % tuple(row) + '\n').encode (errors='ignore'))
fh.write(((row_format % tuple(row) + '\n').encode(errors='ignore')))
finally:
fh.close()

Expand Down Expand Up @@ -212,7 +209,7 @@ if not os.path.exists(inputDir):
app.error('input directory not found')
inFiles = sorted(allindir(inputDir, dir_path=False))
if len(inFiles) <= 1:
app.console('Not enough images found in input directory. More than one image is needed to generate a population template')
app.error('Not enough images found in input directory. More than one image is needed to generate a population template')
else:
app.console('Generating a population-average template from ' + str(len(inFiles)) + ' input images')

Expand Down
9 changes: 5 additions & 4 deletions cmd/5tt2gmwmi.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/5tt2vis.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/5ttcheck.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/5ttedit.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/afdconnectivity.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/amp2response.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/amp2sh.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/connectome2tck.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/connectomestats.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down
9 changes: 5 additions & 4 deletions cmd/dcmedit.cpp
@@ -1,14 +1,15 @@
/* Copyright (c) 2008-2017 the MRtrix3 contributors.
/*
* Copyright (c) 2008-2018 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
* file, you can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* MRtrix3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/.
* For more details, see http://www.mrtrix.org/
*/


Expand Down

0 comments on commit d9cb4f3

Please sign in to comment.