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

UnboundLocalError when using BIDSLayout with specific indexer #1050

Closed
alperkent opened this issue Apr 12, 2024 · 0 comments
Closed

UnboundLocalError when using BIDSLayout with specific indexer #1050

alperkent opened this issue Apr 12, 2024 · 0 comments

Comments

@alperkent
Copy link
Contributor

Hello!

I encountered an UnboundLocalError when trying to create a BIDSLayout with a specific indexer. Here's the code snippet that produces the error:

import bids

filters = {'datatype': 'eeg', 'suffix': 'eeg'}
indexer = bids.BIDSLayoutIndexer(**filters)
layout = bids.BIDSLayout('../data/bids-examples/eeg_ds000117', indexer=indexer)

Here's the error message:

UnboundLocalError: cannot access local variable 'ext_key' where it is not associated with a value

The error occurs in the following lines of the PyBIDS package:

layout.py:177, in BIDSLayout.__init__
index.py:154, in BIDSLayoutIndexer.__call__
index.py:268, in BIDSLayoutIndexer._index_metadata

In the _index_metadata method, the variable ext_key is used in the if filters.get(ext_key): statement before it has been assigned a value. The error seems to occur because of this issue.

Environment:

  • PyBIDS version: 0.16.4
  • Python version: 3.12
  • Operating System: macOS

I would appreciate any help or guidance on this issue. If you need any more information, please let me know. Thank you in advance for your time and assistance.

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

No branches or pull requests

1 participant