Skip to content

Commit 8a837ec

Browse files
MRG: Make cluster permutation logging slightly less verbose for default log level (#10907)
* Make cluster permutation logging slightly less verbose for default log level * Update mne/stats/cluster_level.py Co-authored-by: Eric Larson <larson.eric.d@gmail.com> * Reduce progress bar text Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent 4351e61 commit 8a837ec

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mne/stats/cluster_level.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ def _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun,
905905
partitions = _get_partitions_from_adjacency(adjacency, n_times)
906906
else:
907907
partitions = None
908-
logger.info('Running initial clustering')
908+
logger.info('Running initial clustering')
909909
out = _find_clusters(t_obs, threshold, tail, adjacency,
910910
max_step=max_step, include=include,
911911
partitions=partitions, t_power=t_power,
@@ -919,7 +919,7 @@ def _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun,
919919
if isinstance(threshold, dict):
920920
t_obs = cluster_stats.reshape(t_obs.shape) * np.sign(t_obs)
921921

922-
logger.info('Found %d clusters' % len(clusters))
922+
logger.info(f'Found {len(clusters)} cluster{_pl(clusters)}')
923923

924924
# convert clusters to old format
925925
if adjacency is not None and adjacency is not False:
@@ -978,8 +978,11 @@ def _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun,
978978
this_include = include
979979
else:
980980
this_include = step_down_include
981-
logger.info('Permuting %d times%s...' % (len(orders), extra))
982-
with ProgressBar(len(orders)) as progress_bar:
981+
982+
with ProgressBar(
983+
iterable=range(len(orders)),
984+
mesg=f'Permuting{extra}'
985+
) as progress_bar:
983986
H0 = parallel(
984987
my_do_perm_func(X_full, slices, threshold, tail, adjacency,
985988
stat_fun, max_step, this_include, partitions,
@@ -995,7 +998,7 @@ def _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun,
995998
orig = abs(cluster_stats).max()
996999
H0.insert(0, [orig])
9971000
H0 = np.concatenate(H0)
998-
logger.info('Computing cluster p-values')
1001+
logger.debug('Computing cluster p-values')
9991002
cluster_pv = _pval_from_histogram(cluster_stats, H0, tail)
10001003

10011004
# figure out how many new ones will be removed for step-down
@@ -1014,7 +1017,7 @@ def _permutation_cluster_test(X, threshold, n_permutations, tail, stat_fun,
10141017
'cluster%s to exclude from subsequent iterations'
10151018
% (n_step_downs, n_removed, a_text,
10161019
_pl(n_removed)))
1017-
logger.info('Done.')
1020+
10181021
# The clusters should have the same shape as the samples
10191022
clusters = _reshape_clusters(clusters, sample_shape)
10201023
return t_obs, clusters, cluster_pv, H0

0 commit comments

Comments
 (0)