Skip to content

Commit 553d5a1

Browse files
committed
Refine BIDSDataGrabber example
1 parent ab6ed8d commit 553d5a1

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

notebooks/basic_data_input_bids.ipynb

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,34 @@
212212
"from nipype.interfaces.utility import Function\n",
213213
"\n",
214214
"bg = Node(BIDSDataGrabber(), name='bids-grabber')\n",
215-
"bg.inputs.base_dir = '/data/ds000114'\n",
215+
"bg.inputs.base_dir = '/data/ds000114'"
216+
]
217+
},
218+
{
219+
"cell_type": "markdown",
220+
"metadata": {},
221+
"source": [
222+
"You can define static filters, that will apply to all queries, by modifying the appropriate input"
223+
]
224+
},
225+
{
226+
"cell_type": "code",
227+
"execution_count": null,
228+
"metadata": {},
229+
"outputs": [],
230+
"source": [
216231
"bg.inputs.subject = '01'\n",
217-
"bg.inputs.output_query = {'bolds': dict(type='bold')}"
232+
"res = bg.run()\n",
233+
"res.outputs"
234+
]
235+
},
236+
{
237+
"cell_type": "markdown",
238+
"metadata": {},
239+
"source": [
240+
"Note that by default `BIDSDataGrabber` will fetch `nifti` files matching modality `func` and `anat`, and output them as two output fields. \n",
241+
"\n",
242+
"To define custom fields, simply define the arguments to pass to `BIDSLayout.get` as dictionary, like so:"
218243
]
219244
},
220245
{
@@ -223,6 +248,7 @@
223248
"metadata": {},
224249
"outputs": [],
225250
"source": [
251+
"bg.inputs.output_query = {'bolds': dict(type='bold')}\n",
226252
"res = bg.run()\n",
227253
"res.outputs"
228254
]
@@ -231,7 +257,9 @@
231257
"cell_type": "markdown",
232258
"metadata": {},
233259
"source": [
234-
"Works like a charm! Lets put it in a workflow. We are not going to analyze any data, but for demonstration purposes, we will add a couple of nodes that pretend to analyze their inputs"
260+
"This results in a single output field `bold`, which returns all files with `type:bold` for `subject:\"01\"` \n",
261+
"\n",
262+
"Now, lets put it in a workflow. We are not going to analyze any data, but for demonstration purposes, we will add a couple of nodes that pretend to analyze their inputs"
235263
]
236264
},
237265
{
@@ -289,7 +317,7 @@
289317
"from nipype.pipeline import Node, MapNode, Workflow\n",
290318
"from nipype.interfaces.io import BIDSDataGrabber\n",
291319
"\n",
292-
"ex2_BIDSDataGrabber = BIDSDataGrabber(outfields = ['T1w'])\n",
320+
"ex2_BIDSDataGrabber = BIDSDataGrabber()\n",
293321
"ex2_BIDSDataGrabber.inputs.base_dir = '/data/ds000114'\n",
294322
"ex2_BIDSDataGrabber.inputs.subject = '10'\n",
295323
"ex2_BIDSDataGrabber.inputs.output_query = {'T1w': dict(modality='anat')}\n",
@@ -303,7 +331,7 @@
303331
"metadata": {},
304332
"source": [
305333
"## Iterating over subject labels\n",
306-
"In the previous example, we demonstrated how to use `pybids` to \"analyze\" one subject. How can we scale it for all subjects? Easy - using `iterables` (more in [Iteration/Iterables](basic_iteration.ipynb)."
334+
"In the previous example, we demonstrated how to use `pybids` to \"analyze\" one subject. How can we scale it for all subjects? Easy - using `iterables` (more in [Iteration/Iterables](basic_iteration.ipynb))."
307335
]
308336
},
309337
{
@@ -342,7 +370,7 @@
342370
"cell_type": "markdown",
343371
"metadata": {},
344372
"source": [
345-
"Can we incorporate this into our pipeline? Yes, we can!\n",
373+
"Can we incorporate this into our pipeline? Yes, we can! To do so, let's use a `Function` node to use `BIDSLayout` in a custom way.\n",
346374
"(More about MapNode in [MapNode](basic_mapnodes.ipynb))"
347375
]
348376
},

0 commit comments

Comments
 (0)