コード例 #1
0
ファイル: test_Reg_Resample.py プロジェクト: NifTK/nipype
# 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
ファイル: test_reg.py プロジェクト: msharrock/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
    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
ファイル: test_Reg_Tools.py プロジェクト: msharrock/nipype
# 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
ファイル: test_Reg_Resample.py プロジェクト: msharrock/nipype
# 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
ファイル: test_regutils.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,
                                        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
ファイル: test_Reg_Aladin.py プロジェクト: NifTK/nipype
# 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
ファイル: test_Reg_Aladin.py プロジェクト: NifTK/nipype
# 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
ファイル: test_Reg_Jacobian.py プロジェクト: msharrock/nipype
# 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
ファイル: test_Reg_Average.py プロジェクト: msharrock/nipype
# 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
ファイル: test_Reg_Measure.py プロジェクト: msharrock/nipype
# 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