From 2c698382c57627c923775a91f93708b7000632bd Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 21 Jul 2016 18:31:56 -0700 Subject: [PATCH] [ENH] Move skull-stripping and reorient to NIworkflows And close #140 --- mriqc/workflows/anatomical.py | 48 +++-------------------------------- requirements.txt | 1 + 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/mriqc/workflows/anatomical.py b/mriqc/workflows/anatomical.py index 04a08e23e..93cc60bca 100644 --- a/mriqc/workflows/anatomical.py +++ b/mriqc/workflows/anatomical.py @@ -18,6 +18,9 @@ from nipype.interfaces import ants from nipype.interfaces.afni import preprocess as afp +from niworkflows.anat.skullstrip import afni_wf as skullstrip_wf +from niworkflows.common import reorient as mri_reorient_wf + from mriqc.workflows.utils import fwhm_dict from mriqc.interfaces.qc import StructuralQC from mriqc.interfaces.anatomical import ArtifactMask @@ -178,26 +181,6 @@ def anat_qc_workflow(name='MRIQC_Anat', settings=None): return workflow -def mri_reorient_wf(name='ReorientWorkflow'): - """A workflow to reorient images to 'RPI' orientation""" - workflow = pe.Workflow(name=name) - - inputnode = pe.Node(niu.IdentityInterface(fields=['in_file']), - name='inputnode') - outputnode = pe.Node(niu.IdentityInterface( - fields=['out_file']), name='outputnode') - - deoblique = pe.Node(afp.Refit(deoblique=True), name='deoblique') - reorient = pe.Node(afp.Resample( - orientation='RPI', outputtype='NIFTI_GZ'), name='reorient') - workflow.connect([ - (inputnode, deoblique, [('in_file', 'in_file')]), - (deoblique, reorient, [('out_file', 'in_file')]), - (reorient, outputnode, [('out_file', 'out_file')]) - ]) - return workflow - - def headmsk_wf(name='HeadMaskWorkflow'): """Computes a head mask as in [Mortamet2009]_.""" @@ -322,31 +305,6 @@ def _invt_flags(transforms): ]) return workflow - -def skullstrip_wf(name='SkullStripWorkflow'): - """ Skull-stripping workflow """ - - workflow = pe.Workflow(name=name) - inputnode = pe.Node(niu.IdentityInterface(fields=['in_file']), - name='inputnode') - outputnode = pe.Node(niu.IdentityInterface(fields=['out_file', 'out_mask', 'head_mask']), - name='outputnode') - - sstrip = pe.Node(afp.SkullStrip(outputtype='NIFTI_GZ'), name='skullstrip') - sstrip_orig_vol = pe.Node(afp.Calc( - expr='a*step(b)', outputtype='NIFTI_GZ'), name='sstrip_orig_vol') - binarize = pe.Node(fsl.Threshold(args='-bin', thresh=1.e-3), name='binarize') - - workflow.connect([ - (inputnode, sstrip, [('in_file', 'in_file')]), - (inputnode, sstrip_orig_vol, [('in_file', 'in_file_a')]), - (sstrip, sstrip_orig_vol, [('out_file', 'in_file_b')]), - (sstrip_orig_vol, binarize, [('out_file', 'in_file')]), - (sstrip_orig_vol, outputnode, [('out_file', 'out_file')]), - (binarize, outputnode, [('out_file', 'out_mask')]) - ]) - return workflow - def _get_wm(in_file, wm_val=3, out_file=None): import os.path as op import numpy as np diff --git a/requirements.txt b/requirements.txt index d337bd53c..ef321ee84 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ nitime nilearn dipy -e git+https://github.com/nipy/nipype#egg=nipype +niworkflows lockfile jinja2 seaborn