Error in brain.add_sensors

Hi MNE community,

I’m working with sEEG data and aiming to visualize the localization of sEEG shafts on the individual’s brain. I was using the script below, which used to work fine, but it suddenly stopped working.

  • MNE version: 1.9.0
  • operating system: Windows 11
# Estimate head -> mri transform
    subj_trans = mne.coreg.estimate_head_mri_t('sub'+ListSuj[suj], dirFreeSurfer)   
    trans_filename = dirData+'subject'+ListSuj[suj]+'/subject'+ListSuj[suj]+'_trans.fif'
    mne.write_trans(trans_filename, subj_trans)
    # Load sEEG Data
    sEEG_File = dirData+'subject'+ListSuj[suj]+'/subject'+ListSuj[suj]+'_order1.fif'
    sEEG_Data = mne.io.read_raw(sEEG_File, preload=True)   
    # Plot
    brain =  mne.viz.Brain('sub'+ListSuj[suj], hemi='both', surf='pial', subjects_dir=dirFreeSurfer)
    # Add elec
    brain.add_sensors(sEEG_Data.info, trans=trans_filename, seeg=True)

The error (below) seems to come from the trans argument. And is weird because I indeed give a str…

TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'Transform'

Any help is welcome :slight_smile:

Camille

Funny error indeed. :thinking: Did you try to just pass subj_trans directly? That should work, too: mne.viz.Brain — MNE 1.10.0 documentation

I also advise to look into: