Skip to content

Commit 902fed9

Browse files
committed
Merge maint/1.3.x
2 parents dec5289 + 45b9808 commit 902fed9

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

niworkflows/interfaces/bids.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ def _run_interface(self, runtime):
668668
if new_data is None:
669669
set_consumables(new_header, orig_img.dataobj)
670670
new_data = orig_img.dataobj.get_unscaled()
671+
else:
672+
# Without this, we would be writing nans
673+
# This is our punishment for hacking around nibabel defaults
674+
new_header.set_slope_inter(slope=1., inter=0.)
671675
unsafe_write_nifti_header_and_data(
672676
fname=out_file,
673677
header=new_header,

niworkflows/interfaces/tests/test_bids.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@
9696
["anat.nii.gz"],
9797
{"desc": "brain", "suffix": "mask"},
9898
"sub-100185/anat/sub-100185_desc-brain_mask.nii.gz",
99-
"d425f0096b6b6d1252973e48b31d760c0b1bdc11",
99+
"7af86a1f6806a41078e4d2699d680dbe2b9f6ae2",
100100
),
101101
(
102102
T1W_PATH,
103103
["anat.nii.gz"],
104104
{"desc": "brain", "suffix": "mask", "space": "MNI"},
105105
"sub-100185/anat/sub-100185_space-MNI_desc-brain_mask.nii.gz",
106-
"a2a6efa16eb23173d0ee64779de879711bc74643",
106+
"1591f90e0da2a624c972784dda6a01b5572add15",
107107
),
108108
(
109109
T1W_PATH,
@@ -120,8 +120,8 @@
120120
f"sub-100185/anat/sub-100185_desc-{s}_dseg.nii"
121121
for s in ("aseg", "aparcaseg")
122122
],
123-
["a235cdf59f9bf077ba30bf2523a56508e3a5aabb",
124-
"a235cdf59f9bf077ba30bf2523a56508e3a5aabb"],
123+
["5543a788bf3383d7a2fc41f5cff4e0bbb8f5f282",
124+
"5543a788bf3383d7a2fc41f5cff4e0bbb8f5f282"],
125125
),
126126
(
127127
T1W_PATH,
@@ -194,14 +194,14 @@
194194
["dseg.nii"],
195195
{"space": "MNI", "suffix": "dseg", "desc": "aseg"},
196196
"sub-100185/func/sub-100185_task-machinegame_run-1_space-MNI_desc-aseg_dseg.nii",
197-
"6d2cae7f56c246d7934e2e21e7b472ecc63a4257",
197+
"ddadc9be8224eebe0177a65bf87300f275e17e96",
198198
),
199199
(
200200
BOLD_PATH,
201201
["mask.nii"],
202202
{"space": "MNI", "suffix": "mask", "desc": "brain"},
203203
"sub-100185/func/sub-100185_task-machinegame_run-1_space-MNI_desc-brain_mask.nii",
204-
"c365991854931181a1444d6803f5289448e7e266",
204+
"f97a1877508139b42ea9fc476bdba367b001ab00",
205205
),
206206
(
207207
BOLD_PATH,
@@ -330,6 +330,13 @@ def test_DerivativesDataSink_build_path(
330330

331331
for out, exp in zip(output, expectation):
332332
assert Path(out).relative_to(tmp_path) == Path(base) / exp
333+
# Regression - some images were given nan scale factors
334+
if out.endswith(".nii") or out.endswith(".nii.gz"):
335+
img = nb.load(out)
336+
with nb.openers.ImageOpener(out) as fobj:
337+
hdr = img.header.from_fileobj(fobj)
338+
assert not np.isnan(hdr["scl_slope"])
339+
assert not np.isnan(hdr["scl_inter"])
333340
for out, chksum in zip(output, checksum):
334341
assert sha1(Path(out).read_bytes()).hexdigest() == chksum
335342

0 commit comments

Comments
 (0)