# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegResample) from nipype.testing import skipif, example_data import os import pytest @skipif(no_niftyreg(cmd='reg_resample')) def test_reg_resample_res(): # Create a reg_resample object nr = RegResample() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_resample') # test raising error with mandatory args absent with pytest.raises(ValueError): nr.run() # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') trans_file = example_data('warpfield.nii') nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.trans_file = trans_file nr.inputs.inter_val = 'LIN'
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegTransform) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_transform')) def test_reg_transform_def(): # Create a reg_transform object nr = RegTransform() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_transform') # Assign some input data trans_file = example_data('warpfield.nii') nr.inputs.def_input = trans_file nr.inputs.omp_core_val = 4 expected_cmd = get_custom_path('reg_transform') + ' -omp 4 ' +\ '-def ' + trans_file + ' ' + os.getcwd() + os.sep + 'warpfield_trans.nii.gz' yield assert_equal, nr.cmdline, expected_cmd @skipif(no_niftyreg(cmd='reg_transform')) def test_reg_transform_def_ref():
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegJacobian) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_jacobian')) def test_reg_jacobian_jac(): # Create a reg_jacobian object nr = RegJacobian() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_jacobian') # Assign some input data ref_file = example_data('im1.nii') trans_file = example_data('warpfield.nii') nr.inputs.ref_file = ref_file nr.inputs.trans_file = trans_file nr.inputs.omp_core_val = 4 expected_cmd = get_custom_path('reg_jacobian') + ' -omp 4 ' + '-ref ' + ref_file + ' ' +\ '-trans ' + trans_file + ' -jac ' + os.getcwd() + os.sep + 'warpfield_jac.nii.gz' yield assert_equal, nr.cmdline, expected_cmd @skipif(no_niftyreg(cmd='reg_jacobian'))
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAverage) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_average')) def test_reg_average_avg_nii(): # Create a reg_average object nr = RegAverage() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_average') # Assign some input data one_file = example_data('im1.nii') two_file = example_data('im2.nii') three_file = example_data('im3.nii') nr.inputs.avg_files = [one_file, two_file, three_file] nr.cmdline # Read the reg_average_cmd reg_average_cmd = os.path.join(os.getcwd(), 'reg_average_cmd') with open(reg_average_cmd, 'rb') as f: argv = f.read() os.remove(reg_average_cmd)
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegTools) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_tools')) def test_reg_tools_mul(): # Create a reg_tools object nr = RegTools() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_tools') # Assign some input data in_file = example_data('im1.nii') nr.inputs.in_file = in_file nr.inputs.mul_val = 4 nr.inputs.omp_core_val = 4 expected_cmd = get_custom_path('reg_tools') + ' ' + '-in ' + in_file + ' -mul 4.0 ' +\ '-omp 4 ' + '-out ' + os.getcwd() + os.sep + 'im1_tools.nii.gz' yield assert_equal, nr.cmdline, expected_cmd @skipif(no_niftyreg(cmd='reg_tools')) def test_reg_tools_iso():
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAladin, RegF3D) from nipype.testing import example_data import os import pytest @pytest.mark.skipif(no_niftyreg(cmd='reg_aladin'), reason="niftyreg is not installed. reg_aladin not found.") def test_reg_aladin(): """ tests for reg_aladin interface""" # Create a reg_aladin object nr_aladin = RegAladin() # Check if the command is properly defined assert nr_aladin.cmd == get_custom_path('reg_aladin') # test raising error with mandatory args absent with pytest.raises(ValueError): nr_aladin.run() # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') rmask_file = example_data('mask.nii') nr_aladin.inputs.ref_file = ref_file nr_aladin.inputs.flo_file = flo_file
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAladin, RegF3D) from nipype.testing import example_data import os import pytest @pytest.mark.skipif( no_niftyreg(cmd='reg_aladin'), reason="niftyreg is not installed. reg_aladin not found.") def test_reg_aladin(): """ tests for reg_aladin interface""" # Create a reg_aladin object nr_aladin = RegAladin() # Check if the command is properly defined assert nr_aladin.cmd == get_custom_path('reg_aladin') # test raising error with mandatory args absent with pytest.raises(ValueError): nr_aladin.run() # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') rmask_file = example_data('mask.nii') nr_aladin.inputs.ref_file = ref_file
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import no_niftyreg, get_custom_path, RegTools from nipype.testing import skipif, example_data import os import pytest @skipif(no_niftyreg(cmd='reg_tools')) def test_reg_tools_mul(): # Create a reg_tools object nr = RegTools() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_tools') # test raising error with mandatory args absent with pytest.raises(ValueError): nr.run() # Assign some input data in_file = example_data('im1.nii') nr.inputs.in_file = in_file nr.inputs.mul_val = 4 nr.inputs.omp_core_val = 4 cmd_tmp = '{cmd} -in {in_file} -mul 4.0 -omp 4 -out {out_file}' expected_cmd = cmd_tmp.format(cmd=get_custom_path('reg_tools'), in_file=in_file,
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegMeasure) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_measure')) def test_reg_measure(): # Create a reg_measure object nr = RegMeasure() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_measure') # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.measure_type = 'lncc' nr.inputs.omp_core_val = 4 expected_cmd = get_custom_path('reg_measure') + ' ' + '-flo ' + flo_file + ' ' + '-lncc ' + '-omp 4 '+\ '-out ' + os.getcwd() + os.sep + 'im2_lncc.txt ' + '-ref ' + ref_file yield assert_equal, nr.cmdline, expected_cmd
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegTransform) from nipype.testing import skipif, example_data import os @skipif(no_niftyreg(cmd='reg_transform')) def test_reg_transform_def(): # Create a reg_transform object nr = RegTransform() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_transform') # Assign some input data trans_file = example_data('warpfield.nii') nr.inputs.def_input = trans_file nr.inputs.omp_core_val = 4 cmd_tmp = '{cmd} -omp 4 -def {trans_file} {out_file}' expected_cmd = cmd_tmp.format(cmd=get_custom_path('reg_transform'), trans_file=trans_file, out_file=os.path.join( os.getcwd(), 'warpfield_trans.nii.gz')) assert nr.cmdline == expected_cmd
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegF3D) from nipype.testing import (assert_equal, skipif, example_data) @skipif(no_niftyreg(cmd='reg_f3d')) def test_reg_f3d(): # Create a reg_f3d object nr = RegF3D() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path('reg_f3d') # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') rmask_file = example_data('mask.nii') nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.rmask_file = rmask_file nr.inputs.omp_core_val = 4 nr.inputs.vel_flag = True nr.inputs.be_val = 0.1 nr.inputs.le_val = 0.1 expected_cmd = get_custom_path('reg_f3d') + ' ' + '-be 0.100000 ' +\
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAverage, RegResample, RegJacobian, RegTools, RegMeasure, RegTransform) from nipype.testing import example_data import os import pytest @pytest.mark.skipif( no_niftyreg(cmd='reg_resample'), reason="niftyreg is not installed. reg_resample not found.") def test_reg_resample_res(): """ tests for reg_resample interface """ # Create a reg_resample object nr_resample = RegResample() # Check if the command is properly defined assert nr_resample.cmd == get_custom_path('reg_resample') # test raising error with mandatory args absent with pytest.raises(ValueError): nr_resample.run() # Resample res ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') trans_file = example_data('warpfield.nii')
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: import os from nipype.interfaces.niftyreg import no_niftyreg, get_custom_path, RegAladin from nipype.testing import assert_equal, skipif, example_data @skipif(no_niftyreg(cmd="reg_aladin")) def test_reg_aladin(): # Create a reg_aladin object nr = RegAladin() # Check if the command is properly defined yield assert_equal, nr.cmd, get_custom_path("reg_aladin") # Assign some input data ref_file = example_data("im1.nii") flo_file = example_data("im2.nii") rmask_file = example_data("mask.nii") nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.rmask_file = rmask_file nr.inputs.omp_core_val = 4 expected_cmd = ( get_custom_path("reg_aladin") + " " + "-aff "
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAladin) from nipype.testing import skipif, example_data import os import pytest @skipif(no_niftyreg(cmd='reg_aladin')) def test_reg_aladin(): # Create a reg_aladin object nr = RegAladin() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_aladin') # test raising error with mandatory args absent with pytest.raises(ValueError): nr.run() # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') rmask_file = example_data('mask.nii') nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.rmask_file = rmask_file nr.inputs.omp_core_val = 4
# -*- coding: utf-8 -*- # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAverage, RegResample, RegJacobian, RegTools, RegMeasure, RegTransform) from nipype.testing import example_data import os import pytest @pytest.mark.skipif(no_niftyreg(cmd='reg_resample'), reason="niftyreg is not installed. reg_resample not found." ) def test_reg_resample_res(): """ tests for reg_resample interface """ # Create a reg_resample object nr_resample = RegResample() # Check if the command is properly defined assert nr_resample.cmd == get_custom_path('reg_resample') # test raising error with mandatory args absent with pytest.raises(ValueError): nr_resample.run() # Resample res ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') trans_file = example_data('warpfield.nii')
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegJacobian) from nipype.testing import skipif, example_data import os import pytest @skipif(no_niftyreg(cmd='reg_jacobian')) def test_reg_jacobian_jac(): # Create a reg_jacobian object nr = RegJacobian() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_jacobian') # test raising error with mandatory args absent with pytest.raises(ValueError): nr.run() # Assign some input data ref_file = example_data('im1.nii') trans_file = example_data('warpfield.nii') nr.inputs.ref_file = ref_file nr.inputs.trans_file = trans_file nr.inputs.omp_core_val = 4 cmd_tmp = '{cmd} -omp 4 -ref {ref} -trans {trans} -jac {jac}'
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegAverage) from nipype.testing import skipif, example_data import os @skipif(no_niftyreg(cmd='reg_average')) def test_reg_average_avg_nii(): # Create a reg_average object nr = RegAverage() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_average') # Assign some input data one_file = example_data('im1.nii') two_file = example_data('im2.nii') three_file = example_data('im3.nii') nr.inputs.avg_files = [one_file, two_file, three_file] nr.cmdline # Read the reg_average_cmd reg_average_cmd = os.path.join(os.getcwd(), 'reg_average_cmd') with open(reg_average_cmd, 'rb') as f: argv = f.read() os.remove(reg_average_cmd)
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: from nipype.interfaces.niftyreg import (no_niftyreg, get_custom_path, RegMeasure) from nipype.testing import skipif, example_data import pytest import os @skipif(no_niftyreg(cmd='reg_measure')) def test_reg_measure(): # Create a reg_measure object nr = RegMeasure() # Check if the command is properly defined assert nr.cmd == get_custom_path('reg_measure') # test raising error with mandatory args absent with pytest.raises(ValueError): nr.run() # Assign some input data ref_file = example_data('im1.nii') flo_file = example_data('im2.nii') nr.inputs.ref_file = ref_file nr.inputs.flo_file = flo_file nr.inputs.measure_type = 'lncc' nr.inputs.omp_core_val = 4