Exemplo n.º 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.niftyseg import no_niftyseg, get_custom_path, CalcTopNCC
from nipype.testing import skipif, example_data
import pytest


@skipif(no_niftyseg(cmd='seg_CalcTopNCC'))
def test_seg_calctopncc():

    # Create a node object
    calctopncc = CalcTopNCC()

    # Check if the command is properly defined
    assert calctopncc.cmd == get_custom_path('seg_CalcTopNCC')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        calctopncc.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    file1 = example_data('im2.nii')
    file2 = example_data('im3.nii')
    calctopncc.inputs.in_file = in_file
    calctopncc.inputs.num_templates = 2
    calctopncc.inputs.in_templates = [file1, file2]
    calctopncc.inputs.top_templates = 1

    cmd_tmp = '{cmd} -target {in_file} -templates 2 {file1} {file2} -n 1'
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        PatchMatch)
from nipype.testing import assert_equal, skipif, example_data


@skipif(no_niftyseg(cmd='seg_PatchMatch'))
def test_seg_patchmatch():

    # Create a reg_aladin object
    seg_patchmatch = PatchMatch()

    # Check if the command is properly defined
    yield assert_equal, seg_patchmatch.cmd, get_custom_path('seg_PatchMatch')

    # Assign some input data
    in_file = example_data('im1.nii')
    seg_patchmatch.inputs.in_file = in_file
    seg_patchmatch.inputs.mask_file = in_file
    seg_patchmatch.inputs.database_file = in_file

    cmd_tmp = '{cmd} -i {in_file} -m {mask_file} -db {db} -o {out_file}'
    expected_cmd = cmd_tmp.format(
                        cmd=get_custom_path('seg_PatchMatch'),
                        in_file=in_file,
                        mask_file=in_file,
                        db=in_file,
                        out_file=os.path.join(os.getcwd(), 'im1_pm.nii'))
Exemplo n.º 3
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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryStats, BinaryStats)
from nipype.testing import example_data
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_stats'),
                    reason="niftyseg is not installed")
def test_unary_stats():
    """ Test for the seg_stats interfaces """
    # Create a node object
    unarys = UnaryStats()

    # Check if the command is properly defined
    assert unarys.cmd == get_custom_path('seg_stats')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarys.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarys.inputs.in_file = in_file
    unarys.inputs.operation = 'a'

    expected_cmd = '{cmd} {in_file} -a'.format(
        cmd=get_custom_path('seg_stats'),
        in_file=in_file)
Exemplo n.º 4
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.niftyseg import no_niftyseg, get_custom_path, PatchMatch
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_PatchMatch'),
                    reason="niftyseg is not installed")
def test_seg_patchmatch():

    # Create a node object
    seg_patchmatch = PatchMatch()

    # Check if the command is properly defined
    assert seg_patchmatch.cmd == get_custom_path('seg_PatchMatch')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_patchmatch.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    mask_file = example_data('im2.nii')
    db_file = example_data('db.xml')
    seg_patchmatch.inputs.in_file = in_file
    seg_patchmatch.inputs.mask_file = mask_file
    seg_patchmatch.inputs.database_file = db_file
Exemplo n.º 5
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.niftyseg import (no_niftyseg, get_custom_path,
                                        FillLesions)
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_FillLesions'))
def test_seg_filllesions():

    # Create a node object
    seg_fill = FillLesions()

    # Check if the command is properly defined
    assert seg_fill.cmd == get_custom_path('seg_FillLesions')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_fill.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    lesion_mask = example_data('im2.nii')
    seg_fill.inputs.in_file = in_file
    seg_fill.inputs.lesion_mask = lesion_mask

    expected_cmd = '{cmd} -i {in_file} -l {lesion_mask} -o {out_file}'.format(
                cmd=get_custom_path('seg_FillLesions'),
Exemplo n.º 6
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.niftyseg import (no_niftyseg, get_custom_path,
                                        LabelFusion, CalcTopNCC)
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_LabFusion'),
                    reason="niftyseg is not installed")
def test_seg_lab_fusion():
    """ Test interfaces for seg_labfusion"""
    # Create a node object
    steps = LabelFusion()

    # Check if the command is properly defined
    assert steps.cmd == get_custom_path('seg_LabFusion')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        steps.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    file_to_seg = example_data('im2.nii')
    template_file = example_data('im3.nii')
    steps.inputs.in_file = in_file
    steps.inputs.kernel_size = 2.0
    steps.inputs.file_to_seg = file_to_seg
Exemplo n.º 7
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.niftyseg import (no_niftyseg, get_custom_path,
                                        LabelFusion, CalcTopNCC)
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_LabFusion'),
                    reason="niftyseg is not installed")
def test_seg_lab_fusion():
    """ Test interfaces for seg_labfusion"""
    # Create a node object
    steps = LabelFusion()

    # Check if the command is properly defined
    assert steps.cmd == get_custom_path('seg_LabFusion')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        steps.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    file_to_seg = example_data('im2.nii')
    template_file = example_data('im3.nii')
    steps.inputs.in_file = in_file
    steps.inputs.kernel_size = 2.0
    steps.inputs.file_to_seg = file_to_seg
Exemplo n.º 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.niftyseg import no_niftyseg, get_custom_path, PatchMatch
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_PatchMatch'))
def test_seg_patchmatch():

    # Create a node object
    seg_patchmatch = PatchMatch()

    # Check if the command is properly defined
    assert seg_patchmatch.cmd == get_custom_path('seg_PatchMatch')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_patchmatch.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    mask_file = example_data('im2.nii')
    db_file = example_data('db.xml')
    seg_patchmatch.inputs.in_file = in_file
    seg_patchmatch.inputs.mask_file = mask_file
    seg_patchmatch.inputs.database_file = db_file

    cmd_tmp = '{cmd} -i {in_file} -m {mask_file} -db {db} -o {out_file}'
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryMaths, BinaryMaths,
                                        BinaryMathsInteger, TupleMaths,
                                        Merge)
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_maths'),
                    reason="niftyseg is not installed")
def test_unary_maths():

    # Create a node object
    unarym = UnaryMaths()

    # Check if the command is properly defined
    assert unarym.cmd == get_custom_path('seg_maths')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarym.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarym.inputs.in_file = in_file
    unarym.inputs.operation = 'otsu'
    unarym.inputs.output_datatype = 'float'
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryMaths, BinaryMaths)
from nipype.testing import (assert_equal, skipif, example_data)


@skipif(no_niftyseg(cmd='seg_maths'))
def test_seg_maths():

    # Create a reg_aladin object
    unarym = UnaryMaths()

    # Check if the command is properly defined
    yield assert_equal, unarym.cmd, get_custom_path('seg_maths')

    # Assign some input data
    in_file = example_data('im1.nii')
    unarym.inputs.in_file = in_file
    unarym.inputs.operation = 'otsu'

    expected_cmd = '{cmd} {in_file} -otsu {out_file}'.format(
                        cmd=get_custom_path('seg_maths'),
                        in_file=in_file,
                        out_file=os.path.join(os.getcwd(), 'im1_otsu.nii'))

    yield assert_equal, unarym.cmdline, expected_cmd

    # Create a reg_aladin object
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        FillLesions)
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_FillLesions'),
                    reason="niftyseg is not installed")
def test_seg_filllesions():

    # Create a node object
    seg_fill = FillLesions()

    # Check if the command is properly defined
    assert seg_fill.cmd == get_custom_path('seg_FillLesions')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_fill.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    lesion_mask = example_data('im2.nii')
    seg_fill.inputs.in_file = in_file
    seg_fill.inputs.lesion_mask = lesion_mask

    expected_cmd = '{cmd} -i {in_file} -l {lesion_mask} -o {out_file}'.format(
Exemplo n.º 12
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.niftyseg import no_niftyseg, get_custom_path, EM
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_EM'))
def test_seg_em():

    # Create a node object
    seg_em = EM()

    # Check if the command is properly defined
    assert seg_em.cmd == get_custom_path('seg_EM')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_em.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    seg_em.inputs.in_file = in_file
    seg_em.inputs.no_prior = 4

    cmd_tmp = '{cmd} -in {in_file} -nopriors 4 -bc_out {bc_out} -out \
{out_file} -out_outlier {out_outlier}'
    expected_cmd = cmd_tmp.format(
        cmd=get_custom_path('seg_EM'),
Exemplo n.º 13
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.niftyseg import (no_niftyseg, get_custom_path,
                                        LabelFusion)
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_LabFusion'))
def test_steps():

    # Create a node object
    steps = LabelFusion()

    # Check if the command is properly defined
    assert steps.cmd == get_custom_path('seg_LabFusion')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        steps.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    file_to_seg = example_data('im2.nii')
    template_file = example_data('im3.nii')
    steps.inputs.in_file = in_file
    steps.inputs.kernel_size = 2.0
    steps.inputs.file_to_seg = file_to_seg
    steps.inputs.template_file = template_file
Exemplo n.º 14
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.niftyseg import (no_niftyseg, get_custom_path,
                                        CalcTopNCC)
from nipype.testing import assert_equal, skipif, example_data


@skipif(no_niftyseg(cmd='seg_CalcTopNCC'))
def test_seg_patchmatch():

    # Create a reg_aladin object
    calctopncc = CalcTopNCC()

    # Check if the command is properly defined
    yield assert_equal, calctopncc.cmd, get_custom_path('seg_CalcTopNCC')

    # Assign some input data
    in_file = example_data('im1.nii')
    calctopncc.inputs.in_file = in_file
    calctopncc.inputs.num_templates = 2
    calctopncc.inputs.in_templates = [in_file, in_file]
    calctopncc.inputs.top_templates = 1

    cmd_tmp = '{cmd} -target {in_file} -templates 2 {file1} {file2} -n 1'
    expected_cmd = cmd_tmp.format(
                        cmd=get_custom_path('seg_CalcTopNCC'),
                        in_file=in_file,
                        file1=in_file,
                        file2=in_file)
    # out_file=os.path.join(os.getcwd(), 'im1_pm.nii'))
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryStats, BinaryStats)
from nipype.testing import skipif, example_data
import pytest


@skipif(no_niftyseg(cmd='seg_stats'))
def test_unary_stats():

    # Create a node object
    unarys = UnaryStats()

    # Check if the command is properly defined
    assert unarys.cmd == get_custom_path('seg_stats')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarys.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarys.inputs.in_file = in_file
    unarys.inputs.operation = 'a'

    expected_cmd = '{cmd} {in_file} -a'.format(
        cmd=get_custom_path('seg_stats'),
        in_file=in_file)
Exemplo n.º 16
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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryMaths, BinaryMaths,
                                        BinaryMathsInteger, TupleMaths, Merge)
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_maths'),
                    reason="niftyseg is not installed")
def test_unary_maths():

    # Create a node object
    unarym = UnaryMaths()

    # Check if the command is properly defined
    assert unarym.cmd == get_custom_path('seg_maths')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarym.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarym.inputs.in_file = in_file
    unarym.inputs.operation = 'otsu'
    unarym.inputs.output_datatype = 'float'
Exemplo n.º 17
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.niftyseg import no_niftyseg, get_custom_path, FillLesions
from nipype.testing import assert_equal, skipif, example_data


@skipif(no_niftyseg(cmd="seg_FillLesions"))
def test_seg_filllesions():

    # Create a reg_aladin object
    seg_fill = FillLesions()

    # Check if the command is properly defined
    yield assert_equal, seg_fill.cmd, get_custom_path("seg_FillLesions")

    # Assign some input data
    in_file = example_data("im1.nii")
    seg_fill.inputs.in_file = in_file
    seg_fill.inputs.lesion_mask = in_file

    expected_cmd = "{cmd} -i {in_file} -l {lesion_mask} -o {out_file}".format(
        cmd=get_custom_path("seg_FillLesions"),
        in_file=in_file,
        lesion_mask=in_file,
        out_file=os.path.join(os.getcwd(), "im1_lesions_filled.nii"),
    )

    yield assert_equal, seg_fill.cmdline, expected_cmd
Exemplo n.º 18
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.niftyseg import no_niftyseg, get_custom_path, EM
from nipype.testing import assert_equal, skipif, example_data


@skipif(no_niftyseg(cmd='seg_EM'))
def test_seg_em():

    # Create a reg_aladin object
    seg_em = EM()

    # Check if the command is properly defined
    yield assert_equal, seg_em.cmd, get_custom_path('seg_EM')

    # Assign some input data
    in_file = example_data('im1.nii')
    seg_em.inputs.in_file = in_file
    seg_em.inputs.no_prior = 4

    cmd_tmp = '{cmd} -in {in_file} -nopriors 4 -bc_out {bc_out} -out {out_file} \
-out_outlier {out_outlier}'
    expected_cmd = cmd_tmp.format(
        cmd=get_custom_path('seg_EM'),
        in_file=in_file,
        out_file=os.path.join(os.getcwd(), 'im1_em.nii'),
        bc_out=os.path.join(os.getcwd(), 'im1_bc_em.nii'),
        out_outlier=os.path.join(os.getcwd(), 'im1_outlier_em.nii'))
Exemplo n.º 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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryStats, BinaryStats)
from nipype.testing import skipif, example_data
import pytest


@skipif(no_niftyseg(cmd='seg_stats'))
def test_unary_stats():

    # Create a node object
    unarys = UnaryStats()

    # Check if the command is properly defined
    assert unarys.cmd == get_custom_path('seg_stats')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarys.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarys.inputs.in_file = in_file
    unarys.inputs.operation = 'a'

    expected_cmd = '{cmd} {in_file} -a'.format(
        cmd=get_custom_path('seg_stats'), in_file=in_file)

    assert unarys.cmdline == expected_cmd
Exemplo n.º 20
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.niftyseg import (no_niftyseg, get_custom_path,
                                        LabelFusion)
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_LabFusion'))
def test_steps():

    # Create a node object
    steps = LabelFusion()

    # Check if the command is properly defined
    assert steps.cmd == get_custom_path('seg_LabFusion')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        steps.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    file_to_seg = example_data('im2.nii')
    template_file = example_data('im3.nii')
    steps.inputs.in_file = in_file
    steps.inputs.kernel_size = 2.0
    steps.inputs.file_to_seg = file_to_seg
    steps.inputs.template_file = template_file
Exemplo n.º 21
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.niftyseg import (no_niftyseg, get_custom_path,
                                        UnaryMaths, BinaryMaths,
                                        BinaryMathsInteger, TupleMaths, Merge)
from nipype.testing import skipif, example_data
import os
import pytest


@skipif(no_niftyseg(cmd='seg_maths'))
def test_unary_maths():

    # Create a node object
    unarym = UnaryMaths()

    # Check if the command is properly defined
    assert unarym.cmd == get_custom_path('seg_maths')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        unarym.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    unarym.inputs.in_file = in_file
    unarym.inputs.operation = 'otsu'
    unarym.inputs.output_datatype = 'float'

    expected_cmd = '{cmd} {in_file} -otsu -odt float {out_file}'.format(
Exemplo n.º 22
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.niftyseg import no_niftyseg, get_custom_path, EM
from nipype.testing import example_data
import os
import pytest


@pytest.mark.skipif(no_niftyseg(cmd='seg_EM'),
                    reason="niftyseg is not installed")
def test_seg_em():

    # Create a node object
    seg_em = EM()

    # Check if the command is properly defined
    assert seg_em.cmd == get_custom_path('seg_EM')

    # test raising error with mandatory args absent
    with pytest.raises(ValueError):
        seg_em.run()

    # Assign some input data
    in_file = example_data('im1.nii')
    seg_em.inputs.in_file = in_file
    seg_em.inputs.no_prior = 4

    cmd_tmp = '{cmd} -in {in_file} -nopriors 4 -bc_out {bc_out} -out \
{out_file} -out_outlier {out_outlier}'
    expected_cmd = cmd_tmp.format(