Skip to content

Commit b10bc8c

Browse files
committed
MAINT: Remove non-compliant dtseries.json metadata
1 parent 5cea8a7 commit b10bc8c

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

niworkflows/interfaces/bids.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from templateflow.api import templates as _get_template_list
5151
from ..utils.bids import _init_layout, relative_to_root
5252
from ..utils.images import set_consumables, unsafe_write_nifti_header_and_data
53-
from ..utils.misc import splitext as _splitext, _copy_any, unlink
53+
from ..utils.misc import _copy_any, unlink
5454

5555
regz = re.compile(r"\.gz$")
5656
_pybids_spec = loads(Path(_pkgres("niworkflows", "data/nipreps.json")).read_text())
@@ -710,21 +710,6 @@ def _run_interface(self, runtime):
710710
}
711711
)
712712
if self._metadata:
713-
out_file = Path(self._results["out_file"][0])
714-
# 1.3.x hack
715-
# For dtseries, we have been generating weird non-BIDS JSON files.
716-
# We can safely keep producing them to avoid breaking derivatives, but
717-
# only the existing keys should keep going into them.
718-
if out_file.name.endswith(".dtseries.nii"):
719-
legacy_metadata = {}
720-
for key in ("grayordinates", "space", "surface", "surface_density", "volume"):
721-
if key in self._metadata:
722-
legacy_metadata[key] = self._metadata.pop(key)
723-
if legacy_metadata:
724-
sidecar = out_file.parent / f"{_splitext(str(out_file))[0]}.json"
725-
unlink(sidecar, missing_ok=True)
726-
sidecar.write_text(dumps(legacy_metadata, sort_keys=True, indent=2))
727-
# The future: the extension is the first . and everything after
728713
sidecar = out_file.parent / f"{out_file.name.split('.', 1)[0]}.json"
729714
unlink(sidecar, missing_ok=True)
730715
sidecar.write_text(dumps(self._metadata, sort_keys=True, indent=2))

niworkflows/interfaces/tests/test_bids.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def test_DerivativesDataSink_build_path(
342342
assert sha1(Path(out).read_bytes()).hexdigest() == chksum
343343

344344

345-
def test_DerivativesDataSink_dtseries_json_hack(tmp_path):
345+
def test_DerivativesDataSink_dtseries_json(tmp_path):
346346
cifti_fname = str(tmp_path / "test.dtseries.nii")
347347

348348
axes = (nb.cifti2.SeriesAxis(start=0, step=2, size=20),
@@ -376,8 +376,7 @@ def test_DerivativesDataSink_dtseries_json_hack(tmp_path):
376376
old_sidecar = out_path.with_name("sub-01_task-rest_space-fsLR_bold.dtseries.json")
377377
new_sidecar = out_path.with_name("sub-01_task-rest_space-fsLR_bold.json")
378378

379-
assert old_sidecar.exists()
380-
assert "grayordinates" in json.loads(old_sidecar.read_text())
379+
assert not old_sidecar.exists()
381380
assert new_sidecar.exists()
382381
assert "RepetitionTime" in json.loads(new_sidecar.read_text())
383382

0 commit comments

Comments
 (0)