Data input for BIDS datasets

DataGrabber and SelectFiles are great if you are dealing with generic datasets with arbitrary organization. However, if you have decided to use Brain Imaging Data Structure (BIDS) to organize your data (or got your hands on a BIDS dataset) you can take advantage of a formal structure BIDS imposes. In this short tutorial, you will learn how to do this.

pybids - a Python API for working with BIDS datasets

pybids is a lightweight python API for querying BIDS folder structure for specific files and metadata. You can install it from PyPi:

pip install pybids

Please note it should be already installed in the tutorial Docker image.

The layout object and simple queries

To begin working with pybids we need to initialize a layout object. We will need it to do all of our queries

In [ ]:
from bids.layout import BIDSLayout
layout = BIDSLayout("/data/ds000114/")
In [ ]:
!tree -L 4 /data/ds000114/
/data/ds000114/
├── CHANGES
├── dataset_description.json
├── derivatives
│   ├── fmriprep
│   │   ├── mni_icbm152_nlin_asym_09c
│   │   │   ├── 1mm_brainmask.nii.gz
│   │   │   ├── 1mm_T1.nii.gz
│   │   │   ├── 1mm_tpm_csf.nii.gz
│   │   │   ├── 1mm_tpm_gm.nii.gz
│   │   │   ├── 1mm_tpm_wm.nii.gz
│   │   │   ├── 2mm_brainmask.nii.gz
│   │   │   ├── 2mm_T1.nii.gz
│   │   │   ├── 2mm_tpm_csf.nii.gz
│   │   │   ├── 2mm_tpm_gm.nii.gz
│   │   │   ├── 2mm_tpm_wm.nii.gz
│   │   │   └── scripts
│   │   ├── sub-01
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-01.html -> .git/annex/objects/MF/jw/MD5E-s20077561--03ecea8730492d537e050941bdf654bf.html/MD5E-s20077561--03ecea8730492d537e050941bdf654bf.html
│   │   ├── sub-02
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-02.html -> .git/annex/objects/99/j3/MD5E-s19975906--5ede67fcdad59b65a02f572360db2863.html/MD5E-s19975906--5ede67fcdad59b65a02f572360db2863.html
│   │   ├── sub-03
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-03.html -> .git/annex/objects/z4/8w/MD5E-s20227534--64e1a981338e8fb9c87f026a79a34785.html/MD5E-s20227534--64e1a981338e8fb9c87f026a79a34785.html
│   │   ├── sub-04
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-04.html -> .git/annex/objects/qF/J1/MD5E-s22389786--2954e6ece2a825c0008e9b1dcfcaf0a6.html/MD5E-s22389786--2954e6ece2a825c0008e9b1dcfcaf0a6.html
│   │   ├── sub-05
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-05.html -> .git/annex/objects/6G/Z6/MD5E-s22109848--70a1908c811102744f39b87ae03216a2.html/MD5E-s22109848--70a1908c811102744f39b87ae03216a2.html
│   │   ├── sub-06
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-06.html -> .git/annex/objects/k9/gx/MD5E-s21892649--c22445c2264626ea8537b440a280d240.html/MD5E-s21892649--c22445c2264626ea8537b440a280d240.html
│   │   ├── sub-07
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-07.html -> .git/annex/objects/4v/vV/MD5E-s19939423--f9c96cb528fb62ebde2d33bb6a69cb8b.html/MD5E-s19939423--f9c96cb528fb62ebde2d33bb6a69cb8b.html
│   │   ├── sub-08
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-08.html -> .git/annex/objects/Kj/P0/MD5E-s21484045--93abf611fe734778dedbfb65ce983e42.html/MD5E-s21484045--93abf611fe734778dedbfb65ce983e42.html
│   │   ├── sub-09
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   ├── sub-09.html -> .git/annex/objects/9M/J0/MD5E-s21261086--9eaa82886171bc130c560ad95e9399ce.html/MD5E-s21261086--9eaa82886171bc130c560ad95e9399ce.html
│   │   ├── sub-10
│   │   │   ├── anat
│   │   │   ├── ses-retest
│   │   │   └── ses-test
│   │   └── sub-10.html -> .git/annex/objects/54/fp/MD5E-s19211083--9cd49ee07578dfdf58246243af5faf16.html/MD5E-s19211083--9cd49ee07578dfdf58246243af5faf16.html
│   └── freesurfer
│       ├── fsaverage
│       │   ├── label
│       │   ├── mri
│       │   ├── mri.2mm
│       │   ├── scripts
│       │   ├── surf
│       │   └── xhemi
│       ├── fsaverage5
│       │   ├── label
│       │   ├── lh.reg.template.tif -> ../.git/annex/objects/Z0/0Q/MD5E-s2857556--0ab279c0acf06733b8360e10f9c1f3af.tif/MD5E-s2857556--0ab279c0acf06733b8360e10f9c1f3af.tif
│       │   ├── mri
│       │   ├── rh.reg.template.tif -> ../.git/annex/objects/WP/JF/MD5E-s2857636--abeff380f357f736c03bf6d9d6f2a69a.tif/MD5E-s2857636--abeff380f357f736c03bf6d9d6f2a69a.tif
│       │   ├── scripts
│       │   ├── stats
│       │   └── surf
│       ├── sub-01
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-02
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-03
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-04
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-05
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-06
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-07
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-08
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       ├── sub-09
│       │   ├── label
│       │   ├── mri
│       │   ├── scripts
│       │   ├── stats
│       │   ├── surf
│       │   └── touch
│       └── sub-10
│           ├── label
│           ├── mri
│           ├── scripts
│           ├── stats
│           ├── surf
│           └── touch
├── dwi.bval -> .git/annex/objects/JX/4K/MD5E-s335--5bd6fa32ccd0c79e79f9ac63a2c09c1a.bval/MD5E-s335--5bd6fa32ccd0c79e79f9ac63a2c09c1a.bval
├── dwi.bvec -> .git/annex/objects/Pg/wk/MD5E-s1248--0641c68ff6ee6164928c984541653430.bvec/MD5E-s1248--0641c68ff6ee6164928c984541653430.bvec
├── sub-01
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-01_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/xm/25/MD5E-s8503839--3b3b49b2396b59ddd5a73b7f596f9e46.nii.gz/MD5E-s8503839--3b3b49b2396b59ddd5a73b7f596f9e46.nii.gz
│   │   ├── dwi
│   │   │   └── sub-01_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/0K/16/MD5E-s99899518--5ebac8e9e23180638dd68dde10b818be.nii.gz/MD5E-s99899518--5ebac8e9e23180638dd68dde10b818be.nii.gz
│   │   └── func
│   │       ├── sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/3q/Qf/MD5E-s22317848--b30f5b2f7a6039a3e384bcb40bec7e55.nii.gz/MD5E-s22317848--b30f5b2f7a6039a3e384bcb40bec7e55.nii.gz
│   │       ├── sub-01_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/26/6j/MD5E-s23793248--327e42d440f0557105bf7c05a3b9f1e8.nii.gz/MD5E-s23793248--327e42d440f0557105bf7c05a3b9f1e8.nii.gz
│   │       ├── sub-01_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/qv/gf/MD5E-s30728838--58392e3ead9caeefe148a57c71dd5b44.nii.gz/MD5E-s30728838--58392e3ead9caeefe148a57c71dd5b44.nii.gz
│   │       ├── sub-01_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/QK/9Q/MD5E-s4934--30ef35f37e4a035beb9105ff6f4e1e1f.tsv/MD5E-s4934--30ef35f37e4a035beb9105ff6f4e1e1f.tsv
│   │       ├── sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Fx/6K/MD5E-s11839146--5f62c005467de0dabc6ebcd09c3e7ec3.nii.gz/MD5E-s11839146--5f62c005467de0dabc6ebcd09c3e7ec3.nii.gz
│   │       └── sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/x3/qW/MD5E-s10162063--a86a0f448872de33a901a6b639e975c9.nii.gz/MD5E-s10162063--a86a0f448872de33a901a6b639e975c9.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-01_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/QP/jm/MD5E-s8677710--d6820f6cb8fb965e864419c14f6a22d5.nii.gz/MD5E-s8677710--d6820f6cb8fb965e864419c14f6a22d5.nii.gz
│       ├── dwi
│       │   └── sub-01_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/X2/kJ/MD5E-s104193417--454850ac9ed1c96c40b6b7946e51bf71.nii.gz/MD5E-s104193417--454850ac9ed1c96c40b6b7946e51bf71.nii.gz
│       └── func
│           ├── sub-01_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/mx/zJ/MD5E-s22944165--71b1eda077a1003a177552f6c380323a.nii.gz/MD5E-s22944165--71b1eda077a1003a177552f6c380323a.nii.gz
│           ├── sub-01_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/k6/4f/MD5E-s24454931--e9ab535d84a922b0c7ed52461244cf47.nii.gz/MD5E-s24454931--e9ab535d84a922b0c7ed52461244cf47.nii.gz
│           ├── sub-01_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/32/Qq/MD5E-s31617092--151bc230c3b577110883369b6fad0daa.nii.gz/MD5E-s31617092--151bc230c3b577110883369b6fad0daa.nii.gz
│           ├── sub-01_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/vf/x3/MD5E-s4939--e9cef6b5ba48c5e3236747d208cf9668.tsv/MD5E-s4939--e9cef6b5ba48c5e3236747d208cf9668.tsv
│           ├── sub-01_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/p3/fZ/MD5E-s12048980--648c9094579aa5d047a5f6db468f9bc9.nii.gz/MD5E-s12048980--648c9094579aa5d047a5f6db468f9bc9.nii.gz
│           └── sub-01_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/56/GV/MD5E-s10362270--6a5c483d118db28ff8a62455def5501c.nii.gz/MD5E-s10362270--6a5c483d118db28ff8a62455def5501c.nii.gz
├── sub-02
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-02_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/VV/x2/MD5E-s8901003--6ad41304cbd57904227d914c054dcdc3.nii.gz/MD5E-s8901003--6ad41304cbd57904227d914c054dcdc3.nii.gz
│   │   ├── dwi
│   │   │   └── sub-02_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/ZZ/4X/MD5E-s101314358--9be934908a88073bc070e524651ee665.nii.gz/MD5E-s101314358--9be934908a88073bc070e524651ee665.nii.gz
│   │   └── func
│   │       ├── sub-02_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/vk/gK/MD5E-s22730907--26df7900a64e1d9f90e17ad0fa53145d.nii.gz/MD5E-s22730907--26df7900a64e1d9f90e17ad0fa53145d.nii.gz
│   │       ├── sub-02_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/Jg/vq/MD5E-s24364271--593256c66ce88ed8aaef140a4b37c6ec.nii.gz/MD5E-s24364271--593256c66ce88ed8aaef140a4b37c6ec.nii.gz
│   │       ├── sub-02_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/pZ/GJ/MD5E-s31238024--929a3999fa92002e571bec60f7343b65.nii.gz/MD5E-s31238024--929a3999fa92002e571bec60f7343b65.nii.gz
│   │       ├── sub-02_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/3K/wG/MD5E-s4888--e89bad630d80cd29bc3abc4349b0c644.tsv/MD5E-s4888--e89bad630d80cd29bc3abc4349b0c644.tsv
│   │       ├── sub-02_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/35/2V/MD5E-s12039294--070d0299974f916bdee0791985381593.nii.gz/MD5E-s12039294--070d0299974f916bdee0791985381593.nii.gz
│   │       └── sub-02_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/Z4/0G/MD5E-s10369674--71d655f61e4ce98ae7761ce76e3c30f9.nii.gz/MD5E-s10369674--71d655f61e4ce98ae7761ce76e3c30f9.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-02_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/qq/gm/MD5E-s10025785--0e790e210a275d76e3f2f4d895df6358.nii.gz/MD5E-s10025785--0e790e210a275d76e3f2f4d895df6358.nii.gz
│       ├── dwi
│       │   └── sub-02_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/8x/vp/MD5E-s104222416--86575d07809e9c717079592a12c69344.nii.gz/MD5E-s104222416--86575d07809e9c717079592a12c69344.nii.gz
│       └── func
│           ├── sub-02_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/F6/6J/MD5E-s23349944--2a2b8bc1f3d90e84d879bdd4638103c8.nii.gz/MD5E-s23349944--2a2b8bc1f3d90e84d879bdd4638103c8.nii.gz
│           ├── sub-02_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/pG/k1/MD5E-s24882575--75c39bee9e25e02c629dfcce1b378589.nii.gz/MD5E-s24882575--75c39bee9e25e02c629dfcce1b378589.nii.gz
│           ├── sub-02_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/WM/m9/MD5E-s32248732--4cd877de7b4c66e073610dffb67dfbcc.nii.gz/MD5E-s32248732--4cd877de7b4c66e073610dffb67dfbcc.nii.gz
│           ├── sub-02_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/XJ/2g/MD5E-s4882--01bacc601e70a375193045c052d4a5fe.tsv/MD5E-s4882--01bacc601e70a375193045c052d4a5fe.tsv
│           ├── sub-02_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Jz/zM/MD5E-s12348374--67f259c7e0bbb0fe39e747be5f905a4b.nii.gz/MD5E-s12348374--67f259c7e0bbb0fe39e747be5f905a4b.nii.gz
│           └── sub-02_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/6g/Zw/MD5E-s10496422--bae24132d514bb028ca8a3d749363bd9.nii.gz/MD5E-s10496422--bae24132d514bb028ca8a3d749363bd9.nii.gz
├── sub-03
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-03_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/64/vk/MD5E-s8125470--75575589e60ce58d95b4d72d3b4bf222.nii.gz/MD5E-s8125470--75575589e60ce58d95b4d72d3b4bf222.nii.gz
│   │   ├── dwi
│   │   │   └── sub-03_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/Pf/07/MD5E-s101660442--50491e142880d5f32b6c33cde372fb05.nii.gz/MD5E-s101660442--50491e142880d5f32b6c33cde372fb05.nii.gz
│   │   └── func
│   │       ├── sub-03_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/z1/0p/MD5E-s22709259--a01b5167228be96f007e84bab43e8b60.nii.gz/MD5E-s22709259--a01b5167228be96f007e84bab43e8b60.nii.gz
│   │       ├── sub-03_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/WG/k5/MD5E-s24175561--769ba7da6cac3318c47bc9215a77359b.nii.gz/MD5E-s24175561--769ba7da6cac3318c47bc9215a77359b.nii.gz
│   │       ├── sub-03_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/Qf/QX/MD5E-s31217356--89a8e84fbe0b5f019ce69d4ad643863c.nii.gz/MD5E-s31217356--89a8e84fbe0b5f019ce69d4ad643863c.nii.gz
│   │       ├── sub-03_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/1M/Vm/MD5E-s4877--4e73dbd6d1350b687be811d3d116a689.tsv/MD5E-s4877--4e73dbd6d1350b687be811d3d116a689.tsv
│   │       ├── sub-03_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Xx/q2/MD5E-s11992800--894dac07de9c8cddf6ea7e42f39f5c80.nii.gz/MD5E-s11992800--894dac07de9c8cddf6ea7e42f39f5c80.nii.gz
│   │       └── sub-03_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/7F/8p/MD5E-s10359493--9b3e5cc9933645901049c64c600ec6ca.nii.gz/MD5E-s10359493--9b3e5cc9933645901049c64c600ec6ca.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-03_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/P9/kj/MD5E-s7970968--75bb38265ea96864bfa0b012ba21b0b0.nii.gz/MD5E-s7970968--75bb38265ea96864bfa0b012ba21b0b0.nii.gz
│       ├── dwi
│       │   └── sub-03_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/F3/Pf/MD5E-s106544064--badea2659bd4440ff4c20e2f149034cc.nii.gz/MD5E-s106544064--badea2659bd4440ff4c20e2f149034cc.nii.gz
│       └── func
│           ├── sub-03_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/J6/f0/MD5E-s23145742--a792c0592cb77a161eb5d000a618c17c.nii.gz/MD5E-s23145742--a792c0592cb77a161eb5d000a618c17c.nii.gz
│           ├── sub-03_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/gp/QM/MD5E-s24520513--0fd08e07bbee37ac9efe14c7b265299a.nii.gz/MD5E-s24520513--0fd08e07bbee37ac9efe14c7b265299a.nii.gz
│           ├── sub-03_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/mP/mg/MD5E-s31785134--76856b9d6c90730144196aa48e4d9a9f.nii.gz/MD5E-s31785134--76856b9d6c90730144196aa48e4d9a9f.nii.gz
│           ├── sub-03_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/2q/qK/MD5E-s4943--df69ebd4a36adefa43dd1e5833a6cc91.tsv/MD5E-s4943--df69ebd4a36adefa43dd1e5833a6cc91.tsv
│           ├── sub-03_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/w3/XQ/MD5E-s12159084--67f84031d332467dae91107e53f0d89e.nii.gz/MD5E-s12159084--67f84031d332467dae91107e53f0d89e.nii.gz
│           └── sub-03_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/Qk/kK/MD5E-s10552089--e00b7544d9c44dddcd966e2c1dcd468f.nii.gz/MD5E-s10552089--e00b7544d9c44dddcd966e2c1dcd468f.nii.gz
├── sub-04
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-04_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/z9/V6/MD5E-s10125819--92fcdbdd50bb334651e474417237a7f2.nii.gz/MD5E-s10125819--92fcdbdd50bb334651e474417237a7f2.nii.gz
│   │   ├── dwi
│   │   │   └── sub-04_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/0Q/z6/MD5E-s102315940--827455ba66acecb6a2c8b9222bcd9fa1.nii.gz/MD5E-s102315940--827455ba66acecb6a2c8b9222bcd9fa1.nii.gz
│   │   └── func
│   │       ├── sub-04_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/6G/PV/MD5E-s24644977--c2411e3bad71cddeb2c083f999d22f93.nii.gz/MD5E-s24644977--c2411e3bad71cddeb2c083f999d22f93.nii.gz
│   │       ├── sub-04_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/Jf/m1/MD5E-s26197435--1ec999d21c0039897b67f38f5870d70c.nii.gz/MD5E-s26197435--1ec999d21c0039897b67f38f5870d70c.nii.gz
│   │       ├── sub-04_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/J2/v9/MD5E-s33748727--044de5969956d86b7cdee0eb36e26c9e.nii.gz/MD5E-s33748727--044de5969956d86b7cdee0eb36e26c9e.nii.gz
│   │       ├── sub-04_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/Pv/Mg/MD5E-s4944--a83df0296cd6fda128072efff0d651ca.tsv/MD5E-s4944--a83df0296cd6fda128072efff0d651ca.tsv
│   │       ├── sub-04_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Kf/5K/MD5E-s12862957--a356882c1f18391f2f5215bda39f817f.nii.gz/MD5E-s12862957--a356882c1f18391f2f5215bda39f817f.nii.gz
│   │       └── sub-04_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/70/k3/MD5E-s11172082--dcd559966a66e0645cb98a9b13c67a6c.nii.gz/MD5E-s11172082--dcd559966a66e0645cb98a9b13c67a6c.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-04_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/mg/5z/MD5E-s9717713--7764ef9c3fb344f69f1c2eb34cd56046.nii.gz/MD5E-s9717713--7764ef9c3fb344f69f1c2eb34cd56046.nii.gz
│       ├── dwi
│       │   └── sub-04_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/W0/Gk/MD5E-s104883316--ec0aec8977aa5a5c0901cd9d2e25347c.nii.gz/MD5E-s104883316--ec0aec8977aa5a5c0901cd9d2e25347c.nii.gz
│       └── func
│           ├── sub-04_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/GX/QK/MD5E-s24677139--d835385cb69d9907d6b0cb7311a91ff3.nii.gz/MD5E-s24677139--d835385cb69d9907d6b0cb7311a91ff3.nii.gz
│           ├── sub-04_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/Qv/qX/MD5E-s26270785--61f837b1ef1f667975ab25b820844d93.nii.gz/MD5E-s26270785--61f837b1ef1f667975ab25b820844d93.nii.gz
│           ├── sub-04_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/gk/3p/MD5E-s33823763--377e091ada8819942070a374b71ea986.nii.gz/MD5E-s33823763--377e091ada8819942070a374b71ea986.nii.gz
│           ├── sub-04_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/ZF/Pm/MD5E-s4963--df695f2ef7be302fb9ba8f0e03d0c8c8.tsv/MD5E-s4963--df695f2ef7be302fb9ba8f0e03d0c8c8.tsv
│           ├── sub-04_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/0Q/jG/MD5E-s12907201--46e3c39a8f7ec6c2f5b1ab157efa10d1.nii.gz/MD5E-s12907201--46e3c39a8f7ec6c2f5b1ab157efa10d1.nii.gz
│           └── sub-04_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/X5/FJ/MD5E-s11171792--bc9ba9ef24fcf364f3057401c17b1c49.nii.gz/MD5E-s11171792--bc9ba9ef24fcf364f3057401c17b1c49.nii.gz
├── sub-05
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-05_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/JK/PV/MD5E-s9511479--cec6ad961369ea1b21521d33040406d1.nii.gz/MD5E-s9511479--cec6ad961369ea1b21521d33040406d1.nii.gz
│   │   ├── dwi
│   │   │   └── sub-05_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/Mx/KM/MD5E-s104024235--7a107b0b7d70f0e0a60e5fccbda23f41.nii.gz/MD5E-s104024235--7a107b0b7d70f0e0a60e5fccbda23f41.nii.gz
│   │   └── func
│   │       ├── sub-05_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/x3/7x/MD5E-s24240966--89dc3e4888f5788e390be04cc91565ef.nii.gz/MD5E-s24240966--89dc3e4888f5788e390be04cc91565ef.nii.gz
│   │       ├── sub-05_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/V4/fV/MD5E-s25998505--071b1bd89a8d245b7a7a23323b434706.nii.gz/MD5E-s25998505--071b1bd89a8d245b7a7a23323b434706.nii.gz
│   │       ├── sub-05_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/3v/1w/MD5E-s33598359--952f5c8625b962a9f5ccb3d2bb58d1aa.nii.gz/MD5E-s33598359--952f5c8625b962a9f5ccb3d2bb58d1aa.nii.gz
│   │       ├── sub-05_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/vG/xZ/MD5E-s4843--3e56962b347260df61632b6d23853ac6.tsv/MD5E-s4843--3e56962b347260df61632b6d23853ac6.tsv
│   │       ├── sub-05_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/w0/75/MD5E-s12942731--e26171327d6bbdd4f392e1e327f92850.nii.gz/MD5E-s12942731--e26171327d6bbdd4f392e1e327f92850.nii.gz
│   │       └── sub-05_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/2V/K8/MD5E-s11109819--e0875ced4e44d9a144316893937a063b.nii.gz/MD5E-s11109819--e0875ced4e44d9a144316893937a063b.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-05_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/f1/XP/MD5E-s9942928--e32c1d5fb1d6db6449b19be10b5efc67.nii.gz/MD5E-s9942928--e32c1d5fb1d6db6449b19be10b5efc67.nii.gz
│       ├── dwi
│       │   └── sub-05_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/q3/gK/MD5E-s108049676--0d107c0acf9bed884baedfb7bc6a76e7.nii.gz/MD5E-s108049676--0d107c0acf9bed884baedfb7bc6a76e7.nii.gz
│       └── func
│           ├── sub-05_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/0z/1V/MD5E-s24924488--f11c9aec356aa58e53e7a154222f4e74.nii.gz/MD5E-s24924488--f11c9aec356aa58e53e7a154222f4e74.nii.gz
│           ├── sub-05_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/GK/P9/MD5E-s26693258--a904caebfaa372a21eb37231bae55299.nii.gz/MD5E-s26693258--a904caebfaa372a21eb37231bae55299.nii.gz
│           ├── sub-05_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/jW/X3/MD5E-s34416273--467b8d34b985d8caa2ac26e93506b775.nii.gz/MD5E-s34416273--467b8d34b985d8caa2ac26e93506b775.nii.gz
│           ├── sub-05_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/m5/Kg/MD5E-s4950--4603e9f4e09e05f555f8b0e3838c72ab.tsv/MD5E-s4950--4603e9f4e09e05f555f8b0e3838c72ab.tsv
│           ├── sub-05_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/fZ/Qx/MD5E-s13124683--f6b7dbf08272097300cf977ddc06a3a3.nii.gz/MD5E-s13124683--f6b7dbf08272097300cf977ddc06a3a3.nii.gz
│           └── sub-05_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/wP/ZP/MD5E-s11526323--f99a4f1f281cc1213c556b1f446724e5.nii.gz/MD5E-s11526323--f99a4f1f281cc1213c556b1f446724e5.nii.gz
├── sub-06
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-06_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/9W/pF/MD5E-s9712028--b4fbccf8add0667a4cba4306d2609bf6.nii.gz/MD5E-s9712028--b4fbccf8add0667a4cba4306d2609bf6.nii.gz
│   │   ├── dwi
│   │   │   └── sub-06_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/82/0m/MD5E-s102946238--20e290d95ed62fe68f5c73c3e057aa68.nii.gz/MD5E-s102946238--20e290d95ed62fe68f5c73c3e057aa68.nii.gz
│   │   └── func
│   │       ├── sub-06_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/KQ/41/MD5E-s24361814--23edea0b5a1c7b770ae89a700099482a.nii.gz/MD5E-s24361814--23edea0b5a1c7b770ae89a700099482a.nii.gz
│   │       ├── sub-06_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/MW/2q/MD5E-s26020756--5525a120e543de5a7c561eb0ac058c50.nii.gz/MD5E-s26020756--5525a120e543de5a7c561eb0ac058c50.nii.gz
│   │       ├── sub-06_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/kz/g4/MD5E-s33607078--55b31ff735c4a5d571e49ca0fa44ef3b.nii.gz/MD5E-s33607078--55b31ff735c4a5d571e49ca0fa44ef3b.nii.gz
│   │       ├── sub-06_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/2K/0p/MD5E-s4968--7bf3c8727a33112bf9dc55f4455f1fa3.tsv/MD5E-s4968--7bf3c8727a33112bf9dc55f4455f1fa3.tsv
│   │       ├── sub-06_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/qf/92/MD5E-s12884913--85e85fa3810ffbc274163169994516ce.nii.gz/MD5E-s12884913--85e85fa3810ffbc274163169994516ce.nii.gz
│   │       └── sub-06_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/zx/Mx/MD5E-s11071105--d4dc6401799624f330849cb2a26ecce0.nii.gz/MD5E-s11071105--d4dc6401799624f330849cb2a26ecce0.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-06_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/gm/9z/MD5E-s10429286--0dcb4734fa4f0bccc2f7b953e630e24d.nii.gz/MD5E-s10429286--0dcb4734fa4f0bccc2f7b953e630e24d.nii.gz
│       ├── dwi
│       │   └── sub-06_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/q4/Jf/MD5E-s111500846--b91fca5d1ca3b959becfc5da8923aab1.nii.gz/MD5E-s111500846--b91fca5d1ca3b959becfc5da8923aab1.nii.gz
│       └── func
│           ├── sub-06_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/K1/PM/MD5E-s25380586--d07bdf55b059b9532106bdf96c3d5be6.nii.gz/MD5E-s25380586--d07bdf55b059b9532106bdf96c3d5be6.nii.gz
│           ├── sub-06_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/V9/52/MD5E-s26868014--5c133cbc6d656f72433b1c5da1ea66e7.nii.gz/MD5E-s26868014--5c133cbc6d656f72433b1c5da1ea66e7.nii.gz
│           ├── sub-06_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/x0/Z9/MD5E-s34846203--cd71c6d597806515b0f8b956637c33a1.nii.gz/MD5E-s34846203--cd71c6d597806515b0f8b956637c33a1.nii.gz
│           ├── sub-06_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/0G/m9/MD5E-s4959--7e8c63e101c091f98edd21d50f970f91.tsv/MD5E-s4959--7e8c63e101c091f98edd21d50f970f91.tsv
│           ├── sub-06_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/KV/31/MD5E-s13292168--c6397d91154050fe59a42da6316b0d4b.nii.gz/MD5E-s13292168--c6397d91154050fe59a42da6316b0d4b.nii.gz
│           └── sub-06_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/6K/wQ/MD5E-s11225007--3a39708bd39fa2e4fadccbbf3056bb4e.nii.gz/MD5E-s11225007--3a39708bd39fa2e4fadccbbf3056bb4e.nii.gz
├── sub-07
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-07_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/wz/fx/MD5E-s8725991--d2be2d444bca2a33e53521f5aa9fafaa.nii.gz/MD5E-s8725991--d2be2d444bca2a33e53521f5aa9fafaa.nii.gz
│   │   ├── dwi
│   │   │   └── sub-07_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/wP/wJ/MD5E-s101870616--440ae52ddacae1affe2e1f59ac795dd3.nii.gz/MD5E-s101870616--440ae52ddacae1affe2e1f59ac795dd3.nii.gz
│   │   └── func
│   │       ├── sub-07_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Kk/4J/MD5E-s22958973--c4ed743b362967e6fa2da91f07fb5e4b.nii.gz/MD5E-s22958973--c4ed743b362967e6fa2da91f07fb5e4b.nii.gz
│   │       ├── sub-07_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/V3/KV/MD5E-s24493127--2a5924ea580a6156a268fd785ed5a920.nii.gz/MD5E-s24493127--2a5924ea580a6156a268fd785ed5a920.nii.gz
│   │       ├── sub-07_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/Fq/0m/MD5E-s31692006--899332b77616cec163c34a33133db1ad.nii.gz/MD5E-s31692006--899332b77616cec163c34a33133db1ad.nii.gz
│   │       ├── sub-07_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/53/0x/MD5E-s4911--9bc4d97c02654f838d56464701eb0c72.tsv/MD5E-s4911--9bc4d97c02654f838d56464701eb0c72.tsv
│   │       ├── sub-07_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/qf/Fx/MD5E-s12040345--b22b478fbe5db9a29a44a6181a9ca742.nii.gz/MD5E-s12040345--b22b478fbe5db9a29a44a6181a9ca742.nii.gz
│   │       └── sub-07_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/qZ/36/MD5E-s10217500--ff1be72ed50f666ffeca2aec2b33c9ed.nii.gz/MD5E-s10217500--ff1be72ed50f666ffeca2aec2b33c9ed.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-07_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/2Q/jJ/MD5E-s8580756--2f14ce817190386a6b4cbf77f89492e1.nii.gz/MD5E-s8580756--2f14ce817190386a6b4cbf77f89492e1.nii.gz
│       ├── dwi
│       │   └── sub-07_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/zG/84/MD5E-s103326300--7fdd20ad61b709937d1cc5bb2e0798c6.nii.gz/MD5E-s103326300--7fdd20ad61b709937d1cc5bb2e0798c6.nii.gz
│       └── func
│           ├── sub-07_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/V3/g1/MD5E-s23258547--3eac6de7ef215928b8e3124f19ea8a8c.nii.gz/MD5E-s23258547--3eac6de7ef215928b8e3124f19ea8a8c.nii.gz
│           ├── sub-07_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/Xf/kK/MD5E-s24751878--661682e4f762d7c99dbf049fcc658c87.nii.gz/MD5E-s24751878--661682e4f762d7c99dbf049fcc658c87.nii.gz
│           ├── sub-07_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/pG/qJ/MD5E-s32129273--5d4591dadeabaed078c7519da44178fb.nii.gz/MD5E-s32129273--5d4591dadeabaed078c7519da44178fb.nii.gz
│           ├── sub-07_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/Kp/QF/MD5E-s4929--e53ae38a58e2ca7d0f3736abe2a4dd03.tsv/MD5E-s4929--e53ae38a58e2ca7d0f3736abe2a4dd03.tsv
│           ├── sub-07_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/x4/J8/MD5E-s12271868--80db70ef7a5e5c78f7a5cdd16a636f11.nii.gz/MD5E-s12271868--80db70ef7a5e5c78f7a5cdd16a636f11.nii.gz
│           └── sub-07_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/zZ/61/MD5E-s10521017--969638eda30b31ad90b2403d5cc10b20.nii.gz/MD5E-s10521017--969638eda30b31ad90b2403d5cc10b20.nii.gz
├── sub-08
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-08_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/G3/j0/MD5E-s9815716--3ccef5772c262fd48ee053f97a3381ce.nii.gz/MD5E-s9815716--3ccef5772c262fd48ee053f97a3381ce.nii.gz
│   │   ├── dwi
│   │   │   └── sub-08_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/QJ/gw/MD5E-s104814386--e6cab512bec21cf56a56833041fb513c.nii.gz/MD5E-s104814386--e6cab512bec21cf56a56833041fb513c.nii.gz
│   │   └── func
│   │       ├── sub-08_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/QP/w0/MD5E-s24230763--51bc4ea41cba2f3a9d15be16f6c34d02.nii.gz/MD5E-s24230763--51bc4ea41cba2f3a9d15be16f6c34d02.nii.gz
│   │       ├── sub-08_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/48/X1/MD5E-s25800747--f446847b95b4e32814564f9197271ed9.nii.gz/MD5E-s25800747--f446847b95b4e32814564f9197271ed9.nii.gz
│   │       ├── sub-08_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/fP/63/MD5E-s33353778--6a1da1d5367e05e8a62702feeae571d9.nii.gz/MD5E-s33353778--6a1da1d5367e05e8a62702feeae571d9.nii.gz
│   │       ├── sub-08_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/mz/k6/MD5E-s4900--02b50bb6b5213319f49aad10b73f4a18.tsv/MD5E-s4900--02b50bb6b5213319f49aad10b73f4a18.tsv
│   │       ├── sub-08_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/75/86/MD5E-s12754775--52ec0425828a22ec5770d853aca3a446.nii.gz/MD5E-s12754775--52ec0425828a22ec5770d853aca3a446.nii.gz
│   │       └── sub-08_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/gW/KF/MD5E-s10970580--4060fc6ee9f4383aed5c49e4cded633a.nii.gz/MD5E-s10970580--4060fc6ee9f4383aed5c49e4cded633a.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-08_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/85/WP/MD5E-s9325328--35d0ce9fd75157df786d11c84b3c2178.nii.gz/MD5E-s9325328--35d0ce9fd75157df786d11c84b3c2178.nii.gz
│       ├── dwi
│       │   └── sub-08_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/MM/v4/MD5E-s102691986--702eadb2a87f9cc17b8c62c64b27a8fb.nii.gz/MD5E-s102691986--702eadb2a87f9cc17b8c62c64b27a8fb.nii.gz
│       └── func
│           ├── sub-08_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/4g/25/MD5E-s24002538--085dc82910b78be26a215d4c51194aea.nii.gz/MD5E-s24002538--085dc82910b78be26a215d4c51194aea.nii.gz
│           ├── sub-08_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/4g/pV/MD5E-s25655723--fddb912934403f6cd56dd32277e4be69.nii.gz/MD5E-s25655723--fddb912934403f6cd56dd32277e4be69.nii.gz
│           ├── sub-08_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/v0/Vf/MD5E-s33201889--0647f2251ac5f125b4b84ca5a93e37ca.nii.gz/MD5E-s33201889--0647f2251ac5f125b4b84ca5a93e37ca.nii.gz
│           ├── sub-08_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/46/Qg/MD5E-s4905--09b92244551605e32bbf3cc665c1c748.tsv/MD5E-s4905--09b92244551605e32bbf3cc665c1c748.tsv
│           ├── sub-08_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Kf/11/MD5E-s12622070--c140fdd9e3e5747b9c9a8ff8dcc949cf.nii.gz/MD5E-s12622070--c140fdd9e3e5747b9c9a8ff8dcc949cf.nii.gz
│           └── sub-08_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/8g/2p/MD5E-s10907328--1188c30e16c68cd270d02aa8d554f24d.nii.gz/MD5E-s10907328--1188c30e16c68cd270d02aa8d554f24d.nii.gz
├── sub-09
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-09_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/XM/9P/MD5E-s9038046--abcb37f89145be848b1b6c19c69b4e66.nii.gz/MD5E-s9038046--abcb37f89145be848b1b6c19c69b4e66.nii.gz
│   │   ├── dwi
│   │   │   └── sub-09_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/g5/GQ/MD5E-s104913036--9af1945a4e26239a938536e6eb962630.nii.gz/MD5E-s104913036--9af1945a4e26239a938536e6eb962630.nii.gz
│   │   └── func
│   │       ├── sub-09_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/qp/56/MD5E-s23883001--7eb7d4a5b01596f680d0d748473f1f38.nii.gz/MD5E-s23883001--7eb7d4a5b01596f680d0d748473f1f38.nii.gz
│   │       ├── sub-09_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/KM/3m/MD5E-s25333347--98c608533e6f0f0148d1b4223578a7e0.nii.gz/MD5E-s25333347--98c608533e6f0f0148d1b4223578a7e0.nii.gz
│   │       ├── sub-09_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/jG/KZ/MD5E-s32759028--0e0b0badca8ad941baea5212d0bbd4c8.nii.gz/MD5E-s32759028--0e0b0badca8ad941baea5212d0bbd4c8.nii.gz
│   │       ├── sub-09_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/QZ/09/MD5E-s4890--7bd3c7254e7aca678da9039d4c62f0ee.tsv/MD5E-s4890--7bd3c7254e7aca678da9039d4c62f0ee.tsv
│   │       ├── sub-09_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/Wk/x1/MD5E-s12607832--fa71f8dbe19dbb58fc8e56fd4c0d74a9.nii.gz/MD5E-s12607832--fa71f8dbe19dbb58fc8e56fd4c0d74a9.nii.gz
│   │       └── sub-09_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/1F/Qk/MD5E-s10992778--c0e5683ec6bed25d407e896cef3a4cc3.nii.gz/MD5E-s10992778--c0e5683ec6bed25d407e896cef3a4cc3.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-09_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/0w/6v/MD5E-s9093983--6307afbbcebf1d2bfe945a1e963d3a9d.nii.gz/MD5E-s9093983--6307afbbcebf1d2bfe945a1e963d3a9d.nii.gz
│       ├── dwi
│       │   └── sub-09_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/F8/6K/MD5E-s106806289--ed3b50d7d009964e8fbfb2d0250fc67e.nii.gz/MD5E-s106806289--ed3b50d7d009964e8fbfb2d0250fc67e.nii.gz
│       └── func
│           ├── sub-09_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/9x/8z/MD5E-s24415813--8c4d3158eda8efb430816469342f2d83.nii.gz/MD5E-s24415813--8c4d3158eda8efb430816469342f2d83.nii.gz
│           ├── sub-09_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/Pp/J2/MD5E-s25892719--8591a417c483510c6492132b5f0cecb8.nii.gz/MD5E-s25892719--8591a417c483510c6492132b5f0cecb8.nii.gz
│           ├── sub-09_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/vf/7Z/MD5E-s33605998--6a5422bb4dfded010105d8fd14a3f454.nii.gz/MD5E-s33605998--6a5422bb4dfded010105d8fd14a3f454.nii.gz
│           ├── sub-09_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/XP/8J/MD5E-s4895--d15d522ac0d8abdb458fbf2bff069aac.tsv/MD5E-s4895--d15d522ac0d8abdb458fbf2bff069aac.tsv
│           ├── sub-09_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/mV/29/MD5E-s12849009--d9afb889bde8c40bc778bff8ba55060b.nii.gz/MD5E-s12849009--d9afb889bde8c40bc778bff8ba55060b.nii.gz
│           └── sub-09_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/pk/wX/MD5E-s10859124--729337dd4c06fb3aceae73a91fbd5300.nii.gz/MD5E-s10859124--729337dd4c06fb3aceae73a91fbd5300.nii.gz
├── sub-10
│   ├── ses-retest
│   │   ├── anat
│   │   │   └── sub-10_ses-retest_T1w.nii.gz -> ../../../.git/annex/objects/pZ/57/MD5E-s8165420--f72be15a6c60658bac5148423087bb85.nii.gz/MD5E-s8165420--f72be15a6c60658bac5148423087bb85.nii.gz
│   │   ├── dwi
│   │   │   └── sub-10_ses-retest_dwi.nii.gz -> ../../../.git/annex/objects/v0/JM/MD5E-s101212223--f7d66db879a83e55b4caa332fb60f0a9.nii.gz/MD5E-s101212223--f7d66db879a83e55b4caa332fb60f0a9.nii.gz
│   │   └── func
│   │       ├── sub-10_ses-retest_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/kx/8m/MD5E-s22613897--fedb2d74d4c0426bda2660a0194a6e3c.nii.gz/MD5E-s22613897--fedb2d74d4c0426bda2660a0194a6e3c.nii.gz
│   │       ├── sub-10_ses-retest_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/4j/Q5/MD5E-s24086519--a813253ad6218481c5ac211a7b70cb2a.nii.gz/MD5E-s24086519--a813253ad6218481c5ac211a7b70cb2a.nii.gz
│   │       ├── sub-10_ses-retest_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/0V/7G/MD5E-s31223672--4817426ded5dcaa26ab61206c8c25a01.nii.gz/MD5E-s31223672--4817426ded5dcaa26ab61206c8c25a01.nii.gz
│   │       ├── sub-10_ses-retest_task-linebisection_events.tsv -> ../../../.git/annex/objects/xz/J5/MD5E-s4896--3d24876cdb335b9c4a4fa0cfa86317aa.tsv/MD5E-s4896--3d24876cdb335b9c4a4fa0cfa86317aa.tsv
│   │       ├── sub-10_ses-retest_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/PK/m9/MD5E-s12012688--f84bcd3565935a28933f3f6ec778b7e4.nii.gz/MD5E-s12012688--f84bcd3565935a28933f3f6ec778b7e4.nii.gz
│   │       └── sub-10_ses-retest_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/wj/XP/MD5E-s10205344--4dae96535f63a91e230ceee0567731cb.nii.gz/MD5E-s10205344--4dae96535f63a91e230ceee0567731cb.nii.gz
│   └── ses-test
│       ├── anat
│       │   └── sub-10_ses-test_T1w.nii.gz -> ../../../.git/annex/objects/Mq/mJ/MD5E-s8625770--9aad310eebc17dfa2a14de13ae26c9a0.nii.gz/MD5E-s8625770--9aad310eebc17dfa2a14de13ae26c9a0.nii.gz
│       ├── dwi
│       │   └── sub-10_ses-test_dwi.nii.gz -> ../../../.git/annex/objects/vW/Jp/MD5E-s408320142--0e710fe67a26868893112fdbcf441fe1.nii.gz/MD5E-s408320142--0e710fe67a26868893112fdbcf441fe1.nii.gz
│       └── func
│           ├── sub-10_ses-test_task-covertverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/p2/69/MD5E-s23125294--db06785e844b7705bf4eb76c3934e515.nii.gz/MD5E-s23125294--db06785e844b7705bf4eb76c3934e515.nii.gz
│           ├── sub-10_ses-test_task-fingerfootlips_bold.nii.gz -> ../../../.git/annex/objects/wg/wQ/MD5E-s24873409--ef5680f23a727a842c0259fbd38b8207.nii.gz/MD5E-s24873409--ef5680f23a727a842c0259fbd38b8207.nii.gz
│           ├── sub-10_ses-test_task-linebisection_bold.nii.gz -> ../../../.git/annex/objects/zP/g6/MD5E-s32217029--be5d868e5a99f7ae36db9965035197ba.nii.gz/MD5E-s32217029--be5d868e5a99f7ae36db9965035197ba.nii.gz
│           ├── sub-10_ses-test_task-linebisection_events.tsv -> ../../../.git/annex/objects/xv/Kp/MD5E-s4919--42e1573869fcdee415544479dfb6c4f1.tsv/MD5E-s4919--42e1573869fcdee415544479dfb6c4f1.tsv
│           ├── sub-10_ses-test_task-overtverbgeneration_bold.nii.gz -> ../../../.git/annex/objects/xZ/3P/MD5E-s12286926--5194547f3ddf306eca340a7e67ae3376.nii.gz/MD5E-s12286926--5194547f3ddf306eca340a7e67ae3376.nii.gz
│           └── sub-10_ses-test_task-overtwordrepetition_bold.nii.gz -> ../../../.git/annex/objects/9G/VZ/MD5E-s10338205--6cd9153fc2727a337c055c687c8ef705.nii.gz/MD5E-s10338205--6cd9153fc2727a337c055c687c8ef705.nii.gz
├── task-covertverbgeneration_bold.json
├── task-covertverbgeneration_events.tsv
├── task-fingerfootlips_bold.json
├── task-fingerfootlips_events.tsv
├── task-linebisection_bold.json
├── task-overtverbgeneration_bold.json
├── task-overtverbgeneration_events.tsv
├── task-overtwordrepetition_bold.json
└── task-overtwordrepetition_events.tsv

218 directories, 195 files

Let's figure out what are the subject labels in this dataset

In [ ]:
layout.get_subjects()
Out[ ]:
['01', '02', '03', '04', '05', '06', '07', '08', '09', '10']

What modalities are included in this dataset?

In [ ]:
layout.get_modalities()
Out[ ]:
['anat', 'dwi', 'func']

Which different data types are included in this dataset?

In [ ]:
layout.get_types(modality='func')
Out[ ]:
['bold', 'brainmask', 'confounds', 'events', 'fsaverage5', 'preproc']

What are the different tasks included in this dataset?

In [ ]:
layout.get_tasks()
Out[ ]:
['covertverbgeneration',
 'fingerfootlips',
 'linebisection',
 'overtverbgeneration',
 'overtwordrepetition']

We can also ask for all of the data for a particular subject and one modality.

In [ ]:
layout.get(subject='01', modality="anat", session="test")
Out[ ]:
[File(filename='/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz', subject='01', session='test', type='T1w', modality='anat')]

We can also ask for a specific subset of data. Note that we are using extension filter to get just the imaging data (BIDS allows both .nii and .nii.gz so we need to include both).

In [ ]:
layout.get(subject='01', type='bold', extensions=['nii', 'nii.gz'])
Out[ ]:
[File(filename='/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz', subject='01', session='retest', task='covertverbgeneration', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz', subject='01', session='retest', task='fingerfootlips', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz', subject='01', session='retest', task='linebisection', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz', subject='01', session='retest', task='overtverbgeneration', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz', subject='01', session='retest', task='overtwordrepetition', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz', subject='01', session='test', task='covertverbgeneration', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz', subject='01', session='test', task='fingerfootlips', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz', subject='01', session='test', task='linebisection', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz', subject='01', session='test', task='overtverbgeneration', type='bold', modality='func'),
 File(filename='/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz', subject='01', session='test', task='overtwordrepetition', type='bold', modality='func')]

You probably noticed that this method does not only return the file paths, but objects with relevant query fields. We can easily extract just the file paths.

In [ ]:
layout.get(subject='01', type='bold', extensions=['nii', 'nii.gz'], return_type='file')
Out[ ]:
['/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz',
 '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz',
 '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz',
 '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz',
 '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz',
 '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz',
 '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz',
 '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz',
 '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz',
 '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz']

Exercise 1:

List all files for the "linebisection" task for subject 02.

In [ ]:
#write your solution here
In [ ]:
from bids.layout import BIDSLayout
layout = BIDSLayout("/data/ds000114/")

layout.get(subject='02', return_type='file', task="linebisection")
Out[ ]:
['/data/ds000114/derivatives/fmriprep/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold_confounds.tsv',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold_space-fsaverage5.l.func.gii',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold_space-fsaverage5.r.func.gii',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold_space-mni152nlin2009casym_brainmask.nii.gz',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold_space-mni152nlin2009casym_preproc.nii.gz',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold_confounds.tsv',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold_space-fsaverage5.l.func.gii',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold_space-fsaverage5.r.func.gii',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold_space-mni152nlin2009casym_brainmask.nii.gz',
 '/data/ds000114/derivatives/fmriprep/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold_space-mni152nlin2009casym_preproc.nii.gz',
 '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold.nii.gz',
 '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_events.tsv',
 '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold.nii.gz',
 '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_events.tsv']

BIDSDataGrabber: Including pybids in your nipype workflow

This is great, but what we really want is to include this into our nipype workflows. To do this, we can import BIDSDataGrabber, which provides an Interface for BIDSLayout.get

In [ ]:
from nipype.interfaces.io import BIDSDataGrabber
from nipype.pipeline import Node, MapNode, Workflow
from nipype.interfaces.utility import Function

bg = Node(BIDSDataGrabber(), name='bids-grabber')
bg.inputs.base_dir = '/data/ds000114'

You can define static filters, that will apply to all queries, by modifying the appropriate input

In [ ]:
bg.inputs.subject = '01'
res = bg.run()
res.outputs
181017-08:45:20,28 nipype.workflow INFO:
	 [Node] Setting-up "bids-grabber" in "/tmp/tmpokqrrr0e/bids-grabber".
181017-08:45:20,33 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:20,661 nipype.workflow INFO:
	 [Node] Finished "bids-grabber".
Out[ ]:
anat = ['/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_class-csf_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_class-gm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_class-wm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_dtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_class-csf_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_class-gm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_class-wm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_dtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/anat/sub-01_t1w_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/sub-01/ses-retest/anat/sub-01_ses-retest_T1w.nii.gz', '/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz']
func = ['/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz']

Note that by default BIDSDataGrabber will fetch nifti files matching modality func and anat, and output them as two output fields.

To define custom fields, simply define the arguments to pass to BIDSLayout.get as dictionary, like so:

In [ ]:
bg.inputs.output_query = {'bolds': dict(type='bold')}
res = bg.run()
res.outputs
181017-08:45:20,671 nipype.workflow INFO:
	 [Node] Setting-up "bids-grabber" in "/tmp/tmpokqrrr0e/bids-grabber".
181017-08:45:20,678 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:21,205 nipype.workflow INFO:
	 [Node] Finished "bids-grabber".
Out[ ]:
bolds = ['/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz']

This results in a single output field bold, which returns all files with type:bold for subject:"01"

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

In [ ]:
def printMe(paths):
    print("\n\nanalyzing " + str(paths) + "\n\n")
    
analyzeBOLD = Node(Function(function=printMe, input_names=["paths"],
                            output_names=[]), name="analyzeBOLD")
In [ ]:
wf = Workflow(name="bids_demo")
wf.connect(bg, "bolds", analyzeBOLD, "paths")
wf.run()
181017-08:45:21,257 nipype.workflow INFO:
	 Workflow bids_demo settings: ['check', 'execution', 'logging', 'monitoring']
181017-08:45:21,265 nipype.workflow INFO:
	 Running serially.
181017-08:45:21,266 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.bids-grabber" in "/tmp/tmpokqrrr0e/bids-grabber".
181017-08:45:21,273 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:21,888 nipype.workflow INFO:
	 [Node] Finished "bids_demo.bids-grabber".
181017-08:45:21,888 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.analyzeBOLD" in "/tmp/tmpg17g1v31/bids_demo/analyzeBOLD".
181017-08:45:21,895 nipype.workflow INFO:
	 [Node] Running "analyzeBOLD" ("nipype.interfaces.utility.wrappers.Function")


analyzing ['/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz']


181017-08:45:21,900 nipype.workflow INFO:
	 [Node] Finished "bids_demo.analyzeBOLD".
Out[ ]:
<networkx.classes.digraph.DiGraph at 0x7f7caa33e438>

Exercise 2:

Modify the BIDSDataGrabber and the workflow to collect T1ws images for subject 10.

In [ ]:
# write your solution here
In [ ]:
from nipype.pipeline import Node, MapNode, Workflow
from nipype.interfaces.io import BIDSDataGrabber

ex2_BIDSDataGrabber = BIDSDataGrabber()
ex2_BIDSDataGrabber.inputs.base_dir = '/data/ds000114'
ex2_BIDSDataGrabber.inputs.subject = '10'
ex2_BIDSDataGrabber.inputs.output_query = {'T1w': dict(modality='anat')}

ex2_res = ex2_BIDSDataGrabber.run()
ex2_res.outputs
Out[ ]:
T1w = ['/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_class-csf_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_class-gm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_class-wm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_dtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_inflated.l.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_inflated.r.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_midthickness.l.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_midthickness.r.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_pial.l.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_pial.r.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_smoothwm.l.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_smoothwm.r.surf.gii', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_brainmask.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_class-csf_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_class-gm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_class-wm_probtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_dtissue.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_preproc.nii.gz', '/data/ds000114/derivatives/fmriprep/sub-10/anat/sub-10_t1w_space-mni152nlin2009casym_warp.h5', '/data/ds000114/sub-10/ses-retest/anat/sub-10_ses-retest_T1w.nii.gz', '/data/ds000114/sub-10/ses-test/anat/sub-10_ses-test_T1w.nii.gz']

Iterating over subject labels

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).

In [ ]:
bg_all = Node(BIDSDataGrabber(), name='bids-grabber')
bg_all.inputs.base_dir = '/data/ds000114'
bg_all.inputs.output_query = {'bolds': dict(type='bold')}
bg_all.iterables = ('subject', layout.get_subjects()[:2])
wf = Workflow(name="bids_demo")
wf.connect(bg_all, "bolds", analyzeBOLD, "paths")
wf.run()
181017-08:45:22,609 nipype.workflow INFO:
	 Workflow bids_demo settings: ['check', 'execution', 'logging', 'monitoring']
181017-08:45:22,620 nipype.workflow INFO:
	 Running serially.
181017-08:45:22,621 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.bids-grabber" in "/tmp/tmp08ys5m9q/bids_demo/_subject_02/bids-grabber".
181017-08:45:22,626 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:23,189 nipype.workflow INFO:
	 [Node] Finished "bids_demo.bids-grabber".
181017-08:45:23,190 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.analyzeBOLD" in "/tmp/tmpls76stlf/bids_demo/_subject_02/analyzeBOLD".
181017-08:45:23,196 nipype.workflow INFO:
	 [Node] Running "analyzeBOLD" ("nipype.interfaces.utility.wrappers.Function")


analyzing ['/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-linebisection_bold.nii.gz', '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-02/ses-retest/func/sub-02_ses-retest_task-overtwordrepetition_bold.nii.gz', '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-linebisection_bold.nii.gz', '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-02/ses-test/func/sub-02_ses-test_task-overtwordrepetition_bold.nii.gz']


181017-08:45:23,201 nipype.workflow INFO:
	 [Node] Finished "bids_demo.analyzeBOLD".
181017-08:45:23,202 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.bids-grabber" in "/tmp/tmp9jcgulho/bids_demo/_subject_01/bids-grabber".
181017-08:45:23,209 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:23,790 nipype.workflow INFO:
	 [Node] Finished "bids_demo.bids-grabber".
181017-08:45:23,791 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.analyzeBOLD" in "/tmp/tmpxwmhhy2y/bids_demo/_subject_01/analyzeBOLD".
181017-08:45:23,797 nipype.workflow INFO:
	 [Node] Running "analyzeBOLD" ("nipype.interfaces.utility.wrappers.Function")


analyzing ['/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz', '/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz']


181017-08:45:23,802 nipype.workflow INFO:
	 [Node] Finished "bids_demo.analyzeBOLD".
Out[ ]:
<networkx.classes.digraph.DiGraph at 0x7f7caa30a1d0>

Accessing additional metadata

Querying different files is nice, but sometimes you want to access more metadata. For example RepetitionTime. pybids can help with that as well

In [ ]:
layout.get_metadata('/data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz')
Out[ ]:
{'EchoTime': 0.05,
 'FlipAngle': 90,
 'RepetitionTime': 2.5,
 'SliceTiming': [0.0,
  1.2499999999999998,
  0.08333333333333333,
  1.333333333333333,
  0.16666666666666666,
  1.4166666666666663,
  0.25,
  1.4999999999999996,
  0.3333333333333333,
  1.5833333333333328,
  0.41666666666666663,
  1.666666666666666,
  0.5,
  1.7499999999999993,
  0.5833333333333333,
  1.8333333333333326,
  0.6666666666666666,
  1.9166666666666659,
  0.75,
  1.9999999999999991,
  0.8333333333333333,
  2.083333333333332,
  0.9166666666666666,
  2.1666666666666656,
  1.0,
  2.249999999999999,
  1.0833333333333333,
  2.333333333333332,
  1.1666666666666665,
  2.416666666666665],
 'TaskName': 'finger_foot_lips'}

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. (More about MapNode in MapNode)

In [ ]:
def printMetadata(path, data_dir):
    from bids.layout import BIDSLayout
    layout = BIDSLayout(data_dir)
    print("\n\nanalyzing " + path + "\nTR: "+ str(layout.get_metadata(path)["RepetitionTime"]) + "\n\n")
    
analyzeBOLD2 = MapNode(Function(function=printMetadata, input_names=["path", "data_dir"],
                             output_names=[]), name="analyzeBOLD2", iterfield="path")
analyzeBOLD2.inputs.data_dir = "/data/ds000114/"
In [ ]:
wf = Workflow(name="bids_demo")
wf.connect(bg, "bolds", analyzeBOLD2, "path")
wf.run()
181017-08:45:23,857 nipype.workflow INFO:
	 Workflow bids_demo settings: ['check', 'execution', 'logging', 'monitoring']
181017-08:45:23,865 nipype.workflow INFO:
	 Running serially.
181017-08:45:23,866 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.bids-grabber" in "/tmp/tmpokqrrr0e/bids-grabber".
181017-08:45:23,872 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:24,522 nipype.workflow INFO:
	 [Node] Finished "bids_demo.bids-grabber".
181017-08:45:24,523 nipype.workflow INFO:
	 [Node] Setting-up "bids_demo.analyzeBOLD2" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2".
181017-08:45:24,531 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD20" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD20".
181017-08:45:24,535 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD20" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz
TR: 2.5


181017-08:45:25,104 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD20".
181017-08:45:25,106 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD21" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD21".
181017-08:45:25,110 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD21" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz
TR: 2.5


181017-08:45:25,685 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD21".
181017-08:45:25,687 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD22" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD22".
181017-08:45:25,691 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD22" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz
TR: 2.5


181017-08:45:26,312 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD22".
181017-08:45:26,313 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD23" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD23".
181017-08:45:26,317 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD23" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz
TR: 5.0


181017-08:45:26,858 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD23".
181017-08:45:26,860 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD24" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD24".
181017-08:45:26,863 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD24" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz
TR: 5.0


181017-08:45:27,363 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD24".
181017-08:45:27,365 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD25" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD25".
181017-08:45:27,368 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD25" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz
TR: 2.5


181017-08:45:27,894 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD25".
181017-08:45:27,895 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD26" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD26".
181017-08:45:27,899 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD26" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz
TR: 2.5


181017-08:45:28,465 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD26".
181017-08:45:28,467 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD27" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD27".
181017-08:45:28,471 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD27" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz
TR: 2.5


181017-08:45:28,994 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD27".
181017-08:45:28,996 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD28" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD28".
181017-08:45:29,0 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD28" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz
TR: 5.0


181017-08:45:29,516 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD28".
181017-08:45:29,518 nipype.workflow INFO:
	 [Node] Setting-up "_analyzeBOLD29" in "/tmp/tmpn_5oipba/bids_demo/analyzeBOLD2/mapflow/_analyzeBOLD29".
181017-08:45:29,522 nipype.workflow INFO:
	 [Node] Running "_analyzeBOLD29" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz
TR: 5.0


181017-08:45:30,169 nipype.workflow INFO:
	 [Node] Finished "_analyzeBOLD29".
181017-08:45:30,175 nipype.workflow INFO:
	 [Node] Finished "bids_demo.analyzeBOLD2".
Out[ ]:
<networkx.classes.digraph.DiGraph at 0x7f7caa2f6ba8>

Exercise 3:

Modify the printMetadata function to also print EchoTime

In [ ]:
# write your solution here
In [ ]:
from nipype.pipeline import Node, MapNode, Workflow
from nipype.interfaces.io import BIDSDataGrabber

ex3_BIDSDataGrabber = Node(BIDSDataGrabber(), name='bids-grabber')
ex3_BIDSDataGrabber.inputs.base_dir = '/data/ds000114'
ex3_BIDSDataGrabber.inputs.subject = '01'
ex3_BIDSDataGrabber.inputs.output_query = {'bolds': dict(type='bold')}
In [ ]:
# and now modify analyzeBOLD2
def printMetadata_et(path, data_dir):
    from bids.layout import BIDSLayout
    layout = BIDSLayout(data_dir)
    print("\n\nanalyzing " + path + "\nTR: "+ 
          str(layout.get_metadata(path)["RepetitionTime"]) +
          "\nET: "+ str(layout.get_metadata(path)["EchoTime"])+ "\n\n")
    
ex3_analyzeBOLD2 = MapNode(Function(function=printMetadata_et, 
                                    input_names=["path", "data_dir"],
                                    output_names=[]), 
                           name="ex3", iterfield="path")
ex3_analyzeBOLD2.inputs.data_dir = "/data/ds000114/"

# and create a new workflow
ex3_wf = Workflow(name="ex3")
ex3_wf.connect(ex3_BIDSDataGrabber, "bolds", ex3_analyzeBOLD2, "path")
ex3_wf.run()
181017-08:45:30,219 nipype.workflow INFO:
	 Workflow ex3 settings: ['check', 'execution', 'logging', 'monitoring']
181017-08:45:30,225 nipype.workflow INFO:
	 Running serially.
181017-08:45:30,226 nipype.workflow INFO:
	 [Node] Setting-up "ex3.bids-grabber" in "/tmp/tmp2bjh9w7l/ex3/bids-grabber".
181017-08:45:30,233 nipype.workflow INFO:
	 [Node] Running "bids-grabber" ("nipype.interfaces.io.BIDSDataGrabber")
181017-08:45:30,796 nipype.workflow INFO:
	 [Node] Finished "ex3.bids-grabber".
181017-08:45:30,797 nipype.workflow INFO:
	 [Node] Setting-up "ex3.ex3" in "/tmp/tmpaqsetsw_/ex3/ex3".
181017-08:45:30,804 nipype.workflow INFO:
	 [Node] Setting-up "_ex30" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex30".
181017-08:45:30,807 nipype.workflow INFO:
	 [Node] Running "_ex30" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-covertverbgeneration_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:31,398 nipype.workflow INFO:
	 [Node] Finished "_ex30".
181017-08:45:31,400 nipype.workflow INFO:
	 [Node] Setting-up "_ex31" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex31".
181017-08:45:31,404 nipype.workflow INFO:
	 [Node] Running "_ex31" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-fingerfootlips_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:32,134 nipype.workflow INFO:
	 [Node] Finished "_ex31".
181017-08:45:32,136 nipype.workflow INFO:
	 [Node] Setting-up "_ex32" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex32".
181017-08:45:32,140 nipype.workflow INFO:
	 [Node] Running "_ex32" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-linebisection_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:32,719 nipype.workflow INFO:
	 [Node] Finished "_ex32".
181017-08:45:32,721 nipype.workflow INFO:
	 [Node] Setting-up "_ex33" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex33".
181017-08:45:32,724 nipype.workflow INFO:
	 [Node] Running "_ex33" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtverbgeneration_bold.nii.gz
TR: 5.0
ET: 0.05


181017-08:45:33,309 nipype.workflow INFO:
	 [Node] Finished "_ex33".
181017-08:45:33,311 nipype.workflow INFO:
	 [Node] Setting-up "_ex34" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex34".
181017-08:45:33,316 nipype.workflow INFO:
	 [Node] Running "_ex34" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-retest/func/sub-01_ses-retest_task-overtwordrepetition_bold.nii.gz
TR: 5.0
ET: 0.05


181017-08:45:33,946 nipype.workflow INFO:
	 [Node] Finished "_ex34".
181017-08:45:33,948 nipype.workflow INFO:
	 [Node] Setting-up "_ex35" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex35".
181017-08:45:33,952 nipype.workflow INFO:
	 [Node] Running "_ex35" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-covertverbgeneration_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:34,483 nipype.workflow INFO:
	 [Node] Finished "_ex35".
181017-08:45:34,485 nipype.workflow INFO:
	 [Node] Setting-up "_ex36" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex36".
181017-08:45:34,489 nipype.workflow INFO:
	 [Node] Running "_ex36" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-fingerfootlips_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:35,86 nipype.workflow INFO:
	 [Node] Finished "_ex36".
181017-08:45:35,88 nipype.workflow INFO:
	 [Node] Setting-up "_ex37" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex37".
181017-08:45:35,93 nipype.workflow INFO:
	 [Node] Running "_ex37" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-linebisection_bold.nii.gz
TR: 2.5
ET: 0.05


181017-08:45:35,704 nipype.workflow INFO:
	 [Node] Finished "_ex37".
181017-08:45:35,706 nipype.workflow INFO:
	 [Node] Setting-up "_ex38" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex38".
181017-08:45:35,710 nipype.workflow INFO:
	 [Node] Running "_ex38" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtverbgeneration_bold.nii.gz
TR: 5.0
ET: 0.05


181017-08:45:36,237 nipype.workflow INFO:
	 [Node] Finished "_ex38".
181017-08:45:36,239 nipype.workflow INFO:
	 [Node] Setting-up "_ex39" in "/tmp/tmpaqsetsw_/ex3/ex3/mapflow/_ex39".
181017-08:45:36,242 nipype.workflow INFO:
	 [Node] Running "_ex39" ("nipype.interfaces.utility.wrappers.Function")


analyzing /data/ds000114/sub-01/ses-test/func/sub-01_ses-test_task-overtwordrepetition_bold.nii.gz
TR: 5.0
ET: 0.05


181017-08:45:36,765 nipype.workflow INFO:
	 [Node] Finished "_ex39".
181017-08:45:36,770 nipype.workflow INFO:
	 [Node] Finished "ex3.ex3".
Out[ ]:
<networkx.classes.digraph.DiGraph at 0x7f7cae77bba8>

Home | github | Nipype