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

Provide easy way to loop over files as structure #161

Open
nbeliy opened this issue Feb 19, 2021 · 0 comments
Open

Provide easy way to loop over files as structure #161

nbeliy opened this issue Feb 19, 2021 · 0 comments

Comments

@nbeliy
Copy link
Collaborator

nbeliy commented Feb 19, 2021

In actual state user have an access either to the flat list of files using query, or to full unfiltered layout. It can be helpfull to provide user a way to loop all datafiles returned by query with access to corresponding structure.

It can be done using already existing indexing:

finfo = bids.internal.return_file_info(BIDS, data_list{iFile});
file = BIDS.subject(info.sub_idx).(info.modality)(info.file_idx);

However return_file_info rely on find, and so it is time consuming.

The easiest solution (that I see), is to create a new function query_struct(BIDS, query) which will replicate existing query(BIDS, 'data', query) but returnsa list of found file structures. To optimize, the query("data") will call query_struct(BIDS, query) and retrieve the filenames.

Alternatively, an iterator can be implemented:

iterator = bids.BEGIN(BIDS, query);
do
  file = iterator.get();
while iterator.next()

BEGIN creates in memory a list of file infos,
get returns corresponding file structure
next moves current file info to the next in list

@Remi-Gau Remi-Gau linked a pull request Feb 19, 2021 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Wish list
Development

Successfully merging a pull request may close this issue.

1 participant