|
| 1 | +#!/usr/bin/env python |
| 2 | +""" |
| 3 | +================ |
| 4 | +sMRI: FreeSurfer |
| 5 | +================ |
| 6 | +
|
| 7 | +This script, smri_freesurfer.py, demonstrates the ability to call reconall on |
| 8 | +a set of subjects and then make an average subject. |
| 9 | +
|
| 10 | + python smri_freesurfer.py |
| 11 | +
|
| 12 | +Import necessary modules from nipype. |
| 13 | +""" |
| 14 | + |
| 15 | +import os |
| 16 | + |
1 | 17 | import nipype.pipeline.engine as pe
|
2 | 18 | import nipype.interfaces.io as nio
|
3 |
| -import os |
4 | 19 | from nipype.interfaces.freesurfer.preprocess import ReconAll
|
5 | 20 | from nipype.interfaces.freesurfer.utils import MakeAverageSubject
|
6 | 21 |
|
| 22 | + |
7 | 23 | subject_list = ['s1', 's3']
|
8 | 24 | data_dir = os.path.abspath('data')
|
9 | 25 | subjects_dir = os.path.abspath('amri_freesurfer_tutorial/subjects_dir')
|
10 | 26 |
|
11 | 27 | wf = pe.Workflow(name="l1workflow")
|
12 | 28 | wf.base_dir = os.path.abspath('amri_freesurfer_tutorial/workdir')
|
13 | 29 |
|
| 30 | +""" |
| 31 | +Grab data |
| 32 | +""" |
| 33 | + |
14 | 34 | datasource = pe.MapNode(interface=nio.DataGrabber(infields=['subject_id'],
|
15 | 35 | outfields=['struct']),
|
16 | 36 | name='datasource',
|
|
20 | 40 | datasource.inputs.template_args = dict(struct=[['subject_id', 'struct']])
|
21 | 41 | datasource.inputs.subject_id = subject_list
|
22 | 42 |
|
| 43 | +""" |
| 44 | +Run recon-all |
| 45 | +""" |
| 46 | + |
23 | 47 | recon_all = pe.MapNode(interface=ReconAll(), name='recon_all',
|
24 | 48 | iterfield=['subject_id', 'T1_files'])
|
25 | 49 | recon_all.inputs.subject_id = subject_list
|
|
29 | 53 |
|
30 | 54 | wf.connect(datasource, 'struct', recon_all, 'T1_files')
|
31 | 55 |
|
| 56 | +""" |
| 57 | +Make average subject |
| 58 | +""" |
| 59 | + |
32 | 60 | average = pe.Node(interface=MakeAverageSubject(), name="average")
|
33 | 61 | average.inputs.subjects_dir = subjects_dir
|
34 | 62 |
|
|
0 commit comments