Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_B0FieldIdentifiers errors #834

Closed
bpinsard opened this issue Apr 11, 2022 · 3 comments · Fixed by #1112
Closed

get_B0FieldIdentifiers errors #834

bpinsard opened this issue Apr 11, 2022 · 3 comments · Fixed by #1112

Comments

@bpinsard
Copy link
Contributor

I am trying to apply the new spec for B0 fieldmap Intent to bypass limitations with sdcflows nipreps/sdcflows#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.

results = list({
ents[target] for ents in ent_iter if target in ents
})

@effigies
Copy link
Collaborator

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.

@bpinsard
Copy link
Contributor Author

@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.

@bpinsard
Copy link
Contributor Author

It works with the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants