|
212 | 212 | "from nipype.interfaces.utility import Function\n",
|
213 | 213 | "\n",
|
214 | 214 | "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": [ |
216 | 231 | "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:" |
218 | 243 | ]
|
219 | 244 | },
|
220 | 245 | {
|
|
223 | 248 | "metadata": {},
|
224 | 249 | "outputs": [],
|
225 | 250 | "source": [
|
| 251 | + "bg.inputs.output_query = {'bolds': dict(type='bold')}\n", |
226 | 252 | "res = bg.run()\n",
|
227 | 253 | "res.outputs"
|
228 | 254 | ]
|
|
231 | 257 | "cell_type": "markdown",
|
232 | 258 | "metadata": {},
|
233 | 259 | "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" |
235 | 263 | ]
|
236 | 264 | },
|
237 | 265 | {
|
|
289 | 317 | "from nipype.pipeline import Node, MapNode, Workflow\n",
|
290 | 318 | "from nipype.interfaces.io import BIDSDataGrabber\n",
|
291 | 319 | "\n",
|
292 |
| - "ex2_BIDSDataGrabber = BIDSDataGrabber(outfields = ['T1w'])\n", |
| 320 | + "ex2_BIDSDataGrabber = BIDSDataGrabber()\n", |
293 | 321 | "ex2_BIDSDataGrabber.inputs.base_dir = '/data/ds000114'\n",
|
294 | 322 | "ex2_BIDSDataGrabber.inputs.subject = '10'\n",
|
295 | 323 | "ex2_BIDSDataGrabber.inputs.output_query = {'T1w': dict(modality='anat')}\n",
|
|
303 | 331 | "metadata": {},
|
304 | 332 | "source": [
|
305 | 333 | "## 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))." |
307 | 335 | ]
|
308 | 336 | },
|
309 | 337 | {
|
|
342 | 370 | "cell_type": "markdown",
|
343 | 371 | "metadata": {},
|
344 | 372 | "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", |
346 | 374 | "(More about MapNode in [MapNode](basic_mapnodes.ipynb))"
|
347 | 375 | ]
|
348 | 376 | },
|
|
0 commit comments