From 526bdb612f47b129149bf957a2395f479636ac3e Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 00:42:11 +0100 Subject: [PATCH 1/7] Use entry point instead of script. --- pydeface/__init__.py | 0 pydeface/__main__.py | 117 +++++++++++++++++++++++++++++++++++++++++++ pydeface/utils.py | 29 +++++++++++ setup.py | 13 +++-- 4 files changed, 154 insertions(+), 5 deletions(-) create mode 100644 pydeface/__init__.py create mode 100644 pydeface/__main__.py diff --git a/pydeface/__init__.py b/pydeface/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pydeface/__main__.py b/pydeface/__main__.py new file mode 100644 index 0000000..0ea9812 --- /dev/null +++ b/pydeface/__main__.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +"""Defacing utility for MRI images.""" + +import argparse +import os +import tempfile +from nipype.interfaces import fsl +from nibabel import load, Nifti1Image +from pkg_resources import resource_filename, Requirement, require +from pydeface.utils import initial_checks, check_output_path + + +def main(): + """Command line call argument parsing.""" + parser = argparse.ArgumentParser() + parser.add_argument( + 'infile', metavar='path', + help="Path to input nifti.") + + parser.add_argument( + "--outfile", metavar='path', required=False, + help="If not provided adds '_defaced' suffix.") + + parser.add_argument( + '--applyto', nargs='+', required=False, metavar='path', + help='Apply the created face mask to other images.') + + parser.add_argument( + "--force", action='store_true', + help="Force to rewrite the output even if it exists.") + + parser.add_argument( + "--nocleanup", action='store_true', + help="Do not cleanup temporary files.") + + parser.add_argument( + "--verbose", action='store_true', + help="Show additional status prints.") + + welcome_str = 'pydeface ' + require("pydeface")[0].version + welcome_decor = '-' * len(welcome_str) + print(welcome_decor + '\n' + welcome_str + '\n' + welcome_decor) + + template = resource_filename(Requirement.parse("pydeface"), + "pydeface/data/mean_reg2mean.nii.gz") + facemask = resource_filename(Requirement.parse("pydeface"), + "pydeface/data/facemask.nii.gz") + + initial_checks(template, facemask) + args = parser.parse_args() + infile = args.infile + outfile = check_output_path(infile, args.outfile, args.force) + + # temporary files + _, tmpmat = tempfile.mkstemp() + tmpmat = tmpmat + '.mat' + _, tmpfile = tempfile.mkstemp() + tmpfile = tmpfile + '.nii.gz' + if args.verbose: + print(tmpmat) + print(tmpfile) + _, tmpfile2 = tempfile.mkstemp() + _, tmpmat2 = tempfile.mkstemp() + + print('Defacing...\n %s' % args.infile) + + # register template to infile + flirt = fsl.FLIRT() + flirt.inputs.cost_func = 'mutualinfo' + flirt.inputs.in_file = template + flirt.inputs.out_matrix_file = tmpmat + flirt.inputs.out_file = tmpfile2 + flirt.inputs.reference = infile + flirt.run() + + # warp facemask to infile + flirt = fsl.FLIRT() + flirt.inputs.in_file = facemask + flirt.inputs.in_matrix_file = tmpmat + flirt.inputs.apply_xfm = True + flirt.inputs.reference = infile + flirt.inputs.out_file = tmpfile + flirt.inputs.out_matrix_file = tmpmat2 + flirt.run() + + # multiply mask by infile and save + infile_img = load(infile) + tmpfile_img = load(tmpfile) + outdata = infile_img.get_data() * tmpfile_img.get_data() + outfile_img = Nifti1Image(outdata, infile_img.get_affine(), + infile_img.get_header()) + outfile_img.to_filename(outfile) + print('Defaced input saved as:\n %s' % outfile) + + # apply mask to other given images + if args.applyto is not None: + print("Defacing mask also applied to:") + for applyfile in args.applyto: + applyfile_img = load(applyfile) + outdata = applyfile_img.get_data() * tmpfile_img.get_data() + applyfile_img = Nifti1Image(outdata, applyfile_img.get_affine(), + applyfile_img.get_header()) + outfile_img.to_filename(applyfile) + print(' %s' % applyfile) + + if args.nocleanup: + pass + else: + os.remove(tmpfile) + os.remove(tmpfile2) + os.remove(tmpmat) + + print('Finished.') + + +if __name__ == "__main__": + main() diff --git a/pydeface/utils.py b/pydeface/utils.py index bd14c7f..ac20914 100644 --- a/pydeface/utils.py +++ b/pydeface/utils.py @@ -1,5 +1,6 @@ """Utility scripts for pydeface.""" +import os import sys import subprocess @@ -20,3 +21,31 @@ def usage(): """Print the docstring and exit.""" sys.stdout.write(__doc__) sys.exit(2) + + +def initial_checks(template, facemask): + """Initial sanity checks.""" + if not os.path.exists(template): + raise Exception('Missing template: %s' % template) + if not os.path.exists(facemask): + raise Exception('Missing face mask: %s' % facemask) + + if 'FSLDIR' not in os.environ: + raise Exception("FSL must be installed and " + "FSLDIR environment variable must be defined.") + sys.exit(2) + + +def check_output_path(outfile, infile, force=False): + """Determine output file name.""" + if force is None: + force = False + + if os.path.exists(outfile) and force: + print('Previous output will be overwritten.') + elif os.path.exists(outfile): + raise Exception("%s already exists. Remove it first or use '--force' " + "flag to overwrite." % outfile) + else: + outfile = infile.replace('.nii', '_defaced.nii') + return outfile diff --git a/setup.py b/setup.py index f5aeabd..42f3684 100644 --- a/setup.py +++ b/setup.py @@ -15,13 +15,13 @@ LICENSE = 'MIT' URL = 'http://poldracklab.org' DOWNLOAD_URL = 'https://github.com/poldracklab/pydeface/' -VERSION = '1.1' +VERSION = '1.2' if os.path.exists('MANIFEST'): os.remove('MANIFEST') -datafiles = {'pydeface': ['data/facemask.nii.gz', - 'data/mean_reg2mean.nii.gz']} +# datafiles = {'pydeface': ['data/facemask.nii.gz', +# 'data/mean_reg2mean.nii.gz']} setup(name=DISTNAME, maintainer=MAINTAINER, @@ -32,8 +32,7 @@ url=URL, download_url=DOWNLOAD_URL, packages=['pydeface'], - package_data=datafiles, - scripts=['scripts/pydeface.py'], + # package_data=datafiles, classifiers=['Intended Audience :: Science/Research', 'Programming Language :: Python :: 2.7', 'License :: OSI Approved :: BSD License', @@ -41,4 +40,8 @@ 'Operating System :: Unix', 'Operating System :: MacOS'], install_requires=['numpy', 'nibabel', 'nipype'], + entry_points={ + 'console_scripts': [ + 'pydeface = pydeface.__main__:main' + ]}, ) From b716951d3004a1ce482d877940a5cec2af20b0b2 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 01:09:13 +0100 Subject: [PATCH 2/7] Few more changes to tidy up. --- pydeface/__main__.py | 48 +++++++++++++++++++++++++++++++++----------- pydeface/utils.py | 11 +++++++++- setup.py | 6 +++--- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/pydeface/__main__.py b/pydeface/__main__.py index 0ea9812..ea57dee 100644 --- a/pydeface/__main__.py +++ b/pydeface/__main__.py @@ -1,13 +1,34 @@ #!/usr/bin/env python """Defacing utility for MRI images.""" +# Copyright 2011, Russell Poldrack. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY RUSSELL POLDRACK ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL RUSSELL POLDRACK OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + import argparse import os import tempfile from nipype.interfaces import fsl from nibabel import load, Nifti1Image -from pkg_resources import resource_filename, Requirement, require -from pydeface.utils import initial_checks, check_output_path +from pkg_resources import require +from pydeface.utils import initial_checks, output_checks def main(): @@ -21,13 +42,21 @@ def main(): "--outfile", metavar='path', required=False, help="If not provided adds '_defaced' suffix.") + parser.add_argument( + "--force", action='store_true', + help="Force to rewrite the output even if it exists.") + parser.add_argument( '--applyto', nargs='+', required=False, metavar='path', help='Apply the created face mask to other images.') parser.add_argument( - "--force", action='store_true', - help="Force to rewrite the output even if it exists.") + "--template", metavar='path', required=False, + help="Template image used as the registration target.") + + parser.add_argument( + "--facemask", metavar='path', required=False, + help="Face mask for the template image.") parser.add_argument( "--nocleanup", action='store_true', @@ -41,21 +70,16 @@ def main(): welcome_decor = '-' * len(welcome_str) print(welcome_decor + '\n' + welcome_str + '\n' + welcome_decor) - template = resource_filename(Requirement.parse("pydeface"), - "pydeface/data/mean_reg2mean.nii.gz") - facemask = resource_filename(Requirement.parse("pydeface"), - "pydeface/data/facemask.nii.gz") - - initial_checks(template, facemask) args = parser.parse_args() + template, facemask = initial_checks(args.template, args.facemask) infile = args.infile - outfile = check_output_path(infile, args.outfile, args.force) + outfile = output_checks(infile, args.outfile, args.force) # temporary files _, tmpmat = tempfile.mkstemp() tmpmat = tmpmat + '.mat' _, tmpfile = tempfile.mkstemp() - tmpfile = tmpfile + '.nii.gz' + tmpfile = tmpfile + '.nii' if args.verbose: print(tmpmat) print(tmpfile) diff --git a/pydeface/utils.py b/pydeface/utils.py index ac20914..a310961 100644 --- a/pydeface/utils.py +++ b/pydeface/utils.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from pkg_resources import resource_filename, Requirement def run_shell_cmd(cmd, cwd=[]): @@ -23,8 +24,15 @@ def usage(): sys.exit(2) -def initial_checks(template, facemask): +def initial_checks(template=None, facemask=None): """Initial sanity checks.""" + if template is None: + template = resource_filename(Requirement.parse("pydeface"), + "pydeface/data/mean_reg2mean.nii.gz") + if facemask is None: + facemask = resource_filename(Requirement.parse("pydeface"), + "pydeface/data/facemask.nii.gz") + if not os.path.exists(template): raise Exception('Missing template: %s' % template) if not os.path.exists(facemask): @@ -34,6 +42,7 @@ def initial_checks(template, facemask): raise Exception("FSL must be installed and " "FSLDIR environment variable must be defined.") sys.exit(2) + return template, facemask def check_output_path(outfile, infile, force=False): diff --git a/setup.py b/setup.py index 42f3684..4e20467 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,8 @@ if os.path.exists('MANIFEST'): os.remove('MANIFEST') -# datafiles = {'pydeface': ['data/facemask.nii.gz', -# 'data/mean_reg2mean.nii.gz']} +datafiles = {'pydeface': ['data/facemask.nii.gz', + 'data/mean_reg2mean.nii.gz']} setup(name=DISTNAME, maintainer=MAINTAINER, @@ -32,7 +32,7 @@ url=URL, download_url=DOWNLOAD_URL, packages=['pydeface'], - # package_data=datafiles, + package_data=datafiles, classifiers=['Intended Audience :: Science/Research', 'Programming Language :: Python :: 2.7', 'License :: OSI Approved :: BSD License', From db3093a3fd7b0521781f0ab572bb79b958e5f1b8 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 01:23:26 +0100 Subject: [PATCH 3/7] A few more changes and removal of the unused code. --- pydeface/__main__.py | 20 +++++++++++--------- pydeface/utils.py | 21 +-------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/pydeface/__main__.py b/pydeface/__main__.py index ea57dee..ef8dd2d 100644 --- a/pydeface/__main__.py +++ b/pydeface/__main__.py @@ -47,24 +47,27 @@ def main(): help="Force to rewrite the output even if it exists.") parser.add_argument( - '--applyto', nargs='+', required=False, metavar='path', - help='Apply the created face mask to other images.') + '--applyto', nargs='+', required=False, metavar='', + help="Apply the created face mask to other images. Can take multiple " + "arguments.") parser.add_argument( "--template", metavar='path', required=False, - help="Template image used as the registration target.") + help=("Optional template image that will be used as the registration " + "target instead of the default.")) parser.add_argument( "--facemask", metavar='path', required=False, - help="Face mask for the template image.") + help="Optional face mask image that will be used instead of the " + "default.") parser.add_argument( "--nocleanup", action='store_true', - help="Do not cleanup temporary files.") + help="Do not cleanup temporary files. Off by default.") parser.add_argument( "--verbose", action='store_true', - help="Show additional status prints.") + help="Show additional status prints. Off by default.") welcome_str = 'pydeface ' + require("pydeface")[0].version welcome_decor = '-' * len(welcome_str) @@ -79,10 +82,9 @@ def main(): _, tmpmat = tempfile.mkstemp() tmpmat = tmpmat + '.mat' _, tmpfile = tempfile.mkstemp() - tmpfile = tmpfile + '.nii' + tmpfile = tmpfile + '.nii.gz' if args.verbose: - print(tmpmat) - print(tmpfile) + print("Temporary files:\n %s\n %s" % (tmpmat, tmpfile)) _, tmpfile2 = tempfile.mkstemp() _, tmpmat2 = tempfile.mkstemp() diff --git a/pydeface/utils.py b/pydeface/utils.py index a310961..ebb8f37 100644 --- a/pydeface/utils.py +++ b/pydeface/utils.py @@ -2,28 +2,9 @@ import os import sys -import subprocess from pkg_resources import resource_filename, Requirement -def run_shell_cmd(cmd, cwd=[]): - """Run a command in the shell using Popen.""" - if cwd: - process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, - cwd=cwd) - else: - process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - for line in process.stdout: - print(line.strip()) - process.wait() - - -def usage(): - """Print the docstring and exit.""" - sys.stdout.write(__doc__) - sys.exit(2) - - def initial_checks(template=None, facemask=None): """Initial sanity checks.""" if template is None: @@ -45,7 +26,7 @@ def initial_checks(template=None, facemask=None): return template, facemask -def check_output_path(outfile, infile, force=False): +def output_checks(outfile, infile, force=False): """Determine output file name.""" if force is None: force = False From 27f3ee7c22771913c4513e8879bdfa3eaad5ba28 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 01:41:00 +0100 Subject: [PATCH 4/7] More cleanup. --- scripts/pydeface.py | 122 -------------------------------------------- setup.py | 2 + 2 files changed, 2 insertions(+), 122 deletions(-) delete mode 100755 scripts/pydeface.py diff --git a/scripts/pydeface.py b/scripts/pydeface.py deleted file mode 100755 index 8d3d1c9..0000000 --- a/scripts/pydeface.py +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env python -"""Deface an image using FSL. - -Usage: ------- -pydeface.py - -""" - -# Copyright 2011, Russell Poldrack. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY RUSSELL POLDRACK ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL RUSSELL POLDRACK OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import nibabel -import os -import sys -import tempfile -from nipype.interfaces import fsl -from pkg_resources import resource_filename, Requirement, require - - -def main(): - cleanup, verbose = True, False - - template = resource_filename(Requirement.parse("pydeface"), - "pydeface/data/mean_reg2mean.nii.gz") - facemask = resource_filename(Requirement.parse("pydeface"), - "pydeface/data/facemask.nii.gz") - - if not os.path.exists(template): - raise Exception('Missing template: %s' % template) - if not os.path.exists(facemask): - raise Exception('Missing face mask: %s' % facemask) - - if len(sys.argv) < 2: - sys.stdout.write(__doc__) - sys.exit(2) - else: - infile = sys.argv[1] - - if len(sys.argv) > 2: - outfile = sys.argv[2] - else: - outfile = infile.replace('.nii', '_defaced.nii') - - if os.path.exists(outfile): - raise Exception('%s already exists, remove it first.' % outfile) - - if 'FSLDIR' not in os.environ: - raise Exception("FSL must be installed and " - "FSLDIR environment variable must be defined.") - sys.exit(2) - - _, tmpmat = tempfile.mkstemp() - tmpmat = tmpmat + '.mat' - _, tmpfile = tempfile.mkstemp() - tmpfile = tmpfile + '.nii.gz' - if verbose: - print(tmpmat) - print(tmpfile) - _, tmpfile2 = tempfile.mkstemp() - _, tmpmat2 = tempfile.mkstemp() - - print('Defacing...\n%s' % infile) - - # register template to infile - flirt = fsl.FLIRT() - flirt.inputs.cost_func = 'mutualinfo' - flirt.inputs.in_file = template - flirt.inputs.out_matrix_file = tmpmat - flirt.inputs.out_file = tmpfile2 - flirt.inputs.reference = infile - flirt.run() - - # warp facemask to infile - flirt = fsl.FLIRT() - flirt.inputs.in_file = facemask - flirt.inputs.in_matrix_file = tmpmat - flirt.inputs.apply_xfm = True - flirt.inputs.reference = infile - flirt.inputs.out_file = tmpfile - flirt.inputs.out_matrix_file = tmpmat2 - flirt.run() - - # multiply mask by infile and save - infile_img = nibabel.load(infile) - tmpfile_img = nibabel.load(tmpfile) - outdata = infile_img.get_data() * tmpfile_img.get_data() - outfile_img = nibabel.Nifti1Image(outdata, infile_img.get_affine(), - infile_img.get_header()) - outfile_img.to_filename(outfile) - - if cleanup: - os.remove(tmpfile) - os.remove(tmpfile2) - os.remove(tmpmat) - - print('Output saved as:\n%s' % outfile) - - -if __name__ == "__main__": - welcome_str = 'pydeface ' + require("pydeface")[0].version - welcome_decor = '-' * len(welcome_str) - print(welcome_decor + '\n' + welcome_str + '\n' + welcome_decor) - main() diff --git a/setup.py b/setup.py index 4e20467..fbcfdae 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,8 @@ # # Some portions were borrowed from: # https://github.com/mwaskom/lyman/blob/master/setup.py +# and: +# https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ import os from setuptools import setup From bea538b9f8218c003a52e2656d2450cd27c45e49 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 02:43:35 +0100 Subject: [PATCH 5/7] Fixed output naming issue and added cost options --- pydeface/__main__.py | 11 ++++++++--- pydeface/utils.py | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pydeface/__main__.py b/pydeface/__main__.py index ef8dd2d..4c55a55 100644 --- a/pydeface/__main__.py +++ b/pydeface/__main__.py @@ -51,6 +51,10 @@ def main(): help="Apply the created face mask to other images. Can take multiple " "arguments.") + parser.add_argument( + "--cost", metavar='mutualinfo', required=False, default='mutualinfo', + help="FSL-FLIRT cost function. Default is 'mutualinfo'.") + parser.add_argument( "--template", metavar='path', required=False, help=("Optional template image that will be used as the registration " @@ -92,7 +96,7 @@ def main(): # register template to infile flirt = fsl.FLIRT() - flirt.inputs.cost_func = 'mutualinfo' + flirt.inputs.cost_func = args.cost flirt.inputs.in_file = template flirt.inputs.out_matrix_file = tmpmat flirt.inputs.out_file = tmpfile2 @@ -116,7 +120,7 @@ def main(): outfile_img = Nifti1Image(outdata, infile_img.get_affine(), infile_img.get_header()) outfile_img.to_filename(outfile) - print('Defaced input saved as:\n %s' % outfile) + print("Defaced image saved as:\n %s" % outfile) # apply mask to other given images if args.applyto is not None: @@ -126,7 +130,8 @@ def main(): outdata = applyfile_img.get_data() * tmpfile_img.get_data() applyfile_img = Nifti1Image(outdata, applyfile_img.get_affine(), applyfile_img.get_header()) - outfile_img.to_filename(applyfile) + outfile = output_checks(applyfile) + applyfile_img.to_filename(outfile) print(' %s' % applyfile) if args.nocleanup: diff --git a/pydeface/utils.py b/pydeface/utils.py index ebb8f37..c9c31c4 100644 --- a/pydeface/utils.py +++ b/pydeface/utils.py @@ -26,10 +26,12 @@ def initial_checks(template=None, facemask=None): return template, facemask -def output_checks(outfile, infile, force=False): +def output_checks(infile, outfile=None, force=False): """Determine output file name.""" if force is None: force = False + if outfile is None: + outfile = infile.replace('.nii', '_defaced.nii') if os.path.exists(outfile) and force: print('Previous output will be overwritten.') @@ -37,5 +39,5 @@ def output_checks(outfile, infile, force=False): raise Exception("%s already exists. Remove it first or use '--force' " "flag to overwrite." % outfile) else: - outfile = infile.replace('.nii', '_defaced.nii') + pass return outfile From 87535442a16265bb3437bc4f6f9bee5941b6b018 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 03:01:35 +0100 Subject: [PATCH 6/7] update readme --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 398f6f2..be8a353 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Defacing tool for nifti images. +Defacing tool for nifti images. ### Requirements: - [FSL](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSL) @@ -14,5 +14,10 @@ python setup.py install ### To use: ``` -pydeface.py infile.nii.gz +pydeface infile.nii.gz +``` + +Also see the help for additional options: +``` +pydeface --help ``` From 2244e558a97557b61ed6a8408a1ce41ca2a22c61 Mon Sep 17 00:00:00 2001 From: ofgulban Date: Sat, 9 Dec 2017 10:51:43 +0100 Subject: [PATCH 7/7] Version bump. Because the command line call is changed to 'pydeface' instead of 'pydeface.py' I have increased the version to 2.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fbcfdae..b94816e 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ LICENSE = 'MIT' URL = 'http://poldracklab.org' DOWNLOAD_URL = 'https://github.com/poldracklab/pydeface/' -VERSION = '1.2' +VERSION = '2.0' if os.path.exists('MANIFEST'): os.remove('MANIFEST')