RF: Use consistent code for legacy hack and updated sidecar generation
@@ -653,7 +653,7 @@ space-MNI152NLin6Asym_desc-preproc_bold.json'
}
)
if self._metadata:
- out_file = self._results["out_file"][0]
+ out_file = Path(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
@@ -664,13 +664,10 @@ space-MNI152NLin6Asym_desc-preproc_bold.json'
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 = out_file.parent / f"{_splitext(str(out_file))[0]}.json"
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 = out_file.parent / f"{out_file.name.split('.', 1)[0]}.json"
sidecar.write_text(dumps(self._metadata, sort_keys=True, indent=2))
self._results["out_meta"] = str(sidecar)
return runtime
