示例#1
0
# 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'
示例#2
0
# 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():
示例#3
0
# 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'))
示例#4
0
# 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)
示例#5
0
# 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():
示例#6
0
# -*- 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
示例#7
0
文件: test_reg.py 项目: NifTK/nipype
# -*- 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
示例#8
0
# 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,
示例#9
0
# 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'
示例#10
0
# 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
示例#11
0
# 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
示例#12
0
# 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 ' +\
示例#13
0
# -*- 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')
示例#14
0
# 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 "
示例#15
0
# 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
示例#16
0
# -*- 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')
示例#17
0
# 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}'
示例#18
0
# 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)
示例#19
0
# 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