Пример #1
0
def test_flow_runner():
    old_argv = sys.argv
    sys.argv = [sys.argv[0]]

    opt_keys = ['param_combined', 'dwf1.param1', 'dwf2.param2', 'force', 'out_strat',
                'mix_names']

    pos_results = ['dipy.txt']
    opt_results = [30, 10, 20, True, 'absolute', True]

    inputs = inputs_from_results(opt_results, opt_keys, optional=True)
    inputs.extend(inputs_from_results(pos_results))

    sys.argv.extend(inputs)

    dcwf = DummyCombinedWorkflow()
    param1, param2, combined = run_flow(dcwf)

    # generic flow params
    assert dcwf._force_overwrite
    assert dcwf._output_strategy == 'absolute'
    assert dcwf._mix_names

    # sub flow params
    assert param1 == 10
    assert param2 == 20

    # parent flow param
    assert combined == 30

    sys.argv = old_argv
Пример #2
0
def test_flow_runner():
    old_argv = sys.argv
    sys.argv = [sys.argv[0]]

    opt_keys = [
        'param_combined', 'dwf1.param1', 'dwf2.param2', 'force', 'out_strat',
        'mix_names'
    ]

    pos_results = ['dipy.txt']
    opt_results = [30, 10, 20, True, 'absolute', True]

    inputs = inputs_from_results(opt_results, opt_keys, optional=True)
    inputs.extend(inputs_from_results(pos_results))

    sys.argv.extend(inputs)

    dcwf = DummyCombinedWorkflow()
    param1, param2, combined = run_flow(dcwf)

    # generic flow params
    assert dcwf._force_overwrite
    assert dcwf._output_strategy == 'absolute'
    assert dcwf._mix_names

    # sub flow params
    assert param1 == 10
    assert param2 == 20

    # parent flow param
    assert combined == 30

    sys.argv = old_argv
Пример #3
0
def test_variable_type():
    with TemporaryDirectory() as out_dir:
        open(pjoin(out_dir, 'test'), 'w').close()
        open(pjoin(out_dir, 'test1'), 'w').close()
        open(pjoin(out_dir, 'test2'), 'w').close()

        sys.argv = [sys.argv[0]]
        pos_results = [pjoin(out_dir, 'test'), pjoin(out_dir, 'test1'),
                       pjoin(out_dir, 'test2'), 12]
        inputs = inputs_from_results(pos_results)
        sys.argv.extend(inputs)
        dcwf = DummyVariableTypeWorkflow()
        _, positional_res, positional_res2 = run_flow(dcwf)
        npt.assert_equal(positional_res2, 12)

        for k, v in zip(positional_res, pos_results[:-1]):
            npt.assert_equal(k, v)

        dcwf = DummyVariableTypeErrorWorkflow()
        npt.assert_raises(ValueError, run_flow, dcwf)
Пример #4
0
def test_variable_type():
    with TemporaryDirectory() as out_dir:
        open(pjoin(out_dir, 'test'), 'w').close()
        open(pjoin(out_dir, 'test1'), 'w').close()
        open(pjoin(out_dir, 'test2'), 'w').close()

        sys.argv = [sys.argv[0]]
        pos_results = [
            pjoin(out_dir, 'test'),
            pjoin(out_dir, 'test1'),
            pjoin(out_dir, 'test2'), 12
        ]
        inputs = inputs_from_results(pos_results)
        sys.argv.extend(inputs)
        dcwf = DummyVariableTypeWorkflow()
        _, positional_res, positional_res2 = run_flow(dcwf)
        npt.assert_equal(positional_res2, 12)

        for k, v in zip(positional_res, pos_results[:-1]):
            npt.assert_equal(k, v)

        dcwf = DummyVariableTypeErrorWorkflow()
        npt.assert_raises(ValueError, run_flow, dcwf)
Пример #5
0
"""
"""

This is it for the combined workflow class! Now to be able to call it easily via
command line, you need this last bit of code. It is usually in an executable
file located in ../dipy/bin/.
"""

from dipy.workflows.flow_runner import run_flow
"""
This is the method that will wrap everything that is needed to make a workflow
ready then run it.
"""

if __name__ == "__main__":
    run_flow(DenoiseAndSegment())
"""
This is the only thing needed to make your workflow available through command
line.

Now just call the script you just made with -h to see the argparser help text.

`python combined_workflow_creation.py --help`

You should see all your parameters available along with some extra common ones
like logging file and force overwrite. Also all the documentation you wrote
about each parameter is there. Also note that every sub workflow optional
parameter is available.

Now call it for real with a nifti file to see the results. Experiment
with the parameters and see the results.
Пример #6
0
"""
The second line imports the ``AppendTextFlow`` class from the newly created
``my_workflow.py`` file. In this specific case, we comment this import
since ``AppendTextFlow`` class is not on an external file but in the current file.
"""

# from dipy.workflows.my_workflow import AppendTextFlow

"""
This is the method that will wrap everything that is needed to make a flow
command line ready then run it.
"""

if __name__ == "__main__":
    run_flow(AppendTextFlow())

"""
This is the only thing needed to make your workflow available through command
line.

Now just call the script you just made with ``-h`` to see the argparser help
text::

   python workflow_creation.py --help

You should see all your parameters available along with some extra common ones
like logging file and force overwrite. Also all the documentation you wrote
about each parameter is there.

Now call it for real with a text file::
Пример #7
0
"""

This is it for the workflow! Now to be able to call it easily via command
line, you need to add this bit of code. Usually this is in a separate
executable file located in ``bin``.
"""

from dipy.workflows.flow_runner import run_flow
"""
This is the method that will wrap everything that is needed to make a flow
command line ready then run it.
"""

if __name__ == "__main__":
    run_flow(AppendTextFlow())
"""
This is the only thing needed to make your workflow available through command
line.

Now just call the script you just made with ``-h`` to see the argparser help
text::

   python workflow_creation.py --help

You should see all your parameters available along with some extra common ones
like logging file and force overwrite. Also all the documentation you wrote
about each parameter is there.

Now call it for real with a text file::
Пример #8
0
"""

This is it for the combined workflow class! Now to be able to call it easily via
command line, you need this last bit of code. It is usually in an executable
file located in ``bin``.
"""

from dipy.workflows.flow_runner import run_flow
"""
This is the method that will wrap everything that is needed to make a workflow
ready then run it.
"""

if __name__ == "__main__":
    run_flow(DenoiseAndSegment())
"""
This is the only thing needed to make your workflow available through command
line.

Now just call the script you just made with ``-h`` to see the argparser help
text::

   python combined_workflow_creation.py --help

You should see all your parameters available along with some extra common ones
like logging file and force overwrite. Also all the documentation you wrote
about each parameter is there. Also note that every sub workflow optional
parameter is available.

Now call it for real with a nifti file to see the results. Experiment