Skip to content

Commit

Permalink
Merge maint/1.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Sep 1, 2021
2 parents dec5289 + 45b9808 commit 902fed9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ def _run_interface(self, runtime):
if new_data is None:
set_consumables(new_header, orig_img.dataobj)
new_data = orig_img.dataobj.get_unscaled()
else:
# Without this, we would be writing nans
# This is our punishment for hacking around nibabel defaults
new_header.set_slope_inter(slope=1., inter=0.)
unsafe_write_nifti_header_and_data(
fname=out_file,
header=new_header,
Expand Down
19 changes: 13 additions & 6 deletions niworkflows/interfaces/tests/test_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@
["anat.nii.gz"],
{"desc": "brain", "suffix": "mask"},
"sub-100185/anat/sub-100185_desc-brain_mask.nii.gz",
"d425f0096b6b6d1252973e48b31d760c0b1bdc11",
"7af86a1f6806a41078e4d2699d680dbe2b9f6ae2",
),
(
T1W_PATH,
["anat.nii.gz"],
{"desc": "brain", "suffix": "mask", "space": "MNI"},
"sub-100185/anat/sub-100185_space-MNI_desc-brain_mask.nii.gz",
"a2a6efa16eb23173d0ee64779de879711bc74643",
"1591f90e0da2a624c972784dda6a01b5572add15",
),
(
T1W_PATH,
Expand All @@ -120,8 +120,8 @@
f"sub-100185/anat/sub-100185_desc-{s}_dseg.nii"
for s in ("aseg", "aparcaseg")
],
["a235cdf59f9bf077ba30bf2523a56508e3a5aabb",
"a235cdf59f9bf077ba30bf2523a56508e3a5aabb"],
["5543a788bf3383d7a2fc41f5cff4e0bbb8f5f282",
"5543a788bf3383d7a2fc41f5cff4e0bbb8f5f282"],
),
(
T1W_PATH,
Expand Down Expand Up @@ -194,14 +194,14 @@
["dseg.nii"],
{"space": "MNI", "suffix": "dseg", "desc": "aseg"},
"sub-100185/func/sub-100185_task-machinegame_run-1_space-MNI_desc-aseg_dseg.nii",
"6d2cae7f56c246d7934e2e21e7b472ecc63a4257",
"ddadc9be8224eebe0177a65bf87300f275e17e96",
),
(
BOLD_PATH,
["mask.nii"],
{"space": "MNI", "suffix": "mask", "desc": "brain"},
"sub-100185/func/sub-100185_task-machinegame_run-1_space-MNI_desc-brain_mask.nii",
"c365991854931181a1444d6803f5289448e7e266",
"f97a1877508139b42ea9fc476bdba367b001ab00",
),
(
BOLD_PATH,
Expand Down Expand Up @@ -330,6 +330,13 @@ def test_DerivativesDataSink_build_path(

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

Expand Down

0 comments on commit 902fed9

Please sign in to comment.