From 9206d30d34357f921415efe2a0dccaa9027914cd Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Mon, 26 Jun 2017 15:07:48 +1000 Subject: [PATCH 1/4] fixelcrop: Fix for NIfTI images Use fixel convenience function to determine the number of fixels in the image, rather than assume that the header entry containing this parameter will be present. --- cmd/fixelcrop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/fixelcrop.cpp b/cmd/fixelcrop.cpp index 112d97a9d7..a54b40b0b0 100644 --- a/cmd/fixelcrop.cpp +++ b/cmd/fixelcrop.cpp @@ -58,7 +58,7 @@ void run () Fixel::check_fixel_directory (out_fixel_directory, true); Header out_header = Header (in_index_image); - size_t total_nfixels = std::stoul (out_header.keyval ()[Fixel::n_fixels_key]); + size_t total_nfixels = Fixel::get_number_of_fixels (in_index_header); // We need to do a first pass of the mask image to determine the number of cropped fixels for (auto l = Loop (0) (mask_image); l; ++l) { From cec8ef0d4d35020b9d0f53aa85b6733d3b7c2a90 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Mon, 26 Jun 2017 15:08:36 +1000 Subject: [PATCH 2/4] app.debug(): Fix for direct calls Modify the output of the app.debug() function if it is called directly from the invoked Python script, and hence the stack only contains two entries. --- lib/mrtrix3/app.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/mrtrix3/app.py b/lib/mrtrix3/app.py index 3eea64a23e..ae1306e8c8 100644 --- a/lib/mrtrix3/app.py +++ b/lib/mrtrix3/app.py @@ -284,21 +284,24 @@ def debug(text): global colourClear, colourDebug global _verbosity if _verbosity <= 2: return - stack = inspect.stack()[1] - try: - filename = stack.filename - fname = stack.function - except: # Prior to Version 3.5 - filename = stack[1] - fname = stack[3] - funcname = fname + '()' - modulename = inspect.getmodulename(filename) - if modulename: - funcname = modulename + '.' + funcname - # If debug() has been called from within some external function (e.g. a library function), it's often to report on the outcome of that function. - # In this instance, find the location where that function itself was called from, rather than where debug() was called from. - caller = inspect.getframeinfo(inspect.stack()[min(2,len(inspect.stack()))][0]) - sys.stderr.write(os.path.basename(sys.argv[0]) + ': ' + colourDebug + '[DEBUG] ' + funcname + ' (from ' + os.path.basename(caller.filename) + ':' + str(caller.lineno) + '): ' + text + colourClear + '\n') + if len(inspect.stack()) == 2: # debug() called directly from script being executed + caller = inspect.getframeinfo(inspect.stack()[1][0]) + origin = '(' + os.path.basename(caller.filename) + ':' + str(caller.lineno) + ')' + else: # Some function has called debug(): Get location of both that function, and where that function was invoked + stack = inspect.stack()[1] + try: + filename = stack.filename + fname = stack.function + except: # Prior to Version 3.5 + filename = stack[1] + fname = stack[3] + funcname = fname + '()' + modulename = inspect.getmodulename(filename) + if modulename: + funcname = modulename + '.' + funcname + caller = inspect.getframeinfo(inspect.stack()[2][0]) + origin = funcname + ' (from ' + os.path.basename(caller.filename) + ':' + str(caller.lineno) + ')' + sys.stderr.write(os.path.basename(sys.argv[0]) + ': ' + colourDebug + '[DEBUG] ' + origin + ': ' + text + colourClear + '\n') def error(text): import os, sys From 212b71d592a7ee9be916995beb3a96b12e7598d2 Mon Sep 17 00:00:00 2001 From: J-Donald Tournier Date: Mon, 26 Jun 2017 13:36:43 +0100 Subject: [PATCH 3/4] tckconvert: add Daniel Blezek to the authors list --- cmd/tckconvert.cpp | 3 ++- docs/reference/commands/tckconvert.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/tckconvert.cpp b/cmd/tckconvert.cpp index 066a1f51bf..09c6514053 100644 --- a/cmd/tckconvert.cpp +++ b/cmd/tckconvert.cpp @@ -29,7 +29,8 @@ void usage () { AUTHOR = "Daan Christiaens (daan.christiaens@kcl.ac.uk), " "J-Donald Tournier (jdtournier@gmail.com), " - "Philip Broser (philip.broser@me.com)."; + "Philip Broser (philip.broser@me.com), " + "Daniel Blezek (daniel.blezek@gmail.com)."; SYNOPSIS = "Convert between different track file formats"; diff --git a/docs/reference/commands/tckconvert.rst b/docs/reference/commands/tckconvert.rst index 98a2a2bdcc..7d738f6ac0 100644 --- a/docs/reference/commands/tckconvert.rst +++ b/docs/reference/commands/tckconvert.rst @@ -80,7 +80,7 @@ Standard options -**Author:** Daan Christiaens (daan.christiaens@kcl.ac.uk), J-Donald Tournier (jdtournier@gmail.com), Philip Broser (philip.broser@me.com). +**Author:** Daan Christiaens (daan.christiaens@kcl.ac.uk), J-Donald Tournier (jdtournier@gmail.com), Philip Broser (philip.broser@me.com), Daniel Blezek (daniel.blezek@gmail.com). **Copyright:** Copyright (c) 2008-2017 the MRtrix3 contributors. From 74b3441d99f3e06d7fcf1536697e4d65410dd429 Mon Sep 17 00:00:00 2001 From: Max Pietsch Date: Tue, 27 Jun 2017 15:32:04 +0100 Subject: [PATCH 4/4] mrconvert: don't set PE scheme if PhaseEncoding::set_scheme throws an exception --- cmd/mrconvert.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/mrconvert.cpp b/cmd/mrconvert.cpp index 62e064a8d9..46432b2b1b 100644 --- a/cmd/mrconvert.cpp +++ b/cmd/mrconvert.cpp @@ -90,16 +90,16 @@ DESCRIPTION + OptionGroup ("Options to modify generic header entries") - + Option ("clear_property", + + Option ("clear_property", "remove the specified key from the image header altogether.").allow_multiple() + Argument ("key").type_text() - + Option ("set_property", + + Option ("set_property", "set the value of the specified key in the image header.").allow_multiple() + Argument ("key").type_text() + Argument ("value").type_text() - + Option ("append_property", + + Option ("append_property", "append the given value to the specified key in the image header (this adds the value specified as a new line in the header value).").allow_multiple() + Argument ("key").type_text() + Argument ("value").type_text() @@ -288,11 +288,11 @@ void run () } opt = get_options ("set_property"); - for (size_t n = 0; n < opt.size(); ++n) + for (size_t n = 0; n < opt.size(); ++n) header_out.keyval()[opt[n][0].as_text()] = opt[n][1].as_text(); opt = get_options ("append_property"); - for (size_t n = 0; n < opt.size(); ++n) + for (size_t n = 0; n < opt.size(); ++n) add_line (header_out.keyval()[opt[n][0].as_text()], opt[n][1].as_text()); @@ -342,7 +342,7 @@ void run () } } catch (...) { WARN ("Phase encoding scheme of input file does not match number of image volumes; omitting information from output image"); - PhaseEncoding::set_scheme (header_out, pe_scheme); + PhaseEncoding::set_scheme (header_out, Eigen::MatrixXd()); } } }