Skip to content
New issue

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

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

Already on GitHub? # to your account

Handle empty directories more gracefully #925

Open
effigies opened this issue Dec 5, 2022 · 0 comments
Open

Handle empty directories more gracefully #925

effigies opened this issue Dec 5, 2022 · 0 comments
Labels

Comments

@effigies
Copy link
Collaborator

effigies commented Dec 5, 2022

If presented with a subject with an empty anat/ directory, PyBIDS will raise an unhandled StopIteration:

  File "/opt/conda/lib/python3.9/site-packages/fmriprep/config.py", line 472, in init
    cls._layout = BIDSLayout(
  File "/opt/conda/lib/python3.9/site-packages/bids/layout/layout.py", line 152, in __init__
    indexer(self)
  File "/opt/conda/lib/python3.9/site-packages/bids/layout/index.py", line 109, in __call__
    self._index_dir(self._layout._root, self._config)
  File "/opt/conda/lib/python3.9/site-packages/bids/layout/index.py", line 193, in _index_dir
    self._index_dir(d, list(config), default_action=default)
  File "/opt/conda/lib/python3.9/site-packages/bids/layout/index.py", line 193, in _index_dir
    self._index_dir(d, list(config), default_action=default)
  File "/opt/conda/lib/python3.9/site-packages/bids/layout/index.py", line 173, in _index_dir
    _, dirnames, filenames = next(os.walk(path))

Running through pdb:

StopIteration
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /opt/conda/lib/python3.9/site-packages/bids/layout/index.py(173)_index_dir()
-> _, dirnames, filenames = next(os.walk(path))
(Pdb) print(path)
/data/sub-050202002B/anat
(Pdb) up
> /opt/conda/lib/python3.9/site-packages/bids/layout/index.py(193)_index_dir()
-> self._index_dir(d, list(config), default_action=default)
(Pdb) print(d)
/data/sub-050202002B/anat
(Pdb) up
> /opt/conda/lib/python3.9/site-packages/bids/layout/index.py(193)_index_dir()
-> self._index_dir(d, list(config), default_action=default)
(Pdb) print(d)
/data/sub-050202002B

Initially reported in nipreps/fmriprep#2902

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

No branches or pull requests

1 participant