@@ -216,6 +216,95 @@ def validate(config: str, output_folder: str, debug: bool):
216216 sys .exit (1 )
217217
218218
219+ @click .command ()
220+ @click .argument ('output_folder' , type = click .Path (exists = True ))
221+ @click .option ('--estimator' ,
222+ type = click .Choice (['ale' , 'mkdadensity' , 'kda' ]),
223+ default = 'mkdadensity' ,
224+ help = 'CBMA estimator to use (default: mkdadensity)' )
225+ @click .option ('--estimator-args' ,
226+ type = str ,
227+ default = '{}' ,
228+ help = 'JSON string of arguments for the estimator (default: {})' )
229+ @click .option ('--corrector' ,
230+ type = click .Choice (['fdr' , 'montecarlo' , 'bonferroni' ]),
231+ default = 'fdr' ,
232+ help = 'Corrector to use (default: fdr)' )
233+ @click .option ('--corrector-args' ,
234+ type = str ,
235+ default = '{}' ,
236+ help = 'JSON string of arguments for the corrector (default: {})' )
237+ @click .option ('--debug' , is_flag = True ,
238+ help = 'Enable debug mode with post-mortem debugging on errors' )
239+ def meta (output_folder : str , estimator : str , estimator_args : str ,
240+ corrector : str , corrector_args : str , debug : bool ):
241+ """
242+ Run meta-analyses on Autonima output using NiMARE.
243+
244+ This command runs coordinate-based meta-analyses on the results
245+ from an Autonima systematic review pipeline.
246+
247+ Arguments:
248+ OUTPUT_FOLDER Output folder containing NiMADS files
249+
250+ Options:
251+ --estimator CBMA estimator to use (ale, mkdadensity, kda)
252+ --estimator-args JSON string of arguments for the estimator
253+ --corrector Corrector to use (fdr, montecarlo, bonferroni)
254+ --corrector-args JSON string of arguments for the corrector
255+
256+ Examples:
257+ autonima meta results/outputs
258+ autonima meta results/outputs --estimator ale --corrector montecarlo
259+ autonima meta results/outputs --estimator-args '{"n_iters": 1000}' --corrector-args '{"alpha": 0.01}'
260+ """
261+ try :
262+ import json
263+ from pathlib import Path
264+
265+ # Try to import NiMARE dependencies
266+ try :
267+ from .meta import run_meta_analyses
268+ except ImportError as e :
269+ log_error_with_debug (
270+ logger ,
271+ "NiMARE is not installed. Please install with: pip install autonima[meta]"
272+ )
273+ if debug :
274+ import pdb
275+ pdb .post_mortem ()
276+ sys .exit (1 )
277+
278+ # Parse estimator and corrector arguments
279+ try :
280+ estimator_args_dict = json .loads (estimator_args )
281+ corrector_args_dict = json .loads (corrector_args )
282+ except json .JSONDecodeError as e :
283+ log_error_with_debug (logger , f"Error parsing JSON arguments: { e } " )
284+ if debug :
285+ import pdb
286+ pdb .post_mortem ()
287+ sys .exit (1 )
288+
289+ # Run meta-analyses
290+ results = run_meta_analyses (
291+ output_folder ,
292+ estimator_name = estimator ,
293+ estimator_args = estimator_args_dict ,
294+ corrector_name = corrector ,
295+ corrector_args = corrector_args_dict
296+ )
297+
298+ print (f"Completed meta-analyses for { len (results )} columns" )
299+
300+ except Exception as e :
301+ log_error_with_debug (logger , f"Meta-analysis execution failed: { e } " )
302+ if debug :
303+ import pdb
304+ pdb .post_mortem ()
305+ sys .exit (1 )
306+
307+
219308@click .command ()
220309def create_sample_config ():
221310 """
@@ -261,6 +350,7 @@ def cli():
261350cli .add_command (run )
262351cli .add_command (validate )
263352cli .add_command (create_sample_config )
353+ cli .add_command (meta )
264354
265355
266356def main ():
0 commit comments