2626
2727from CPAC .pipeline import \
2828 nipype_pipeline_engine as pe # pylint: disable=ungrouped-imports
29+ from nipype import config , logging # pylint: disable=wrong-import-order
2930from nipype .interfaces .utility import \
3031 Rename # pylint: disable=wrong-import-order
3132from CPAC .func_preproc .func_preproc import motion_estimate_filter
@@ -1188,8 +1189,7 @@ def node_data(self, resource, **kwargs):
11881189
11891190
11901191class NodeBlock :
1191- def __init__ (self , node_block_functions ):
1192-
1192+ def __init__ (self , node_block_functions , debug = False ):
11931193 if not isinstance (node_block_functions , list ):
11941194 node_block_functions = [node_block_functions ]
11951195
@@ -1238,6 +1238,19 @@ def __init__(self, node_block_functions):
12381238 if 'options' in init_dct :
12391239 self .options = init_dct ['options' ]
12401240
1241+ logger .info ('Connecting %s...' , name )
1242+ if debug :
1243+ config .update_config (
1244+ {'logging' : {'workflow_level' : 'DEBUG' }})
1245+ logging .update_logging (config )
1246+ logger .debug ('"inputs": %s\n \t "outputs": %s%s' ,
1247+ init_dct ["inputs" ], list (self .outputs .keys ()),
1248+ f'\n \t "options": { self .options } '
1249+ if self .options != ['base' ] else '' )
1250+ config .update_config (
1251+ {'logging' : {'workflow_level' : 'INFO' }})
1252+ logging .update_logging (config )
1253+
12411254 def get_name (self ):
12421255 return self .name
12431256
@@ -1384,7 +1397,6 @@ def connect_block(self, wf, cfg, rpool):
13841397 switch = [switch ]
13851398
13861399 if True in switch :
1387- logger .info ('Connecting %s...' , name )
13881400 for pipe_idx , strat_pool in rpool .get_strats (
13891401 inputs , debug ).items (): # strat_pool is a ResourcePool like {'desc-preproc_T1w': { 'json': info, 'data': (node, out) }, 'desc-brain_mask': etc.}
13901402 fork = False in switch # keep in mind rpool.get_strats(inputs) = {pipe_idx1: {'desc-preproc_T1w': etc.}, pipe_idx2: {..} }
@@ -2202,7 +2214,7 @@ def run_node_blocks(blocks, data_paths, cfg=None):
22022214 }
22032215
22042216 # TODO: WE HAVE TO PARSE OVER UNIQUE ID'S!!!
2205- rpool = initiate_rpool (cfg , data_paths )
2217+ _ , rpool = initiate_rpool (cfg , data_paths )
22062218
22072219 wf = pe .Workflow (name = 'node_blocks' )
22082220 wf .base_dir = cfg .pipeline_setup ['working_directory' ]['path' ]
@@ -2222,7 +2234,9 @@ def run_node_blocks(blocks, data_paths, cfg=None):
22222234 run_blocks += blocks [1 ]
22232235
22242236 for block in run_blocks :
2225- wf = NodeBlock (block ).connect_block (wf , cfg , rpool )
2237+ wf = NodeBlock (block , debug = cfg ['pipeline_setup' , 'Debugging' ,
2238+ 'verbose' ]).connect_block (
2239+ wf , cfg , rpool )
22262240 rpool .gather_pipes (wf , cfg )
22272241
22282242 wf .run ()
0 commit comments