<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> from scipy import linalg <EOL> import matplotlib . pyplot as plt <EOL> from nilearn import datasets <EOL> from nilearn . input_data import NiftiMasker <EOL> from nilearn . mass_univariate import permuted_ols <EOL> n_samples = <NUM_LIT> <EOL> localizer_dataset = datasets . fetch_localizer_contrasts ( <EOL> [ '<STR_LIT>' ] , n_subjects = n_samples ) <EOL> print ( '<STR_LIT>' % <EOL> localizer_dataset . cmaps [ <NUM_LIT:0> ] ) <EOL> tested_var = localizer_dataset . ext_vars [ '<STR_LIT>' ] <EOL> mask_quality_check = np . where ( tested_var != b'<STR_LIT:None>' ) [ <NUM_LIT:0> ] <EOL> n_samples = mask_quality_check . size <EOL> contrast_map_filenames = [ localizer_dataset . cmaps [ i ] <EOL> for i in mask_quality_check ] <EOL> tested_var = tested_var [ mask_quality_check ] . astype ( float ) . reshape ( ( - <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> print ( "<STR_LIT>" % n_samples ) <EOL> nifti_masker = NiftiMasker ( <EOL> smoothing_fwhm = <NUM_LIT:5> , <EOL> memory = '<STR_LIT>' , memory_level = <NUM_LIT:1> ) <EOL> fmri_masked = nifti_masker . fit_transform ( contrast_map_filenames ) <EOL> from nilearn . _utils . fixes import f_regression <EOL> _ , pvals_anova = f_regression ( fmri_masked , tested_var , center = True ) <EOL> pvals_anova *= fmri_masked . shape [ <NUM_LIT:1> ] <EOL> pvals_anova [ np . isnan ( pvals_anova ) ] = <NUM_LIT:1> <EOL> pvals_anova [ pvals_anova > <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> neg_log_pvals_anova = - np . log10 ( pvals_anova ) <EOL> neg_log_pvals_anova_unmasked = nifti_masker . inverse_transform ( <EOL> neg_log_pvals_anova ) <EOL> neg_log_pvals_permuted_ols , _ , _ = permuted_ols ( <EOL> tested_var , fmri_masked , <EOL> model_intercept = True , <EOL> n_perm = <NUM_LIT> , <EOL> n_jobs = <NUM_LIT:1> ) <EOL> neg_log_pvals_permuted_ols_unmasked = nifti_masker . inverse_transform ( <EOL> np . ravel ( neg_log_pvals_permuted_ols ) ) <EOL> from nilearn . plotting import plot_stat_map , show <EOL> z_slice = <NUM_LIT:12> <EOL> from nilearn . image . resampling import coord_transform <EOL> affine = neg_log_pvals_anova_unmasked . get_affine ( ) <EOL> _ , _ , k_slice = coord_transform ( <NUM_LIT:0> , <NUM_LIT:0> , z_slice , <EOL> linalg . inv ( affine ) ) <EOL> k_slice = np . round ( k_slice ) <EOL> threshold = - np . log10 ( <NUM_LIT:0.1> ) <EOL> vmax = min ( np . amax ( neg_log_pvals_permuted_ols ) , <EOL> np . amax ( neg_log_pvals_anova ) ) <EOL> fig = plt . figure ( figsize = ( <NUM_LIT:5> , <NUM_LIT:7> ) , facecolor = '<STR_LIT:k>' ) <EOL> display = plot_stat_map ( neg_log_pvals_anova_unmasked , <EOL> threshold = threshold , cmap = plt . cm . autumn , <EOL> display_mode = '<STR_LIT:z>' , cut_coords = [ z_slice ] , <EOL> figure = fig , vmax = vmax , black_bg = True ) <EOL> neg_log_pvals_anova_data = neg_log_pvals_anova_unmasked . get_data ( ) <EOL> neg_log_pvals_anova_slice_data = neg_log_pvals_anova_data [ ... , k_slice ] <EOL> n_detections = ( neg_log_pvals_anova_slice_data > threshold ) . sum ( ) <EOL> title = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % n_detections <EOL> display . title ( title , y = <NUM_LIT> ) <EOL> fig = plt . figure ( figsize = ( <NUM_LIT:5> , <NUM_LIT:7> ) , facecolor = '<STR_LIT:k>' ) <EOL> display = plot_stat_map ( neg_log_pvals_permuted_ols_unmasked , <EOL> threshold = threshold , cmap = plt . cm . autumn , <EOL> display_mode = '<STR_LIT:z>' , cut_coords = [ z_slice ] , <EOL> figure = fig , vmax = vmax , black_bg = True ) <EOL> neg_log_pvals_permuted_ols_data = neg_log_pvals_permuted_ols_unmasked . get_data ( ) <EOL> neg_log_pvals_permuted_ols_slice_data = neg_log_pvals_permuted_ols_data [ ... , k_slice ] <EOL> n_detections = ( neg_log_pvals_permuted_ols_slice_data > threshold ) . sum ( ) <EOL> title = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) % n_detections <EOL> display . title ( title , y = <NUM_LIT> ) <EOL> show ( ) </s>
