Skip to content

Commit afe3de4

Browse files
authored
Merge branch 'master' into dev
2 parents 741dba3 + 816a9fc commit afe3de4

File tree

17 files changed

+93
-64
lines changed

17 files changed

+93
-64
lines changed

bin/dwifslpreproc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def execute(): #pylint: disable=unused-variable
12031203
# Also grab any files generated by the eddy qc tool QUAD
12041204
if os.path.isdir('dwi_post_eddy.qc'):
12051205
if app.FORCE_OVERWRITE and os.path.exists(os.path.join(eddyqc_path, 'quad')):
1206-
run.function(shutil.rmtree(os.path.join(eddyqc_path, 'quad')))
1206+
run.function(shutil.rmtree, os.path.join(eddyqc_path, 'quad'))
12071207
run.function(shutil.copytree, 'dwi_post_eddy.qc', os.path.join(eddyqc_path, 'quad'))
12081208
# Also grab the brain mask that was provided to eddy if -eddyqc_all was specified
12091209
if app.ARGS.eddyqc_all:

cmd/mrconvert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void usage ()
6363
+ "The -vox option is used to change the size of the voxels in the output "
6464
"image as reported in the image header; note however that this does not "
6565
"re-sample the image based on a new voxel size (that is done using the "
66-
"mrresize command)."
66+
"mrgrid command)."
6767

6868
+ "By default, the intensity scaling parameters in the input image header "
6969
"are passed through to the output image header when writing to an integer "

cmd/mrthreshold.cpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ default_type calculate (Image<value_type>& in,
200200
const default_type percentile,
201201
const ssize_t bottom,
202202
const ssize_t top,
203-
const bool ignore_zero,
204-
const bool to_cout)
203+
const bool ignore_zero)
205204
{
206205
if (std::isfinite (abs)) {
207206

@@ -249,9 +248,6 @@ default_type calculate (Image<value_type>& in,
249248

250249
} else { // No explicit mechanism option: do automatic thresholding
251250

252-
std::unique_ptr<LogLevelLatch> latch;
253-
if (to_cout)
254-
latch.reset (new LogLevelLatch (App::log_level - 1));
255251
if (max_axis < in.ndim()) {
256252

257253
// Need to extract just the current 3D volume
@@ -302,14 +298,8 @@ void apply (Image<value_type>& in,
302298
const size_t max_axis,
303299
const value_type threshold,
304300
const operator_type comp,
305-
const bool mask_out,
306-
const bool to_cout)
301+
const bool mask_out)
307302
{
308-
if (to_cout) {
309-
std::cout << threshold;
310-
return;
311-
}
312-
313303
const T true_value = std::is_floating_point<T>::value ? 1.0 : true;
314304
const T false_value = std::is_floating_point<T>::value ? NaN : false;
315305

@@ -335,7 +325,9 @@ void apply (Image<value_type>& in,
335325

336326

337327

338-
328+
// TODO Don't write directly to std::cout;
329+
// will get hidden by /r of progress bar
330+
// Alternatively, withhold progress bar if writing to std::cout
339331
template <typename T>
340332
void execute (Image<value_type>& in,
341333
Image<bool>& mask,
@@ -363,19 +355,27 @@ void execute (Image<value_type>& in,
363355

364356
// Do one volume at a time
365357
// If writing to cout, also add a newline between each volume
366-
bool is_first_loop = true;
367-
for (auto l = Loop("Determining and applying per-volume thresholds", 3, in.ndim()) (in); l; ++l) {
368-
if (to_cout) {
358+
if (to_cout) {
359+
LogLevelLatch latch (App::log_level - 1);
360+
bool is_first_loop = true;
361+
for (auto l = Loop(3, in.ndim()) (in); l; ++l) {
369362
if (is_first_loop)
370363
is_first_loop = false;
371364
else
372365
std::cout << "\n";
366+
const default_type threshold = calculate (in, mask, 3, abs, percentile, bottom, top, ignore_zero);
367+
std::cout << threshold;
373368
}
374-
LogLevelLatch latch (App::log_level - 1);
375-
const default_type threshold = calculate (in, mask, 3, abs, percentile, bottom, top, ignore_zero, to_cout);
376-
if (out.valid())
369+
370+
} else {
371+
372+
for (auto l = Loop("Determining and applying per-volume thresholds", 3, in.ndim()) (in); l; ++l) {
373+
LogLevelLatch latch (App::log_level - 1);
374+
const default_type threshold = calculate (in, mask, 3, abs, percentile, bottom, top, ignore_zero);
377375
assign_pos_of (in, 3).to (out);
378-
apply (in, mask, out, 3, value_type(threshold), op, mask_out, to_cout);
376+
apply (in, mask, out, 3, value_type(threshold), op, mask_out);
377+
}
378+
379379
}
380380

381381
return;
@@ -385,8 +385,11 @@ void execute (Image<value_type>& in,
385385
}
386386

387387
// Process whole input image as a single block
388-
const default_type threshold = calculate (in, mask, in.ndim(), abs, percentile, bottom, top, ignore_zero, to_cout);
389-
apply (in, mask, out, in.ndim(), value_type(threshold), op, mask_out, to_cout);
388+
const default_type threshold = calculate (in, mask, in.ndim(), abs, percentile, bottom, top, ignore_zero);
389+
if (to_cout)
390+
std::cout << threshold;
391+
else
392+
apply (in, mask, out, in.ndim(), value_type(threshold), op, mask_out);
390393

391394
}
392395

core/dwi/gradient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ namespace MR
288288
// write the scheme as interpreted back into the header if:
289289
// - vector normalisation effect is large, regardless of whether or not b-value scaling was applied
290290
// - gradient information was pulled from file
291-
if (exceeds_single_precision || get_options ("grad").size() || get_options ("fslgrad").size())
291+
// - explicit b-value scaling is requested
292+
if (exceeds_single_precision || get_options ("grad").size() || get_options ("fslgrad").size() || bvalue_scaling != BValueScalingBehaviour::Auto)
292293
set_DW_scheme (const_cast<Header&> (header), grad);
293294

294295
INFO ("found " + str (grad.rows()) + "x" + str (grad.cols()) + " diffusion gradient table");

docs/fixel_based_analysis/mt_fibre_density_cross-section.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ There is however no strict requirement for the final set of response functions t
6464
^^^^^^^^^^^^^^^^^^^^^^^
6565
Upsampling DWI data *before* computing FODs increases anatomical contrast and improves downstream template building, registration, tractography and statistics. We recommend upsampling to an isotropic voxel size of 1.25 mm for human brains (if your original resolution is already higher, you can skip this step)::
6666

67-
for_each * : mrresize IN/dwi_denoised_unringed_preproc_unbiased.mif -vox 1.25 IN/dwi_denoised_unringed_preproc_unbiased_upsampled.mif
67+
for_each * : mrgrid IN/dwi_denoised_unringed_preproc_unbiased.mif regrid -vox 1.25 IN/dwi_denoised_unringed_preproc_unbiased_upsampled.mif
6868

6969

7070
6. Compute upsampled brain mask images

docs/fixel_based_analysis/st_fibre_density_cross-section.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ There is however no strict requirement for the (one) final response function to
107107
^^^^^^^^^^^^^^^^^^^^^^^
108108
Upsampling DWI data *before* computing FODs can increase anatomical contrast and improve downstream template building, registration, tractography and statistics. We recommend upsampling to an isotropic voxel size of 1.25 mm for human brains (if your original resolution is already higher, you can skip this step)::
109109

110-
for_each * : mrresize IN/dwi_denoised_unringed_preproc_unbiased_normalised.mif -vox 1.25 IN/dwi_denoised_unringed_preproc_unbiased_normalised_upsampled.mif
110+
for_each * : mrgrid IN/dwi_denoised_unringed_preproc_unbiased_normalised.mif regrid -vox 1.25 IN/dwi_denoised_unringed_preproc_unbiased_normalised_upsampled.mif
111111

112112
8. Compute upsampled brain mask images
113113
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/quantitative_structural_connectivity/ismrm_hcp_tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ image and provide this alternative FOD image to SIFT (this should have
161161
little influence on the outcome of the algorithm, but will greatly
162162
reduce memory consumption):
163163

164-
``mrresize WM_FODs.mif FOD_downsampled.mif -scale 0.5 -interp sinc``
164+
``mrgrid WM_FODs.mif regrid FOD_downsampled.mif -scale 0.5 -interp sinc``
165165

166166
If this still does not adequately reduce RAM usage, you will need to
167167
reduce the number of input streamlines to a level where your processing

docs/reference/commands/mrconvert.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Note that for both the -coord and -axes options, indexing starts from 0 rather t
2727

2828
Additionally, for the second input to the -coord option and the -axes option, you can use any valid number sequence in the selection, as well as the 'end' keyword (see the main documentation for details); this can be particularly useful to select multiple coordinates.
2929

30-
The -vox option is used to change the size of the voxels in the output image as reported in the image header; note however that this does not re-sample the image based on a new voxel size (that is done using the mrresize command).
30+
The -vox option is used to change the size of the voxels in the output image as reported in the image header; note however that this does not re-sample the image based on a new voxel size (that is done using the mrgrid command).
3131

3232
By default, the intensity scaling parameters in the input image header are passed through to the output image header when writing to an integer image, and reset to 0,1 (i.e. no scaling) for floating-point and binary images. Note that the -scaling option will therefore have no effect for floating-point or binary output images.
3333

matlab/write_mrtrix.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ function write_mrtrix (image, filename)
142142

143143
if strcmp(filename(end-3:end), '.mif')
144144
dataoffset = ftell (fid) + 18;
145-
dataoffset += mod((4 - mod(dataoffset, 4)), 4);
145+
dataoffset = dataoffset + mod((4 - mod(dataoffset, 4)), 4);
146146
fprintf (fid, '. %d\nEND\n ', dataoffset);
147-
fseek (fid, dataoffset);
147+
fseek (fid, dataoffset, 'bof');
148148
elseif strcmp(filename(end-3:end), '.mih')
149149
datafile = [ filename(1:end-4) '.dat' ];
150150
fprintf (fid, '%s 0\nEND\n', datafile);

run_tests

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ EOD
8282

8383

8484
if [ ! -z $datadir ]; then
85-
echo -n "fetching requisite test data... "
85+
echo -n "checking for requisite test data... "
8686
git submodule update --init $datadir >> $LOGFILE 2>&1
8787
if [ $? != 0 ]; then
88-
echo ERROR!
89-
exit 1
88+
if [[ -e $datadir && ! -z $(ls -A $datadir) ]]; then
89+
echo "Found; UNABLE TO VERIFY VERSION MATCH"
90+
else
91+
echo "ERROR!"
92+
exit 1
93+
fi
9094
else
91-
echo OK
95+
echo "Synchronized OK"
9296
fi
9397
fi
9498

0 commit comments

Comments
 (0)