FIX: Cordon off .dtseries.json contents
@@ -653,9 +653,24 @@ space-MNI152NLin6Asym_desc-preproc_bold.json'
}
)
if self._metadata:
+ out_file = self._results["out_file"][0]
+ # 1.3.x hack
+ # For dtseries, we have been generating weird non-BIDS JSON files.
+ # We can safely keep producing them to avoid breaking derivatives, but
+ # only the existing keys should keep going into them.
+ if out_file.endswith(".dtseries.nii"):
+ legacy_metadata = {}
+ for key in ("grayordinates", "space", "surface", "surface_density", "volume"):
+ if key in self._metadata:
+ legacy_metadata[key] = self._metadata.pop(key)
+ if legacy_metadata:
sidecar = Path(self._results["out_file"][0]).parent / (
"%s.json" % _splitext(self._results["out_file"][0])[0]
)
+ sidecar.write_text(dumps(legacy_metadata, sort_keys=True, indent=2))
+ # The future: the extension is the first . and everything after
+ out_path = Path(out_file)
+ sidecar = out_path.parent / f"{out_path.name.split('.', 1)[0]}.json"
sidecar.write_text(dumps(self._metadata, sort_keys=True, indent=2))
self._results["out_meta"] = str(sidecar)
return runtime
