You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not entirely sure that this is expected to work, but it was a bit surprising to me. One of the entities associated with the fmap nifti is "fmap": "epi". But getting files with that entity excludes the associated json sidecar. I expected the json sidecar to have the same entities as the nifti, but for the extension.
importtempfilefrompathlibimportPathimportnibabelasnbimportnumpyasnpimportjsonimportbidssub="0"description= {"BIDSVersion": "1.9.0", "Name": "test"}
withtempfile.TemporaryDirectory() asd:
bidsdir=Path(d)
(bidsdir/"dataset_description.json").write_text(json.dumps(description))
fmapdir=bidsdir/f"sub-{sub}"/"fmap"fmapdir.mkdir(parents=True)
fordirectionin ["AP", "PA"]:
img=fmapdir/f"sub-{sub}_acq-dwib0_dir-{direction}_epi.nii.gz"nb.nifti1.Nifti1Image(np.zeros((4, 4)), affine=np.eye(4)).to_filename(
img
)
sidecar_api=fmapdir/img.name.replace(".nii.gz", ".json")
ped="i"ifdirection=="AP"else"i-"sidecar_api.write_text(
json.dumps({"PhaseEncodingDirection": ped, "TotalReadoutTime": 1})
)
test_layout=bids.BIDSLayout(bidsdir)
img_file: bids.layout.models.BIDSImageFile=test_layout.get(
subject=sub, suffix="epi", extension=".nii.gz", direction="AP"
)[0]
# show bids fileprint(f"{img_file=}")
entities=img_file.get_entities()
entities_with_extension= {
**{k: vfork, vinentities.items() ifk!="extension"},
**{"extension": ".json"},
}
# confirm that the new entities has the .json ending# (but what's that extra fmap: epi?)print(f"{entities_with_extension=}")
files=test_layout.get(**entities_with_extension)
# this is empty?print(f"{files=}")
files_without_fmap_entity=test_layout.get(
**{k: vfork, vinentities_with_extension.items() ifk!="fmap"}
)
# seems like the issue was the extra fmap entityprint(f"{files_without_fmap_entity=}")
It seems unlikely that anybody's using that undocumented "entity", that is just the same as suffix for fieldmaps, but removing it properly would take a deprecation cycle. Feel free to add a config option:
I'm not entirely sure that this is expected to work, but it was a bit surprising to me. One of the entities associated with the fmap nifti is
"fmap": "epi"
. Butget
ting files with that entity excludes the associated json sidecar. I expected the json sidecar to have the same entities as the nifti, but for the extension.The text was updated successfully, but these errors were encountered: