@@ -63,7 +63,12 @@ def _check_input(obj, clss, options, **kwargs):
63
63
if obj == FWECorrector :
64
64
kwargs ["method" ] = obj_str
65
65
66
- return _check_type (obj , clss , ** kwargs )
66
+ # Apply kwargs (including n_cores) when obj is a class or string
67
+ if isinstance (obj , (str , type )):
68
+ return _check_type (obj , clss , ** kwargs )
69
+
70
+ # If object is already instantiated, return it as-is
71
+ return _check_type (obj , clss )
67
72
68
73
69
74
class Workflow (NiMAREBase ):
@@ -93,23 +98,25 @@ def _preprocess_input(self, estimator, corrector, diagnostics):
93
98
diagnostics = [diagnostics ]
94
99
95
100
# Check inputs and set defaults if input is None
96
- estimator = (
97
- self ._estm_default (n_cores = self .n_cores )
98
- if estimator is None
99
- else _check_input (estimator , self ._estm_base , self ._estm_options , n_cores = self .n_cores )
100
- )
101
-
102
- corrector = (
103
- self ._corr_default (method = self ._mcc_method , n_cores = self .n_cores )
104
- if corrector is None
105
- else _check_input (corrector , Corrector , self ._corr_options , n_cores = self .n_cores )
106
- )
101
+ if estimator is None :
102
+ estimator = self ._estm_default (n_cores = self .n_cores )
103
+ else :
104
+ estimator = _check_input (
105
+ estimator , self ._estm_base , self ._estm_options , n_cores = self .n_cores
106
+ )
107
+
108
+ if corrector is None :
109
+ corrector = self ._corr_default (method = self ._mcc_method , n_cores = self .n_cores )
110
+ else :
111
+ corrector = _check_input (
112
+ corrector , Corrector , self ._corr_options , n_cores = self .n_cores
113
+ )
107
114
108
115
diag_kwargs = {
109
116
"voxel_thresh" : self .voxel_thresh ,
110
117
"cluster_threshold" : self .cluster_threshold ,
111
- "n_cores" : self .n_cores ,
112
118
}
119
+ diag_kwargs ["n_cores" ] = self .n_cores
113
120
if diagnostics is None :
114
121
diagnostics = [self ._diag_default (** diag_kwargs )]
115
122
else :
0 commit comments