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

BIDSlayout.get_sessions() fails on openneuro ds001541 #747

Closed
poldrack opened this issue Jun 18, 2021 · 3 comments · Fixed by #748
Closed

BIDSlayout.get_sessions() fails on openneuro ds001541 #747

poldrack opened this issue Jun 18, 2021 · 3 comments · Fixed by #748

Comments

@poldrack
Copy link

here is code to reproduce:

import os
from bids import BIDSLayout

os.system('datalad clone [email protected]:OpenNeuroDatasets/ds001541.git')

layout = BIDSLayout('ds001541')
layout.get_sessions()

should raise the following error:

  File "pybids_ds001541.py", line 9, in <module>
    layout.get_sessions()
  File "/Users/poldrack/anaconda3/envs/py38/lib/python3.8/site-packages/bids/layout/layout.py", line 970, in get
    results = list(set([x.entities[target] for x in results]))
TypeError: unhashable type: 'dict'

I wonder if it's related to different numbers of sessions across subjects:

ls ds001541/sub*
ds001541/sub-562:
ses-1	ses-2	ses-3	ses-4	ses-5	ses-6

ds001541/sub-572:
ses-4	ses-5	ses-7	ses-8	ses-9

ds001541/sub-573:
ses-1	ses-2	ses-3

ds001541/sub-584:
ses-1

ds001541/sub-589:
ses-1

ds001541/sub-597:
ses-1	ses-2	ses-4

ds001541/sub-598:
ses-1	ses-2	ses-3	ses-4	ses-5	ses-6	ses-7

ds001541/sub-600:
ses-1

ds001541/sub-603:
ses-1	ses-2	ses-3	ses-4	ses-5	ses-6	ses-7

ds001541/sub-620:
ses-1	ses-2	ses-3	ses-4	ses-5	ses-6	ses-7

ds001541/sub-647:
ses-1

ds001541/sub-652:
ses-1	ses-2

ds001541/sub-662:
ses-1	ses-2	ses-3

ds001541/sub-663:
ses-2

ds001541/sub-666:
ses-1

ds001541/sub-667:
ses-1	ses-2
@effigies
Copy link
Collaborator

I think it's probably that there's metadata in sessions.tsv.

@poldrack
Copy link
Author

poldrack commented Jun 18, 2021 via email

@adelavega
Copy link
Collaborator

adelavega commented Jun 29, 2021

I'm having the same issue with get_tasks on narratives.

What is happening is the by default pybids has index_metadata=True. What this does is index the .json sidecar meta-data as entities for the corresponding files. This is fine for .json side cars for images, but for .tsv side cars, this doesn't make sense. .tsv sidecars are descriptions of columns, not additional "entities" for the corresponding files.

Since the columns in .tsv files are not protected, then one could use "sessions" or "tasks" and describe those columns in a .json side car with an object: {"session": {"Description": "session name"}}. This object is then entered into the set() operation used in get_sessions.

A quick fix is to set index_metadata=False, but this is a bug that should be fixed.

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.

3 participants