Skip to content

Commit

Permalink
-stride --> -strides
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsdhollander committed Dec 5, 2017
1 parent 97f7285 commit 2258b08
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 49 deletions.
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
2 changes: 1 addition & 1 deletion 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
8 changes: 4 additions & 4 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 @@ -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.stride()])


# Check to see whether or not eddy has provided a rotated bvecs file;
Expand Down
4 changes: 2 additions & 2 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
10 changes: 5 additions & 5 deletions cmd/mrinfo.cpp
Expand Up @@ -76,7 +76,7 @@ void usage ()
+ Option ("size", "image size along each axis")
+ Option ("spacing", "voxel spacing along each image dimension")
+ Option ("datatype", "data type used for image data storage")
+ Option ("stride", "data strides i.e. order and direction of axes data layout")
+ Option ("strides", "data strides i.e. order and direction of axes data layout")
+ Option ("offset", "image intensity offset")
+ Option ("multiplier", "image intensity multiplier")
+ Option ("transform", "the voxel to image transformation")
Expand Down Expand Up @@ -236,7 +236,7 @@ void header2json (const Header& header, nlohmann::json& json)
json["spacing"] = spacing;
vector<ssize_t> strides (Stride::get (header));
Stride::symbolise (strides);
json["stride"] = strides;
json["strides"] = strides;
json["format"] = header.format();
json["datatype"] = header.datatype().specifier();
json["intensity_offset"] = header.intensity_offset();
Expand Down Expand Up @@ -278,7 +278,7 @@ void run ()
const bool size = get_options("size") .size();
const bool spacing = get_options("spacing") .size();
const bool datatype = get_options("datatype") .size();
const bool stride = get_options("stride") .size();
const bool strides = get_options("strides") .size();
const bool offset = get_options("offset") .size();
const bool multiplier = get_options("multiplier") .size();
const auto properties = get_options("property");
Expand All @@ -289,7 +289,7 @@ void run ()
const bool raw_dwgrad = get_options("raw_dwgrad") .size();
const bool petable = get_options("petable") .size();

const bool print_full_header = !(format || ndim || size || spacing || datatype || stride ||
const bool print_full_header = !(format || ndim || size || spacing || datatype || strides ||
offset || multiplier || properties.size() || transform ||
dwgrad || export_grad || shellvalues || shellcounts || export_pe || petable ||
json_keyval || json_all);
Expand All @@ -306,7 +306,7 @@ void run ()
if (size) print_dimensions (header);
if (spacing) print_spacing (header);
if (datatype) std::cout << (header.datatype().specifier() ? header.datatype().specifier() : "invalid") << "\n";
if (stride) print_strides (header);
if (strides) print_strides (header);
if (offset) std::cout << header.intensity_offset() << "\n";
if (multiplier) std::cout << header.intensity_scale() << "\n";
if (transform) print_transform (header);
Expand Down
6 changes: 3 additions & 3 deletions core/stride.cpp
Expand Up @@ -23,7 +23,7 @@ namespace MR
using namespace App;

const OptionGroup Options = OptionGroup ("Stride options")
+ Option ("stride",
+ Option ("strides",
"specify the strides of the output data in memory, as a comma-separated list. "
"The actual strides produced will depend on whether the output image "
"format can support it.")
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace MR


if (strides.size() > current.size())
WARN ("too many axes supplied to -stride option - ignoring remaining strides");
WARN ("too many axes supplied to -strides option - ignoring remaining strides");
strides.resize (current.size(), 0);

for (const auto x : strides)
Expand All @@ -95,7 +95,7 @@ namespace MR
if (!strides[1]) continue;
for (size_t j = i+1; j < strides.size(); ++j)
if (std::abs (strides[i]) == std::abs (strides[j]))
throw Exception ("duplicate entries provided to \"-stride\" option: " + str(opt[0][0]));
throw Exception ("duplicate entries provided to \"-strides\" option: " + str(opt[0][0]));
}

List prev = get_symbolic (current);
Expand Down
10 changes: 5 additions & 5 deletions docs/getting_started/image_data.rst
Expand Up @@ -284,17 +284,17 @@ for applications that need to process all values for a given voxel
concurrently (as is often the case in diffusion MRI), by allowing the hardware
to make better use of resources (tractography is one such example).

Many *MRtrix3* commands accept the ``-stride`` option, which is used to specify
Many *MRtrix3* commands accept the ``-strides`` option, which is used to specify
the strides for the output image. For example, to generate a LAS (radiological)
NIfTI image for use with FSL (along with the corresponding bvecs/bvals), you
can use :ref:`mrconvert` along with the ``-stride -1,2,3,4`` option::
can use :ref:`mrconvert` along with the ``-strides -1,2,3,4`` option::

$ mrconvert dwi.mif -stride -1,2,3,4 -export_grad_fsl bvecs bvals dwi.nii
$ mrconvert dwi.mif -strides -1,2,3,4 -export_grad_fsl bvecs bvals dwi.nii

Likewise, if you need to ensure the orientation is neurological (RAS), you can
specify strides ``1,2,3,4`` (or use the ``1:4`` shorthand). You can also specify
other combinations if required: for example ``-stride -2,-1,3,4`` would
correspond to a PLS coordinate system, ``-stride 2,3,4,1`` would correspond to
other combinations if required: for example ``-strides -2,-1,3,4`` would
correspond to a PLS coordinate system, ``-strides 2,3,4,1`` would correspond to
volume-contiguous storage (with RAS for the spatial axes), etc.

The different formats supported by *MRtrix3* differ in the range of strides
Expand Down
Expand Up @@ -95,7 +95,7 @@ Diffusion image processing
in memory for each voxel, and convert to floating-point representation
(makes data access faster in subsequent commands):

``mrconvert data.nii.gz DWI.mif -fslgrad bvecs bvals -datatype float32 -stride 0,0,0,1``
``mrconvert data.nii.gz DWI.mif -fslgrad bvecs bvals -datatype float32 -strides 0,0,0,1``

2. Generate a mean *b*\ =0 image (useful for visualisation):

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/amp2sh.rst
Expand Up @@ -55,7 +55,7 @@ DW shell selection options
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwi2fod.rst
Expand Up @@ -66,7 +66,7 @@ Options for the Constrained Spherical Deconvolution algorithm
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/dwiextract.rst
Expand Up @@ -56,7 +56,7 @@ Options for selecting volumes based on phase-encoding
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/maskfilter.rst
Expand Up @@ -56,7 +56,7 @@ Options for median filter
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/mrconvert.rst
Expand Up @@ -70,7 +70,7 @@ Options to modify generic header entries
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Data type options
^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/mrfilter.rst
Expand Up @@ -73,7 +73,7 @@ Options for smooth filter
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/mrinfo.rst
Expand Up @@ -41,7 +41,7 @@ Options

- **-datatype** data type used for image data storage

- **-stride** data strides i.e. order and direction of axes data layout
- **-strides** data strides i.e. order and direction of axes data layout

- **-offset** image intensity offset

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/sh2amp.rst
Expand Up @@ -29,7 +29,7 @@ Options
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Data type options
^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/commands/shconv.rst
Expand Up @@ -27,7 +27,7 @@ Options
Stride options
^^^^^^^^^^^^^^

- **-stride spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.
- **-strides spec** specify the strides of the output data in memory, as a comma-separated list. The actual strides produced will depend on whether the output image format can support it.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
8 changes: 4 additions & 4 deletions lib/mrtrix3/_5ttgen/fsl.py
Expand Up @@ -24,11 +24,11 @@ def getInputs(): #pylint: disable=unused-variable
image.check3DNonunity(path.fromUser(app.args.input, False))
run.command('mrconvert ' + path.fromUser(app.args.input, True) + ' ' + path.toTemp('input.mif', True))
if app.args.mask:
run.command('mrconvert ' + path.fromUser(app.args.mask, True) + ' ' + path.toTemp('mask.mif', True) + ' -datatype bit -stride -1,+2,+3')
run.command('mrconvert ' + path.fromUser(app.args.mask, True) + ' ' + path.toTemp('mask.mif', True) + ' -datatype bit -strides -1,+2,+3')
if app.args.t2:
if not image.match(app.args.input, app.args.t2):
app.error('Provided T2 image does not match input T1 image')
run.command('mrconvert ' + path.fromUser(app.args.t2, True) + ' ' + path.toTemp('T2.nii', True) + ' -stride -1,+2,+3')
run.command('mrconvert ' + path.fromUser(app.args.t2, True) + ' ' + path.toTemp('T2.nii', True) + ' -strides -1,+2,+3')



Expand Down Expand Up @@ -68,7 +68,7 @@ def execute(): #pylint: disable=unused-variable
'retaining the original higher resolution of the T1 image is preferable')
upsample_for_first = True

run.command('mrconvert input.mif T1.nii -stride -1,+2,+3')
run.command('mrconvert input.mif T1.nii -strides -1,+2,+3')

fast_t1_input = 'T1.nii'
fast_t2_input = ''
Expand Down Expand Up @@ -206,7 +206,7 @@ def execute(): #pylint: disable=unused-variable
run.command('mrcalc ' + fast_gm_output + ' multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult cgm.mif')
run.command('mrcalc ' + fast_wm_output + ' multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult wm.mif')
run.command('mrcalc 0 wm.mif -min path.mif')
run.command('mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - combined_precrop.mif -stride +2,+3,+4,+1')
run.command('mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - combined_precrop.mif -strides +2,+3,+4,+1')

# Use mrcrop to reduce file size (improves caching of image data during tracking)
if app.args.nocrop:
Expand Down
2 changes: 1 addition & 1 deletion lib/mrtrix3/dwi2response/manual.py
Expand Up @@ -23,7 +23,7 @@ def getInputs(): #pylint: disable=unused-variable
os.remove(mask_path)
run.command('mrconvert ' + path.fromUser(app.args.in_voxels, True) + ' ' + path.toTemp('in_voxels.mif', True))
if app.args.dirs:
run.command('mrconvert ' + path.fromUser(app.args.dirs, True) + ' ' + path.toTemp('dirs.mif', True) + ' -stride 0,0,0,1')
run.command('mrconvert ' + path.fromUser(app.args.dirs, True) + ' ' + path.toTemp('dirs.mif', True) + ' -strides 0,0,0,1')



Expand Down
2 changes: 1 addition & 1 deletion lib/mrtrix3/dwi2response/msmt_5tt.py
Expand Up @@ -26,7 +26,7 @@ def getInputs(): #pylint: disable=unused-variable
from mrtrix3 import app, path, run
run.command('mrconvert ' + path.fromUser(app.args.in_5tt, True) + ' ' + path.toTemp('5tt.mif', True))
if app.args.dirs:
run.command('mrconvert ' + path.fromUser(app.args.dirs, True) + ' ' + path.toTemp('dirs.mif', True) + ' -stride 0,0,0,1')
run.command('mrconvert ' + path.fromUser(app.args.dirs, True) + ' ' + path.toTemp('dirs.mif', True) + ' -strides 0,0,0,1')



Expand Down
6 changes: 3 additions & 3 deletions lib/mrtrix3/image.py
Expand Up @@ -27,7 +27,7 @@ def __init__(self, image_path):
self._name = data['name']
self._size = data['size']
self._spacing = data['spacing']
self._stride = data['stride']
self._strides = data['strides']
self._format = data['format']
self._datatype = data['datatype']
self._intensity_offset = data['intensity_offset']
Expand All @@ -47,8 +47,8 @@ def size(self):
return self._size
def spacing(self):
return self._spacing
def stride(self):
return self._stride
def strides(self):
return self._strides
def format(self):
return self._format
def datatype(self):
Expand Down

0 comments on commit 2258b08

Please sign in to comment.