Hi folks, we are trying to organize some data into BIDS, however, getting an error message on the RepetitionTime during validation: “Repetition time was not defined in seconds, milliseconds or microseconds in the scan's header.”
The functional file header seems to have correct TR, as observed with pixdim4 in fslinfo
Here’s the json file:
We tried changing it to millseconds (i.e., 800), but still same issue.
Any idea what might be happening and why BIDS validation failed?
I ran into a similar problem and wanted to share a fix as I wasn’t able to find a straightforward python solution anywhere and had to look at the nibabel source code to find the correct unit codes.
from bids import BIDSLayout
import nibabel as nb
def set_xyzt_units(img, xyz='mm', t='sec'):
header = img.header.copy()
header.set_xyzt_units(xyz=xyz, t=t)
return img.__class__(img.get_data().copy(), img.affine, header)
def fix_xyzt_units(bids_root):
layout = BIDSLayout(bids_root)
for nii in layout.get(extensions=['.nii', '.nii.gz']):
metadata = layout.get_metadata(nii.path)
img = nb.load(nii.path)
fixed_img = set_xyzt_units(img)
fixed_img.to_filename(nii.path)