Same unsmoothed first-level t-maps across runs

Dear all,
I am doing unsmoothed first-level t-maps of each run (n=6) for further classification analysis.
The maps were correct between the contrasts. However, I tried but still don’t understand why the t-maps across each run look the same after visualization.
Thank you very much for your time and help in advance.

    fmri_glm =, events, confounds_glm)
    # Create contrasts
    design_matrices = fmri_glm.design_matrices_
    contrast_list = []
    for design_matrix in design_matrices:
        n_columns = design_matrix.shape[1]
        def pad_vector(contrast_, n_columns):
            return np.hstack((contrast_, np.zeros(n_columns - len(contrast_))))      
        contrasts = {'21-labial-BL': pad_vector([-1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0], n_columns),
                    '22-dental-BL': pad_vector([-1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0], n_columns),
                    '25-bilabial-dental': pad_vector([0,0,1,1,1,1,0,0,0,0,0,0,-1,-1,-1,-1,0,0], n_columns),
                    '26-dental-bilabial': pad_vector([0,0,-1,-1,-1,-1,0,0,0,0,0,0,1,1,1,1,0,0], n_columns)}
    ### Create stats_map for each contrast and each run
    for run_idx in range(len(design_matrices)):
        for contrast_key in contrast_list[run_idx].keys():
            run_contrasts = contrast_list[run_idx][contrast_key]
            stats_type = 'stat'
            stats_map = fmri_glm.compute_contrast(run_contrasts, output_type=stats_type)
            res_name = f'sub-{sID}_task-phono_'
            filename = res_name + f'desc-{contrast_key}-{run_idx + 1}_{stats_type}.nii.gz'
            print(filename) ## filename is correct with each defined condition
            stats_map.to_filename(os.path.join(outdir, filename))

A more specific question:
If I can print out 6 different design_matrices from fmri_glm.design_matrices_,
and iterate over each run_idx of design_matrices to create 6 stats_map per contrast with the same fmri_glm,
why the 6 stats_map of the same contrast would be the same computing from different 6 design_matrix?

Many thanks!

Sorry it got me so long to get to back to this one.

So you are always getting the same result because the compute_contrast method will compute the fixed effects map (i.e the average across runs) in the multi run case.

Check this example if you want to check each run separately.

1 Like

Bonjour Rémi,

No worries and thank you very much for the reply.
It was actually right before my meeting so it was great to get more suggestions.

I think that the concerns came from different visualization between SPM and Nilearn, in which the design matrices are usually presented as a big figure with all the runs in SPM, but separated into single runs in Nilearn.
I was wondering if fitting the univariate GLM separately for each run would introduce different confounds across the runs. (You might see my understanding here might not be clear enough.)
Since this step is for MVPA that the data will be flatten into patterns after for classification, so the slight confounds that might affect the activations seem not to be an issue for the later analysis anymore.

Many thanks,