|
5 | 5 | import sys
|
6 | 6 | import json
|
7 | 7 | from pathlib import Path
|
| 8 | +from bids import BIDSLayout |
| 9 | + |
| 10 | + |
| 11 | +def collect_data(bids_dir, participant_label, task=None, echo=None, |
| 12 | + bids_validate=True): |
| 13 | + """Replacement for niworkflows' version.""" |
| 14 | + if isinstance(bids_dir, BIDSLayout): |
| 15 | + layout = bids_dir |
| 16 | + else: |
| 17 | + layout = BIDSLayout(str(bids_dir), validate=bids_validate) |
| 18 | + |
| 19 | + queries = { |
| 20 | + 'fmap': {'datatype': 'fmap'}, |
| 21 | + 'dwi': {'datatype': 'dwi', 'suffix': 'dwi'}, |
| 22 | + 'bold': {'datatype': 'func', 'suffix': 'bold'}, |
| 23 | + 'sbref': {'datatype': 'func', 'suffix': 'sbref'}, |
| 24 | + 'flair': {'datatype': 'anat', 'suffix': 'FLAIR'}, |
| 25 | + 't2w': {'datatype': 'anat', 'suffix': 'T2w'}, |
| 26 | + 't1w': {'datatype': 'anat', 'suffix': 'T1w'}, |
| 27 | + 'roi': {'datatype': 'anat', 'suffix': 'roi'}, |
| 28 | + } |
| 29 | + |
| 30 | + if task: |
| 31 | + queries['bold']['task'] = task |
| 32 | + |
| 33 | + if echo: |
| 34 | + queries['bold']['echo'] = echo |
| 35 | + |
| 36 | + subj_data = { |
| 37 | + dtype: sorted(layout.get(return_type='file', subject=participant_label, |
| 38 | + extension=['nii', 'nii.gz'], **query)) |
| 39 | + for dtype, query in queries.items()} |
| 40 | + |
| 41 | + return subj_data, layout |
8 | 42 |
|
9 | 43 |
|
10 | 44 | def write_derivative_description(bids_dir, deriv_dir):
|
|
0 commit comments