From 75ed633531adf756c22b1b7fae97e789331eda0d Mon Sep 17 00:00:00 2001 From: Evan Edmond <evan.edmond@ndcn.ox.ac.uk> Date: Mon, 7 Dec 2020 11:32:57 +0000 Subject: [PATCH] ENH: add fslmaths simple smoothing --- fsl/wrappers/fslmaths.py | 5 +++++ tests/test_wrappers/test_wrappers.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fsl/wrappers/fslmaths.py b/fsl/wrappers/fslmaths.py index 2bfd71291..21decf6f2 100644 --- a/fsl/wrappers/fslmaths.py +++ b/fsl/wrappers/fslmaths.py @@ -105,6 +105,11 @@ class fslmaths(object): self.__args.append("-dilF") return self + def smooth(self, sigma): + """Spatial smoothing - mean filtering using a gauss kernel of sigma mm""" + self.__args.extend(("-s", sigma)) + return self + def add(self, image): """Add input to current image.""" self.__args.extend(("-add", image)) diff --git a/tests/test_wrappers/test_wrappers.py b/tests/test_wrappers/test_wrappers.py index dbffff1d6..e93d494ea 100644 --- a/tests/test_wrappers/test_wrappers.py +++ b/tests/test_wrappers/test_wrappers.py @@ -290,14 +290,15 @@ def test_fslmaths(): .abs().bin().binv().recip().Tmean().Tstd().Tmin().Tmax() \ .fillh().ero().dilM().dilF().add('addim').sub('subim') \ .mul('mulim').div('divim').mas('masim').rem('remim') \ - .thr('thrim').uthr('uthrim').inm('inmim').bptf(1, 10).run('output') + .thr('thrim').uthr('uthrim').inm('inmim').bptf(1, 10) \ + .smooth(sigma=6).run('output') expected = [cmd, 'input', '-abs', '-bin', '-binv', '-recip', '-Tmean', '-Tstd', '-Tmin', '-Tmax', '-fillh', '-ero', '-dilM', '-dilF', '-add addim', '-sub subim', '-mul mulim', '-div divim', '-mas masim', '-rem remim', '-thr thrim', '-uthr uthrim', - '-inm inmim', '-bptf 1 10', 'output'] + '-inm inmim', '-bptf 1 10', '-s 6', 'output'] expected = ' '.join(expected) assert result.stdout[0] == expected -- GitLab