def test_workflow(self):
     # get settings
     settings = default_preproc_settings()
     settings['tmp_dir'] = tempfile.TemporaryDirectory().name
     settings['output_dir'] = tempfile.TemporaryDirectory().name
     gen_wf = workflow.newworkflow('test', settings)
     self.assertIsInstance(gen_wf, Workflow)
 def test_nodedefs(self):
     # get settings
     settings = default_preproc_settings()
     settings['output_dir'] = tempfile.TemporaryDirectory().name
     # define node object
     defnodeobj = nodedefs.definednodes(settings)
     # assert the instance
     self.assertIsInstance(defnodeobj, nodedefs.definednodes)
Exemple #3
0
 def test_basenodedefs(self):
     settings = default_preproc_settings()
     settings['output_dir'] = tempfile.TemporaryDirectory().name
     dn = basenodedefs(settings)
     self.assertIsInstance(dn, basenodedefs)
     dn.set_input(['test'])
     self.assertIsInstance(dn.inputnode, Node)
     dn.set_output(['test'])
     self.assertIsInstance(dn.outputnode, Node)
     dn.set_subs([('_test1', '_test2')])
     dn.set_resubs([
         (r'_test\d{1,3}', '_test'),
     ])
     self.assertIsInstance(dn.datasink, Node)
Exemple #4
0
import unittest
from p3.pipeline import *
from p3.settings import default_preproc_settings
from p3 import workflows
import os
import sys
import importlib
import tempfile
from nipype import Workflow
from mock import patch
from .mock_stdout import MockDevice
sys.path.append(os.path.abspath(os.path.dirname(workflows.__file__))) # set default workflows path
current_dir = os.path.dirname(os.path.abspath(os.path.realpath(__file__))) # get the current directory

# get and setup default settings
settings = default_preproc_settings()
settings['output_dir'] = tempfile.TemporaryDirectory().name
settings['tmp_dir'] = os.path.join(settings['output_dir'],'tmp')
settings['bids_dir'] = os.path.join(current_dir,'example_data')
settings['subject'] = ['01','02','03']
settings['debug'] = False

# import default workflows
imported_workflows = {}
for module in settings['workflows']:
    imported_workflows[module] = importlib.import_module('{}.workflow'.format(module))

class test(unittest.TestCase):
    def test_generate_subworkflows(self):
        with patch('sys.stdout',new=MockDevice()) as fake_out:
            # generate subworkflows
Exemple #5
0
 def test_workflowgnerator(self):
     settings = default_preproc_settings()
     settings['tmp_dir'] = tempfile.TemporaryDirectory().name
     workflowgenerator('test', settings)
     self.assertIsInstance(workflowgenerator.workflow, Workflow)