Provide easy way to loop over files as structure
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