|
93 | 93 | },
|
94 | 94 | {
|
95 | 95 | "cell_type": "code",
|
96 |
| - "execution_count": null, |
97 |
| - "metadata": { |
98 |
| - "collapsed": true |
99 |
| - }, |
| 96 | + "execution_count": 1, |
| 97 | + "metadata": {}, |
100 | 98 | "outputs": [],
|
101 | 99 | "source": [
|
102 | 100 | "from nipype import DataGrabber, Node\n",
|
|
139 | 137 | },
|
140 | 138 | {
|
141 | 139 | "cell_type": "code",
|
142 |
| - "execution_count": null, |
143 |
| - "metadata": { |
144 |
| - "collapsed": true |
145 |
| - }, |
| 140 | + "execution_count": 2, |
| 141 | + "metadata": {}, |
146 | 142 | "outputs": [],
|
147 | 143 | "source": [
|
148 | 144 | "dg.inputs.template_args = {'anat': [['subject_id', 'ses_name']],\n",
|
|
158 | 154 | },
|
159 | 155 | {
|
160 | 156 | "cell_type": "code",
|
161 |
| - "execution_count": null, |
162 |
| - "metadata": { |
163 |
| - "collapsed": true |
164 |
| - }, |
| 157 | + "execution_count": 3, |
| 158 | + "metadata": {}, |
165 | 159 | "outputs": [],
|
166 | 160 | "source": [
|
167 | 161 | "dg.inputs.field_template = {'anat': 'sub-%02d/ses-%s/anat/*_T1w.nii.gz',\n",
|
|
184 | 178 | },
|
185 | 179 | {
|
186 | 180 | "cell_type": "code",
|
187 |
| - "execution_count": null, |
188 |
| - "metadata": { |
189 |
| - "collapsed": true |
190 |
| - }, |
| 181 | + "execution_count": 4, |
| 182 | + "metadata": {}, |
191 | 183 | "outputs": [],
|
192 | 184 | "source": [
|
193 | 185 | "# Using the IdentityInterface\n",
|
|
216 | 208 | },
|
217 | 209 | {
|
218 | 210 | "cell_type": "code",
|
219 |
| - "execution_count": null, |
220 |
| - "metadata": { |
221 |
| - "collapsed": true |
222 |
| - }, |
| 211 | + "execution_count": 5, |
| 212 | + "metadata": {}, |
223 | 213 | "outputs": [],
|
224 | 214 | "source": [
|
225 | 215 | "# Specifying the input fields of DataGrabber directly\n",
|
|
237 | 227 | },
|
238 | 228 | {
|
239 | 229 | "cell_type": "code",
|
240 |
| - "execution_count": null, |
| 230 | + "execution_count": 6, |
241 | 231 | "metadata": {},
|
242 |
| - "outputs": [], |
| 232 | + "outputs": [ |
| 233 | + { |
| 234 | + "name": "stdout", |
| 235 | + "output_type": "stream", |
| 236 | + "text": [ |
| 237 | + "170904-06:02:02,387 workflow INFO:\n", |
| 238 | + "\t Executing node datagrabber in dir: /tmp/tmpiwew6ysu/datagrabber\n" |
| 239 | + ] |
| 240 | + }, |
| 241 | + { |
| 242 | + "data": { |
| 243 | + "text/plain": [ |
| 244 | + "\n", |
| 245 | + "anat = /data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz\n", |
| 246 | + "func = /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz" |
| 247 | + ] |
| 248 | + }, |
| 249 | + "execution_count": 6, |
| 250 | + "metadata": {}, |
| 251 | + "output_type": "execute_result" |
| 252 | + } |
| 253 | + ], |
243 | 254 | "source": [
|
244 | 255 | "dg.run().outputs"
|
245 | 256 | ]
|
|
268 | 279 | },
|
269 | 280 | {
|
270 | 281 | "cell_type": "code",
|
271 |
| - "execution_count": null, |
272 |
| - "metadata": { |
273 |
| - "collapsed": true |
274 |
| - }, |
| 282 | + "execution_count": 7, |
| 283 | + "metadata": {}, |
275 | 284 | "outputs": [],
|
276 | 285 | "source": [
|
277 | 286 | "from nipype import SelectFiles, Node\n",
|
|
302 | 311 | },
|
303 | 312 | {
|
304 | 313 | "cell_type": "code",
|
305 |
| - "execution_count": null, |
| 314 | + "execution_count": 8, |
306 | 315 | "metadata": {},
|
307 |
| - "outputs": [], |
| 316 | + "outputs": [ |
| 317 | + { |
| 318 | + "name": "stdout", |
| 319 | + "output_type": "stream", |
| 320 | + "text": [ |
| 321 | + "170904-06:02:02,435 workflow INFO:\n", |
| 322 | + "\t Executing node selectfiles in dir: /tmp/tmpd3odxyze/selectfiles\n" |
| 323 | + ] |
| 324 | + }, |
| 325 | + { |
| 326 | + "data": { |
| 327 | + "text/plain": [ |
| 328 | + "\n", |
| 329 | + "anat = /data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz\n", |
| 330 | + "func = /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz" |
| 331 | + ] |
| 332 | + }, |
| 333 | + "execution_count": 8, |
| 334 | + "metadata": {}, |
| 335 | + "output_type": "execute_result" |
| 336 | + } |
| 337 | + ], |
308 | 338 | "source": [
|
309 | 339 | "sf.run().outputs"
|
310 | 340 | ]
|
|
324 | 354 | },
|
325 | 355 | {
|
326 | 356 | "cell_type": "code",
|
327 |
| - "execution_count": null, |
| 357 | + "execution_count": 9, |
328 | 358 | "metadata": {},
|
329 |
| - "outputs": [], |
| 359 | + "outputs": [ |
| 360 | + { |
| 361 | + "name": "stdout", |
| 362 | + "output_type": "stream", |
| 363 | + "text": [ |
| 364 | + "170904-06:02:02,458 workflow INFO:\n", |
| 365 | + "\t Executing node selectfiles in dir: /tmp/tmp53bxb6rj/selectfiles\n" |
| 366 | + ] |
| 367 | + }, |
| 368 | + { |
| 369 | + "data": { |
| 370 | + "text/plain": [ |
| 371 | + "\n", |
| 372 | + "anat = ['/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz', '/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz']" |
| 373 | + ] |
| 374 | + }, |
| 375 | + "execution_count": 9, |
| 376 | + "metadata": {}, |
| 377 | + "output_type": "execute_result" |
| 378 | + } |
| 379 | + ], |
330 | 380 | "source": [
|
331 | 381 | "from nipype import SelectFiles, Node\n",
|
332 | 382 | "from os.path import abspath as opap\n",
|
|
364 | 414 | "source": [
|
365 | 415 | "## FreeSurferSource\n",
|
366 | 416 | "\n",
|
367 |
| - "`FreeSurferSource` is a specific case of a file grabber that felicitates the data import of outputs from the FreeSurfer recon-all algorithm. This of course requires that you've already run `recon-all` on your subject.\n", |
368 |
| - "\n", |
369 |
| - "Before you can run `FreeSurferSource`, you first have to specify the path to the FreeSurfer output folder, i.e. you have to specify the SUBJECTS_DIR variable. This can be done as follows:" |
| 417 | + "`FreeSurferSource` is a specific case of a file grabber that felicitates the data import of outputs from the FreeSurfer recon-all algorithm. This of course requires that you've already run `recon-all` on your subject." |
| 418 | + ] |
| 419 | + }, |
| 420 | + { |
| 421 | + "cell_type": "markdown", |
| 422 | + "metadata": {}, |
| 423 | + "source": [ |
| 424 | + "For the tutorial dataset ``ds000114``, `recon-all` was already run. So, let's make sure that you have the anatomy output of one subject on your system:" |
370 | 425 | ]
|
371 | 426 | },
|
372 | 427 | {
|
373 | 428 | "cell_type": "code",
|
374 | 429 | "execution_count": null,
|
375 |
| - "metadata": { |
376 |
| - "collapsed": true |
377 |
| - }, |
| 430 | + "metadata": {}, |
| 431 | + "outputs": [], |
| 432 | + "source": [ |
| 433 | + "!datalad get -r -J4 /data/ds000114/derivatives/freesurfer/sub-01/" |
| 434 | + ] |
| 435 | + }, |
| 436 | + { |
| 437 | + "cell_type": "markdown", |
| 438 | + "metadata": {}, |
| 439 | + "source": [ |
| 440 | + "Now, before you can run `FreeSurferSource`, you first have to specify the path to the FreeSurfer output folder, i.e. you have to specify the SUBJECTS_DIR variable. This can be done as follows:" |
| 441 | + ] |
| 442 | + }, |
| 443 | + { |
| 444 | + "cell_type": "code", |
| 445 | + "execution_count": 21, |
| 446 | + "metadata": {}, |
378 | 447 | "outputs": [],
|
379 | 448 | "source": [
|
380 | 449 | "from nipype.interfaces.freesurfer import FSCommand\n",
|
381 | 450 | "from os.path import abspath as opap\n",
|
382 | 451 | "\n",
|
383 | 452 | "# Path to your freesurfer output folder\n",
|
384 |
| - "fs_dir = opap('/data/ds000114/derivatives/freesurfer')\n", |
| 453 | + "fs_dir = opap('/data/ds000114/derivatives/freesurfer/')\n", |
385 | 454 | "\n",
|
386 | 455 | "# Set SUBJECTS_DIR\n",
|
387 | 456 | "FSCommand.set_default_subjects_dir(fs_dir)"
|
|
396 | 465 | },
|
397 | 466 | {
|
398 | 467 | "cell_type": "code",
|
399 |
| - "execution_count": null, |
400 |
| - "metadata": { |
401 |
| - "collapsed": true |
402 |
| - }, |
| 468 | + "execution_count": 22, |
| 469 | + "metadata": {}, |
403 | 470 | "outputs": [],
|
404 | 471 | "source": [
|
405 | 472 | "from nipype import Node\n",
|
|
419 | 486 | },
|
420 | 487 | {
|
421 | 488 | "cell_type": "code",
|
422 |
| - "execution_count": null, |
| 489 | + "execution_count": 23, |
423 | 490 | "metadata": {},
|
424 |
| - "outputs": [], |
| 491 | + "outputs": [ |
| 492 | + { |
| 493 | + "name": "stdout", |
| 494 | + "output_type": "stream", |
| 495 | + "text": [ |
| 496 | + "170904-06:04:52,28 workflow INFO:\n", |
| 497 | + "\t Executing node fssource in dir: /tmp/tmpisu77m7r/fssource\n" |
| 498 | + ] |
| 499 | + } |
| 500 | + ], |
425 | 501 | "source": [
|
426 | 502 | "fssource.inputs.subject_id = 'sub-01'\n",
|
427 | 503 | "result = fssource.run() "
|
|
436 | 512 | },
|
437 | 513 | {
|
438 | 514 | "cell_type": "code",
|
439 |
| - "execution_count": null, |
| 515 | + "execution_count": 24, |
440 | 516 | "metadata": {},
|
441 |
| - "outputs": [], |
| 517 | + "outputs": [ |
| 518 | + { |
| 519 | + "name": "stdout", |
| 520 | + "output_type": "stream", |
| 521 | + "text": [ |
| 522 | + "aparc_aseg: ['/data/ds000114/derivatives/freesurfer/sub-01/mri/aparc+aseg.mgz', '/data/ds000114/derivatives/freesurfer/sub-01/mri/aparc.a2009s+aseg.mgz', '/data/ds000114/derivatives/freesurfer/sub-01/mri/aparc.dktatlas+aseg.mgz']\n", |
| 523 | + "\n", |
| 524 | + "brainmask: /data/ds000114/derivatives/freesurfer/sub-01/mri/brainmask.mgz\n", |
| 525 | + "\n", |
| 526 | + "inflated: ['/data/ds000114/derivatives/freesurfer/sub-01/surf/rh.inflated', '/data/ds000114/derivatives/freesurfer/sub-01/surf/lh.inflated']\n", |
| 527 | + "\n" |
| 528 | + ] |
| 529 | + } |
| 530 | + ], |
442 | 531 | "source": [
|
443 | 532 | "print('aparc_aseg: %s\\n' % result.outputs.aparc_aseg)\n",
|
444 | 533 | "print('brainmask: %s\\n' % result.outputs.brainmask)\n",
|
|
454 | 543 | },
|
455 | 544 | {
|
456 | 545 | "cell_type": "code",
|
457 |
| - "execution_count": null, |
| 546 | + "execution_count": 25, |
458 | 547 | "metadata": {},
|
459 |
| - "outputs": [], |
| 548 | + "outputs": [ |
| 549 | + { |
| 550 | + "name": "stdout", |
| 551 | + "output_type": "stream", |
| 552 | + "text": [ |
| 553 | + "170904-06:04:54,346 workflow INFO:\n", |
| 554 | + "\t Executing node fssource in dir: /tmp/tmpisu77m7r/fssource\n" |
| 555 | + ] |
| 556 | + } |
| 557 | + ], |
460 | 558 | "source": [
|
461 | 559 | "fssource.inputs.hemi = 'lh'\n",
|
462 | 560 | "result = fssource.run()"
|
|
471 | 569 | },
|
472 | 570 | {
|
473 | 571 | "cell_type": "code",
|
474 |
| - "execution_count": null, |
| 572 | + "execution_count": 26, |
475 | 573 | "metadata": {},
|
476 |
| - "outputs": [], |
| 574 | + "outputs": [ |
| 575 | + { |
| 576 | + "data": { |
| 577 | + "text/plain": [ |
| 578 | + "'/data/ds000114/derivatives/freesurfer/sub-01/surf/lh.inflated'" |
| 579 | + ] |
| 580 | + }, |
| 581 | + "execution_count": 26, |
| 582 | + "metadata": {}, |
| 583 | + "output_type": "execute_result" |
| 584 | + } |
| 585 | + ], |
477 | 586 | "source": [
|
478 | 587 | "result.outputs.inflated"
|
479 | 588 | ]
|
|
503 | 612 | "name": "python",
|
504 | 613 | "nbconvert_exporter": "python",
|
505 | 614 | "pygments_lexer": "ipython3",
|
506 |
| - "version": "3.5.2" |
| 615 | + "version": "3.6.2" |
507 | 616 | }
|
508 | 617 | },
|
509 | 618 | "nbformat": 4,
|
|
0 commit comments