From 1d697afdb1b27d69610b7a1068bbf9fe99282526 Mon Sep 17 00:00:00 2001 From: oliver-contier Date: Fri, 18 Aug 2017 16:52:10 -0400 Subject: [PATCH 1/4] gave option to pick run for reference volume to create_featreg_preproc workflow --- nipype/workflows/fmri/fsl/preprocess.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nipype/workflows/fmri/fsl/preprocess.py b/nipype/workflows/fmri/fsl/preprocess.py index 9660f19c53..ee4561d21a 100644 --- a/nipype/workflows/fmri/fsl/preprocess.py +++ b/nipype/workflows/fmri/fsl/preprocess.py @@ -18,6 +18,14 @@ def getthreshop(thresh): return ['-thr %.10f -Tmin -bin' % (0.1 * val[1]) for val in thresh] +def pickrun(files, whichrun): + """pick file from list of files""" + if isinstance(files, list): + return files[whichrun] + else: + return files + + def pickfirst(files): if isinstance(files, list): return files[0] @@ -401,7 +409,7 @@ def create_parallelfeat_preproc(name='featpreproc', highpass=True): return featpreproc -def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle'): +def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle', whichrun=0): """Create a FEAT preprocessing workflow with registration to one volume of the first run Parameters @@ -412,6 +420,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') name : name of workflow (default: featpreproc) highpass : boolean (default: True) whichvol : which volume of the first run to register to ('first', 'middle', 'last', 'mean') + whichrun : which of the runs to draw reference volume from (indexed by int) Inputs:: @@ -456,7 +465,6 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') """ Set up a node to define all inputs required for the preprocessing workflow - """ if highpass: @@ -512,7 +520,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') extract_ref = pe.Node(interface=fsl.ExtractROI(t_size=1), iterfield=['in_file'], name='extractref') - featpreproc.connect(img2float, ('out_file', pickfirst), extract_ref, 'in_file') + featpreproc.connect(img2float, ('out_file', pickrun, whichrun), extract_ref, 'in_file') featpreproc.connect(img2float, ('out_file', pickvol, 0, whichvol), extract_ref, 't_min') featpreproc.connect(extract_ref, 'roi_file', outputnode, 'reference') @@ -530,7 +538,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') featpreproc.connect(extract_ref, 'roi_file', motion_correct, 'ref_file') else: motion_correct.inputs.mean_vol = True - featpreproc.connect(motion_correct, ('mean_img', pickfirst), outputnode, 'reference') + featpreproc.connect(motion_correct, ('mean_img', pickrun, whichrun), outputnode, 'reference') featpreproc.connect(motion_correct, 'par_file', outputnode, 'motion_parameters') featpreproc.connect(motion_correct, 'out_file', outputnode, 'realigned_files') @@ -553,7 +561,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') meanfunc = pe.Node(interface=fsl.ImageMaths(op_string='-Tmean', suffix='_mean'), name='meanfunc') - featpreproc.connect(motion_correct, ('out_file', pickfirst), meanfunc, 'in_file') + featpreproc.connect(motion_correct, ('out_file', pickrun, whichrun), meanfunc, 'in_file') """ Strip the skull from the mean functional to generate a mask @@ -699,7 +707,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle') iterfield=['in_file'], name='meanfunc3') - featpreproc.connect(meanscale, ('out_file', pickfirst), meanfunc3, 'in_file') + featpreproc.connect(meanscale, ('out_file', pickrun, whichrun), meanfunc3, 'in_file') featpreproc.connect(meanfunc3, 'out_file', outputnode, 'mean') """ From cfb5f5a528e5df4304565ff7de91011ba3f3c6d6 Mon Sep 17 00:00:00 2001 From: oliver-contier Date: Sat, 19 Aug 2017 00:35:17 -0400 Subject: [PATCH 2/4] reference run can now be given either as integer or string --- nipype/workflows/fmri/fsl/preprocess.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nipype/workflows/fmri/fsl/preprocess.py b/nipype/workflows/fmri/fsl/preprocess.py index ee4561d21a..2373e95767 100644 --- a/nipype/workflows/fmri/fsl/preprocess.py +++ b/nipype/workflows/fmri/fsl/preprocess.py @@ -20,6 +20,16 @@ def getthreshop(thresh): def pickrun(files, whichrun): """pick file from list of files""" + + filemap = {'first': 0, 'last': -1, 'middle' :len(files) // 2} + + if isinstance(whichrun, str): + if whichrun not in filemap.keys(): + raise(KeyError, 'Sorry, whichrun must be either integer index' + 'or string in form of "first", "last" or "middle') + else: + return files[filemap[whichrun]] + if isinstance(files, list): return files[whichrun] else: From 9c30bd1018156c65f62e907d917992ad386d67d8 Mon Sep 17 00:00:00 2001 From: oliver-contier Date: Sat, 23 Feb 2019 15:43:37 +0100 Subject: [PATCH 3/4] merged local master with upstream rel/1.1.9 --- nipype/workflows/fmri/fsl/preprocess.py | 50 ------------------------- 1 file changed, 50 deletions(-) diff --git a/nipype/workflows/fmri/fsl/preprocess.py b/nipype/workflows/fmri/fsl/preprocess.py index 7ae2e98a1b..38e03c0065 100644 --- a/nipype/workflows/fmri/fsl/preprocess.py +++ b/nipype/workflows/fmri/fsl/preprocess.py @@ -20,20 +20,6 @@ def getthreshop(thresh): def pickrun(files, whichrun): """pick file from list of files""" -<<<<<<< HEAD - filemap = {'first': 0, 'last': -1, 'middle' :len(files) // 2} - - if isinstance(whichrun, str): - if whichrun not in filemap.keys(): - raise(KeyError, 'Sorry, whichrun must be either integer index' - 'or string in form of "first", "last" or "middle') - else: - return files[filemap[whichrun]] - - if isinstance(files, list): - return files[whichrun] - else: -======= filemap = {'first': 0, 'last': -1, 'middle': len(files) // 2} if isinstance(files, list): @@ -50,7 +36,6 @@ def pickrun(files, whichrun): return files[filemap[whichrun]] else: # in case single file name is given ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd return files @@ -426,14 +411,10 @@ def create_parallelfeat_preproc(name='featpreproc', highpass=True): return featpreproc -<<<<<<< HEAD -def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle', whichrun=0): -======= def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle', whichrun=0): ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd """Create a FEAT preprocessing workflow with registration to one volume of the first run Parameters @@ -444,11 +425,7 @@ def create_featreg_preproc(name='featpreproc', name : name of workflow (default: featpreproc) highpass : boolean (default: True) whichvol : which volume of the first run to register to ('first', 'middle', 'last', 'mean') -<<<<<<< HEAD - whichrun : which of the runs to draw reference volume from (indexed by int) -======= whichrun : which run to draw reference volume from (integer index or 'first', 'middle', 'last') ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd Inputs:: @@ -537,13 +514,6 @@ def create_featreg_preproc(name='featpreproc', """ if whichvol != 'mean': -<<<<<<< HEAD - extract_ref = pe.Node(interface=fsl.ExtractROI(t_size=1), - iterfield=['in_file'], - name='extractref') - featpreproc.connect(img2float, ('out_file', pickrun, whichrun), extract_ref, 'in_file') - featpreproc.connect(img2float, ('out_file', pickvol, 0, whichvol), extract_ref, 't_min') -======= extract_ref = pe.Node( interface=fsl.ExtractROI(t_size=1), iterfield=['in_file'], @@ -552,7 +522,6 @@ def create_featreg_preproc(name='featpreproc', extract_ref, 'in_file') featpreproc.connect(img2float, ('out_file', pickvol, 0, whichvol), extract_ref, 't_min') ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd featpreproc.connect(extract_ref, 'roi_file', outputnode, 'reference') """ Realign the functional runs to the reference (`whichvol` volume of first run) @@ -569,15 +538,8 @@ def create_featreg_preproc(name='featpreproc', 'ref_file') else: motion_correct.inputs.mean_vol = True -<<<<<<< HEAD - featpreproc.connect(motion_correct, ('mean_img', pickrun, whichrun), outputnode, 'reference') - - featpreproc.connect(motion_correct, 'par_file', outputnode, 'motion_parameters') - featpreproc.connect(motion_correct, 'out_file', outputnode, 'realigned_files') -======= featpreproc.connect(motion_correct, ('mean_img', pickrun, whichrun), outputnode, 'reference') ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd featpreproc.connect(motion_correct, 'par_file', outputnode, 'motion_parameters') @@ -598,19 +560,11 @@ def create_featreg_preproc(name='featpreproc', Extract the mean volume of the first functional run """ -<<<<<<< HEAD - meanfunc = pe.Node(interface=fsl.ImageMaths(op_string='-Tmean', - suffix='_mean'), - name='meanfunc') - featpreproc.connect(motion_correct, ('out_file', pickrun, whichrun), meanfunc, 'in_file') - -======= meanfunc = pe.Node( interface=fsl.ImageMaths(op_string='-Tmean', suffix='_mean'), name='meanfunc') featpreproc.connect(motion_correct, ('out_file', pickrun, whichrun), meanfunc, 'in_file') ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd """ Strip the skull from the mean functional to generate a mask """ @@ -746,12 +700,8 @@ def create_featreg_preproc(name='featpreproc', iterfield=['in_file'], name='meanfunc3') -<<<<<<< HEAD - featpreproc.connect(meanscale, ('out_file', pickrun, whichrun), meanfunc3, 'in_file') -======= featpreproc.connect(meanscale, ('out_file', pickrun, whichrun), meanfunc3, 'in_file') ->>>>>>> f079ed286d456b531f4f325ddc689f2572654edd featpreproc.connect(meanfunc3, 'out_file', outputnode, 'mean') """ Perform temporal highpass filtering on the data From 3b7c0184f564a3913f35a6be79bdb4384b56804b Mon Sep 17 00:00:00 2001 From: oliver-contier Date: Sat, 23 Feb 2019 15:54:28 +0100 Subject: [PATCH 4/4] Added my name to .zenodo.json --- .zenodo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.zenodo.json b/.zenodo.json index 7358a2aec2..6ed3552b5c 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -609,6 +609,11 @@ "affiliation": "MIT, HMS", "name": "Ghosh, Satrajit", "orcid": "0000-0002-5312-6729" + }, + { + "affiliation": "Otto-von-Guericke-University Magdeburg, Germany", + "name": "Contier, Oliver", + "orcid": "0000-0002-2983-4709" } ], "keywords": [