Skip to content

Commit 735d09c

Browse files
committed
FIX: reset previous changes to make examples work with derivative files
1 parent 317bf09 commit 735d09c

File tree

4 files changed

+70
-28
lines changed

4 files changed

+70
-28
lines changed

notebooks/example_1stlevel.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
"outputs": [],
432432
"source": [
433433
"from nilearn.plotting import plot_stat_map\n",
434-
"anatimg = '/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz'"
434+
"anatimg = '/data/ds000114/derivatives/fmriprep/sub-02/anat/sub-02_t1w_preproc.nii.gz'"
435435
]
436436
},
437437
{
@@ -553,7 +553,7 @@
553553
"source": [
554554
"plot_stat_map(\n",
555555
" '/output/datasink/1stLevel/sub-01/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-01',\n",
556-
" bg_img='/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz',\n",
556+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_preproc.nii.gz',\n",
557557
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
558558
]
559559
},
@@ -565,7 +565,7 @@
565565
"source": [
566566
"plot_stat_map(\n",
567567
" '/output/datasink/1stLevel/sub-02/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-02',\n",
568-
" bg_img='/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz',\n",
568+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-02/anat/sub-02_t1w_preproc.nii.gz',\n",
569569
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
570570
]
571571
},
@@ -577,7 +577,7 @@
577577
"source": [
578578
"plot_stat_map(\n",
579579
" '/output/datasink/1stLevel/sub-03/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-03',\n",
580-
" bg_img='/data/ds000114/sub-03/ses-test/anat/sub-03_ses-test_T1w.nii.gz',\n",
580+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-03/anat/sub-03_t1w_preproc.nii.gz',\n",
581581
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
582582
]
583583
},
@@ -589,7 +589,7 @@
589589
"source": [
590590
"plot_stat_map(\n",
591591
" '/output/datasink/1stLevel/sub-04/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-04',\n",
592-
" bg_img='/data/ds000114/sub-04/ses-test/anat/sub-04_ses-test_T1w.nii.gz',\n",
592+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-04/anat/sub-04_t1w_preproc.nii.gz',\n",
593593
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
594594
]
595595
},
@@ -601,7 +601,7 @@
601601
"source": [
602602
"plot_stat_map(\n",
603603
" '/output/datasink/1stLevel/sub-05/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-05',\n",
604-
" bg_img='/data/ds000114/sub-05/ses-test/anat/sub-05_ses-test_T1w.nii.gz',\n",
604+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-05/anat/sub-05_t1w_preproc.nii.gz',\n",
605605
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
606606
]
607607
},
@@ -613,7 +613,7 @@
613613
"source": [
614614
"plot_stat_map(\n",
615615
" '/output/datasink/1stLevel/sub-06/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-06',\n",
616-
" bg_img='/data/ds000114/sub-06/ses-test/anat/sub-06_ses-test_T1w.nii.gz',\n",
616+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-06/anat/sub-06_t1w_preproc.nii.gz',\n",
617617
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
618618
]
619619
},
@@ -625,7 +625,7 @@
625625
"source": [
626626
"plot_stat_map(\n",
627627
" '/output/datasink/1stLevel/sub-07/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-07',\n",
628-
" bg_img='/data/ds000114/sub-07/ses-test/anat/sub-07_ses-test_T1w.nii.gz',\n",
628+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-07/anat/sub-07_t1w_preproc.nii.gz',\n",
629629
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
630630
]
631631
},
@@ -637,7 +637,7 @@
637637
"source": [
638638
"plot_stat_map(\n",
639639
" '/output/datasink/1stLevel/sub-08/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-08',\n",
640-
" bg_img='/data/ds000114/sub-08/ses-test/anat/sub-08_ses-test_T1w.nii.gz',\n",
640+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-08/anat/sub-08_t1w_preproc.nii.gz',\n",
641641
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
642642
]
643643
},
@@ -649,7 +649,7 @@
649649
"source": [
650650
"plot_stat_map(\n",
651651
" '/output/datasink/1stLevel/sub-09/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-09',\n",
652-
" bg_img='/data/ds000114/sub-09/ses-test/anat/sub-09_ses-test_T1w.nii.gz',\n",
652+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-09/anat/sub-09_t1w_preproc.nii.gz',\n",
653653
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
654654
]
655655
},
@@ -661,7 +661,7 @@
661661
"source": [
662662
"plot_stat_map(\n",
663663
" '/output/datasink/1stLevel/sub-10/fwhm-4/spmT_0002.nii', title='finger - fwhm=4 - sub-10',\n",
664-
" bg_img='/data/ds000114/sub-10/ses-test/anat/sub-10_ses-test_T1w.nii.gz',\n",
664+
" bg_img='/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_preproc.nii.gz',\n",
665665
" threshold=3, display_mode='y', cut_coords=(5, 10, 15, 20), dim=-1);"
666666
]
667667
},

notebooks/example_2ndlevel.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
"cell_type": "code",
243243
"execution_count": null,
244244
"metadata": {
245-
"scrolled": false
245+
"scrolled": true
246246
},
247247
"outputs": [],
248248
"source": [

notebooks/example_normalize.ipynb

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"## Normalization with ANTs\n",
19-
"\n",
20-
"The normalization with ANTs requires that you first compute the transformation matrix that would bring the anatomical images of each subject into template space. Depending on your system this might take a few hours per subject. To facilitate this step, the transformation matrix is already computed for the T1 images.\n",
18+
"## Preparation\n",
2119
"\n",
22-
"The data for it can be found under:"
20+
"Before we can start with the ANTs example, we first need to download the already computed deforamation field. The data can be found in the `derivatives/fmriprep` folder of the dataset and can be downloaded with the following `datalad` command:"
2321
]
2422
},
2523
{
@@ -28,16 +26,34 @@
2826
"metadata": {},
2927
"outputs": [],
3028
"source": [
31-
"!ls /data/ds000114/derivatives/fmriprep/sub-*/anat/*h5"
29+
"%%bash\n",
30+
"datalad get -J4 /data/ds000114/derivatives/fmriprep/sub-*/anat/*h5"
31+
]
32+
},
33+
{
34+
"cell_type": "markdown",
35+
"metadata": {},
36+
"source": [
37+
"**Note:** This might take a while, as datalad needs to download ~1000MB of data"
3238
]
3339
},
3440
{
3541
"cell_type": "markdown",
3642
"metadata": {},
3743
"source": [
38-
"If you want to compute the transformation matrix yourself, either use [fmriprep](http://fmriprep.readthedocs.io), as in our example dataset.\n",
44+
"### Alternatively: Prepare yourself\n",
45+
"We're using the precomputed warp field from [fmriprep](http://fmriprep.readthedocs.io), as this step otherwise would take a up to 10 hours or more for all subjects to complete. If you're nonetheless interested in computing the warp parameters with ANTs yourself, without using [fmriprep](http://fmriprep.readthedocs.io), either check out the script [ANTS_registration.py](https://github.com/miykael/nipype_tutorial/blob/master/notebooks/scripts/ANTS_registration.py) or even quicker, use [RegistrationSynQuick](http://nipype.readthedocs.io/en/latest/interfaces/generated/interfaces.ants/registration.html#registrationsynquick), Nipype's implementation of `antsRegistrationSynQuick.sh`."
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"metadata": {},
51+
"source": [
52+
"## Normalization with ANTs\n",
53+
"\n",
54+
"The normalization with ANTs requires that you first compute the transformation matrix that would bring the anatomical images of each subject into template space. Depending on your system this might take a few hours per subject. To facilitate this step, the transformation matrix is already computed for the T1 images.\n",
3955
"\n",
40-
"Alternatively, you can also create a ANTS registration pipeline yourself. An example of such a pipeline would look as follows (**note, that you can remove the comment character to load the script to see the workflow, but you don't have to run it, we will NOT use the output of the workflow in this nothebook**):"
56+
"The data for it can be found under:"
4157
]
4258
},
4359
{
@@ -46,7 +62,7 @@
4662
"metadata": {},
4763
"outputs": [],
4864
"source": [
49-
"#%load scripts/ANTS_registration.py"
65+
"!ls /data/ds000114/derivatives/fmriprep/sub-*/anat/*h5"
5066
]
5167
},
5268
{
@@ -115,7 +131,7 @@
115131
"cell_type": "markdown",
116132
"metadata": {},
117133
"source": [
118-
"**Note** that the **``template``** file might not be in your ``data`` directory. To get ``mni_icbm152_nlin_asym_09c``, either download it from this [website](https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/580705089ad5a101f17944a9), unpack it and move it to ``/data/ds000114/derivatives/fmriprep/`` or run the following command in a cell:"
134+
"**Note** if you're not using the corresponding docker image, than the **``template``** file might not be in your ``data`` directory. To get ``mni_icbm152_nlin_asym_09c``, either download it from this [website](https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/580705089ad5a101f17944a9), unpack it and move it to ``/data/ds000114/derivatives/fmriprep/`` or run the following command in a cell:"
119135
]
120136
},
121137
{
@@ -387,8 +403,8 @@
387403
"# SelectFiles - to grab the data (alternativ to DataGrabber)\n",
388404
"templates = {'con': opj(output_dir, '1stLevel',\n",
389405
" '{subject_id}/fwhm-{fwhm_id}', '???_00??.nii'),\n",
390-
" 'anat': opj('/data/ds000114', '{subject_id}', 'ses-test',\n",
391-
" 'anat', '{subject_id}_ses-test_T1w.nii.gz')}\n",
406+
" 'anat': opj('/data/ds000114/derivatives', 'fmriprep', '{subject_id}',\n",
407+
" 'anat', '{subject_id}_t1w_preproc.nii.gz')}\n",
392408
"\n",
393409
"selectfiles = Node(SelectFiles(templates,\n",
394410
" base_directory=experiment_dir,\n",
@@ -519,7 +535,7 @@
519535
" title='anatomy - ANTs (normalized to ICBM152)', bg_img=anatimg,\n",
520536
" threshold=200, display_mode='ortho', cut_coords=(-50, 0, -10));\n",
521537
"plot_stat_map(\n",
522-
" '/output/datasink/norm_spm/sub-02_fwhm4/wsub-02_ses-test_T1w.nii',\n",
538+
" '/output/datasink/norm_spm/sub-02_fwhm4/wsub-02_t1w_preproc.nii',\n",
523539
" title='anatomy - SPM (normalized to SPM\\'s TPM)', bg_img=anatimg,\n",
524540
" threshold=200, display_mode='ortho', cut_coords=(-50, 0, -10));"
525541
]

notebooks/example_preprocessing.ipynb

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,32 @@
1818
"cell_type": "markdown",
1919
"metadata": {},
2020
"source": [
21+
"## Preparation\n",
22+
"\n",
23+
"Before we can start with anything we first need to download the data (the other 9 subjects in the dataset). This can be done very quickly with the following `datalad` command.\n",
24+
"\n",
25+
"**Note:** This might take a while, as datalad needs to download ~700MB of data"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": null,
31+
"metadata": {
32+
"scrolled": true
33+
},
34+
"outputs": [],
35+
"source": [
36+
"%%bash\n",
37+
"datalad get -J4 /data/ds000114/derivatives/fmriprep/sub-*/anat/*preproc.nii.gz \\\n",
38+
" /data/ds000114/sub-*/ses-test/func/*fingerfootlips*"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {},
44+
"source": [
45+
"## Inspect the data\n",
46+
"\n",
2147
"For every subject we have one anatomical T1w and 5 functional images. As a short recap, the image properties of the anatomy and the **fingerfootlips** functional image are:"
2248
]
2349
},
@@ -28,8 +54,8 @@
2854
"outputs": [],
2955
"source": [
3056
"%%bash\n",
31-
"cd /data/ds000114/sub-01/ses-test\n",
32-
"nib-ls a*/*.nii.gz f*/*fingerfootlips*.nii.gz"
57+
"cd /data/ds000114/\n",
58+
"nib-ls derivatives/fmriprep/sub-01/*/*t1w_preproc.nii.gz sub-01/ses-test/f*/*fingerfootlips*.nii.gz"
3359
]
3460
},
3561
{
@@ -251,7 +277,7 @@
251277
" ('task_name', task_list)]\n",
252278
"\n",
253279
"# SelectFiles - to grab the data (alternativ to DataGrabber)\n",
254-
"anat_file = opj('{subject_id}', 'ses-test', 'anat', '{subject_id}_ses-test_T1w.nii.gz')\n",
280+
"anat_file = opj('derivatives', 'fmriprep', '{subject_id}', 'anat', '{subject_id}_t1w_preproc.nii.gz')\n",
255281
"func_file = opj('{subject_id}', 'ses-test', 'func',\n",
256282
" '{subject_id}_ses-test_task-{task_name}_bold.nii.gz')\n",
257283
"\n",
@@ -427,7 +453,7 @@
427453
"outputs": [],
428454
"source": [
429455
"plotting.plot_epi(\n",
430-
" '/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz',\n",
456+
" '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_preproc.nii.gz',\n",
431457
" title=\"T1\", display_mode='ortho', annotate=False, draw_cross=False, cmap='gray');"
432458
]
433459
},

0 commit comments

Comments
 (0)