pybids
pybids copied to clipboard
`get_B0FieldIdentifiers` errors
I am trying to apply the new spec for B0 fieldmap Intent to bypass limitations with sdcflows https://github.com/nipreps/sdcflows/issues/266
However I have fmriprep crashing in pybids.BIDSLayout.get_B0FieldIdentifiers
lib/python3.7/site-packages/bids/layout/layout.py in get(self, return_type, target, scope, regex_search, absolute
_paths, invalid_filters, **filters)
676 ent_iter = (x.get_entities(metadata=metadata) for x in results)
677 results = list({
--> 678 ents[target] for ents in ent_iter if target in ents
679 })
680
lib/python3.7/site-packages/bids/layout/layout.py in <setcomp>(.0)
676 ent_iter = (x.get_entities(metadata=metadata) for x in results)
677 results = list({
--> 678 ents[target] for ents in ent_iter if target in ents
679 })
680
TypeError: unhashable type: 'list'
From the spec, B0FieldIdentifier
can be a string or an array of string, which I stored as a json list if I am correct.
https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#echo-planar-imaging-and-b0-mapping
So I am not sure why it is converted to a dict here.
https://github.com/bids-standard/pybids/blob/5ea3103b6dada5d3fd02cdec7d6498817d76f366/bids/layout/layout.py#L677-L679
Hi @bpinsard, thanks for posting this! I think this is a definitive use case for #684. If you're doing some testing, would you mind seeing whether merging that would resolve the issue? I can get back to this issue next week.
@effigies thanks for the pointer, weirdly I had not found that PR in my search. I will test it on our data. Yesterday I had implemented a quick and dirty fix in the pybids code to do something similar (str representation of the list for hashing/unique) and it allowed to pass that error, so that should work.
It works with the PR.