Skip to content

Commit

Permalink
Merge pull request #528 from mgxd/fix/derivatives-dtype
Browse files Browse the repository at this point in the history
FIX: Non-integer data coercion initialization
  • Loading branch information
effigies authored May 27, 2020
2 parents e15694f + 28e0d4f commit aea5805
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion niworkflows/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def _run_interface(self, runtime):
if np.issubdtype(data_dtype, np.integer):
new_data = np.rint(nii.dataobj).astype(data_dtype)
else:
new_data = data_dtype(nii.dataobj)
new_data = np.asanyarray(nii.dataobj, dtype=data_dtype)
# and set header to match
nii.set_data_dtype(data_dtype)
nii = nii.__class__(new_data, nii.affine, nii.header)
Expand Down
2 changes: 1 addition & 1 deletion niworkflows/interfaces/tests/test_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_DerivativesDataSink_build_path(
"space, size, units, xcodes, zipped, fixed, data_dtype",
[
("T1w", (30, 30, 30, 10), ("mm", "sec"), (2, 2), True, [False], None),
("T1w", (30, 30, 30, 10), ("mm", "sec"), (0, 2), True, [True], None),
("T1w", (30, 30, 30, 10), ("mm", "sec"), (0, 2), True, [True], "float64"),
("T1w", (30, 30, 30, 10), ("mm", "sec"), (0, 0), True, [True], "<i4"),
("T1w", (30, 30, 30, 10), ("mm", None), (2, 2), True, [True], "<f4"),
("T1w", (30, 30, 30, 10), (None, None), (0, 2), True, [True], None),
Expand Down

0 comments on commit aea5805

Please sign in to comment.