def extract_stats(neurons, config):
stats = defaultdict(dict)<EOL>for ns, modes in config['<STR_LIT>'].items():<EOL><INDENT>for n in config['<STR_LIT>']:<EOL><INDENT>n = _NEURITE_MAP[n]<EOL>for mode in modes:<EOL><INDENT>stat_name = _stat_name(ns, mode)<EOL>stat = eval_stats(nm.get(ns, neurons, neurite_type=n), mode)<EOL>if stat is None or not stat.shape:<EOL><INDENT>stats[n.name][stat_name] = stat<EOL><DEDENT>else:<EOL><INDENT>assert stat.shape in ((<NUM_LIT:3>, ), ),'<STR_LIT>'<EOL>for i, suffix in enumerate('<STR_LIT>'):<EOL><INDENT>compound_stat_name = stat_name + '<STR_LIT:_>' + suffix<EOL>stats[n.name][compound_stat_name] = stat[i]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>for ns, modes in config['<STR_LIT>'].items():<EOL><INDENT>for mode in modes:<EOL><INDENT>stat_name = _stat_name(ns, mode)<EOL>stats[stat_name] = eval_stats(nm.get(ns, neurons), mode)<EOL><DEDENT><DEDENT>return stats<EOL>
Extract stats from neurons