Nilearn Firstlevelmodel: SPM + derivative + dispersion

Dear Neurostars,

I’m trying to set up a firstlevel model with the hrf_model parameter set to spm + derivative + dispersion. When plotting the resulting zmaps the brain are empty and all values are zero. When I run the same firstlevelmodel with he hrf_model parameter set to just spm or spm + derivative this is not the case.

Does anyone know what may explain this finding?


for sub in subs[:1]:
    print('---------- '+sub+' ----------')

    sub_new = sub[0] + sub[-2:]
    design_matrices=[]
    fmri_img=[]
    for run in  [1]:
        
        print(f'### run: {run} ###')
        run_new = 'RUN'+str(run).zfill(2)
        
        func_data_dir = opj(prep_dir, sub_new)       
        onset_dir = opj(base_dir,'data/bids/',sub,'func')
        confound_dir = opj(base_dir,'data/bids/derivatives/fmriprep',sub,'func' )


        func1_path = glob(opj(func_data_dir, f'w*{run_new}*topup.nii.gz'))[0]
        func1_img = load_img(func1_path)
        n_frames=func1_img.shape[3]
        frame_times = np.arange(n_frames) * tr

        # onest file 
        events = pd.read_csv(glob(opj(onset_dir,'*'+sub[-2:]+'*run-'+str(run).zfill(2)+'*_onsets_svo_BPdep_woBO.tsv'))[0], sep = '\t')
        events['trial_type'] = events['trial_type'].replace('-', '', regex=True)
        
        events.drop(['Unnamed: 0'],axis=1, inplace=True)
        
        confounds = pd.read_table(glob(opj(confound_dir,sub+'*run-'+str(run)+'*confounds_timeseries.tsv'))[0])
        confounds_sel = confounds[['rot_x','rot_y','rot_z',
        'trans_x','trans_y','trans_z']].fillna(0)

        # create design matrix 
        dm_ms = make_first_level_design_matrix(
            frame_times,
            events,
            add_regs=confounds_sel,
            add_reg_names=list(confounds_sel.columns),
            hrf_model='spm + derivative + dispersion,
            drift_model='polynomial',
            drift_order=3,     
        )
        
        plot_design_matrix(dm_ms)
        plt.show()
        design_matrices.append(dm_ms)
        fmri_img.append(func1_img)
        
    print('Length of img check' + str(len(fmri_img)))
    print('Length of design_matrices check' + str(len(design_matrices)))

    fmri_glm = FirstLevelModel(minimize_memory=True, standardize=False, smoothing_fwhm=5)#, signal_scaling=False)
    fmri_glm = fmri_glm.fit(fmri_img, design_matrices=design_matrices) # might have to turn off signal scaling because data might be centered

    trialwise_conditions = events['trial_type'].unique()

    for condition in trialwise_conditions:
        print(condition)
        
        # V1
        z_map = fmri_glm.compute_contrast(condition, output_type='z_score')
        plot_glass_brain(z_map)
        plt.show()```
type or paste code here

Thx for reporting. Can you share the event file ?

sub-003_task-MentalStates_run-01_onsets_svo_BPdep_woBO.txt (3.4 KB)

Does anyone have any advice for a solution to this?