Skip to content

Commit af51820

Browse files
committed
Merge remote-tracking branch 'upstream/master' into enh/spmnormalize
* upstream/master: fix: ensure ipython engine is not left in an undefined directory - closes #983 Updated ApplyTransform Specs fixed ants ApplyTransformInputSpec fix error Enable lowb greater than zero in b0_average
2 parents edf76cf + c6aca88 commit af51820

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

nipype/interfaces/ants/resampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
249249
File(exists=True), argstr='%s', mandatory=True, desc=(''))
250250
invert_transform_flags = InputMultiPath(traits.Bool())
251251
default_value = traits.Float(
252-
0.0, argstr='--default-value %d', usedefault=True)
252+
0.0, argstr='--default-value %g', usedefault=True)
253253
print_out_composite_warp_file = traits.Enum(
254254
0, 1, requires=["output_image"], desc=('')) # TODO: Change to boolean
255255

nipype/interfaces/ants/tests/test_auto_ApplyTransforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def test_ApplyTransforms_inputs():
66
input_map = dict(args=dict(argstr='%s',
77
),
8-
default_value=dict(argstr='--default-value %d',
8+
default_value=dict(argstr='--default-value %g',
99
usedefault=True,
1010
),
1111
dimension=dict(argstr='--dimensionality %d',

nipype/pipeline/plugins/ipython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def execute_task(pckld_task, node_config, updatehash):
2222
from nipype import config, logging
2323
traceback=None
2424
result=None
25+
import os
26+
cwd = os.getcwd()
2527
try:
2628
config.update_config(node_config)
2729
logging.update_logging(config)
@@ -31,6 +33,7 @@ def execute_task(pckld_task, node_config, updatehash):
3133
except:
3234
traceback = format_exc()
3335
result = task.result
36+
os.chdir(cwd)
3437
return result, traceback, gethostname()
3538

3639
class IPythonPlugin(DistributedPluginBase):
@@ -72,7 +75,7 @@ def run(self, graph, config, updatehash=False):
7275

7376
def _get_result(self, taskid):
7477
if taskid not in self.taskmap:
75-
raise ValueError('Task %d not in pending list'%taskid)
78+
raise ValueError('Task %d not in pending list' % taskid)
7679
if self.taskmap[taskid].ready():
7780
result, traceback, hostname = self.taskmap[taskid].get()
7881
result_out = dict(result=None, traceback=None)

nipype/workflows/dmri/fsl/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,11 @@ def recompose_xfm(in_bval, in_xfms):
381381
return out_files
382382

383383

384-
def b0_average(in_dwi, in_bval, out_file=None):
384+
def b0_average(in_dwi, in_bval, max_b=10.0, out_file=None):
385385
"""
386386
A function that averages the *b0* volumes from a DWI dataset.
387+
As current dMRI data are being acquired with all b-values > 0.0,
388+
the *lowb* volumes are selected by specifying the parameter max_b.
387389
388390
.. warning:: *b0* should be already registered (head motion artifact should
389391
be corrected).
@@ -403,7 +405,7 @@ def b0_average(in_dwi, in_bval, out_file=None):
403405
imgs = np.array(nb.four_to_three(nb.load(in_dwi)))
404406
bval = np.loadtxt(in_bval)
405407
b0s = [im.get_data().astype(np.float32)
406-
for im in imgs[np.where(bval == 0)]]
408+
for im in imgs[np.where(bval <= max_b)]]
407409
b0 = np.average(np.array(b0s), axis=0)
408410

409411
hdr = imgs[0].get_header().copy()

0 commit comments

Comments
 (0)