MNE-bids: 'head' coordinate frame must contain nasion and left and right pre-auricular point landmarks

Hi experts,

I have trying to bidsfy my eeg data using mne-bids following the tutorial on the mne website, and got the following error:

  'head' coordinate frame must contain nasion and left and right pre-auricular point landmarks
   
   File "/Users/ebigayle/Desktop/EEG_PLS_Test/Codes /eeg2bids", line 65, in <module>
   write_raw_bids(raw, bids_path, overwrite=True)

This is the code I ran:

  home_dir = "/Users/ebigayle/Desktop/EEG_PLS_Test"
  data_dir = "EEG_raw/data_raw"
  data_path = os.path.join(home_dir, data_dir)
  output_dir = "EEG_raw/data_renamed"
  output_path = os.path.join(home_dir, output_dir)
  num_task_runs = 4
  num_rest_runs = 2
  sub_ids = ["001", "002"]
  ses_id = ["01"]

  #%%
  os.chdir(home_dir)
  bids_root = os.path.join(home_dir, output_dir)
  
  raw_list = list()
  bids_list = list()
  
  for sub_id in sub_ids:
  
      sub_folder = os.path.join(data_path, f"sub-{sub_id}")
      print(f"\n Processing: sub_id {sub_id} in {sub_folder} \n")
  
      ses_folder = os.path.join(sub_folder, f"ses-{ses_id[0]}")
      print(f"\n Processing: session {ses_id} in directory: {ses_folder} \n")
  
      eeg_folder = os.path.join(ses_folder, "eeg")
  
      for run_id in range(1, num_task_runs + 1):
  
          task_name = f"PSRTT{run_id}"
  
          eeg_file = glob.glob(eeg_folder + "/*" + task_name + "*.vhdr")
          print(f"\n Reading EEG file at : {eeg_file[0]} \n")
  
          raw = mne.io.read_raw_brainvision(
              eeg_file[0],
              preload=False,
              eog=("LHEOG", "TVEOG", "RHEOG", "BVEOG"),
              misc=["Photosensor"],
          )
          raw_list.append(raw)
          bids_path = BIDSPath(
              subject=sub_id, session=ses_id[0], task=task_name, root=bids_root,
          )
          bids_list.append(bids_path)
  
  for raw, bids_path in zip(raw_list, bids_list):
      write_raw_bids(raw, bids_path, overwrite=True)

And the code failed at the last line, write_raw bids.

This is the directory tree for my input folder:

   Processing: session ses-1 in directory: /Users/ebigayle/Desktop/EEG_PLS_Test/EEG_raw/data_raw/sub-002/ses-1
  |ses-1/
  
  |--- .DS_Store
  
  |--- behavioral/
  
  |------ .DS_Store
  
  |------ sub-002_ses-1_2908221901_Actual_Run1.txt
  
  |------ sub-002_ses-1_2908221906_Actual_Run2.txt
  
  |------ sub-002_ses-1_2908221911_Actual_Run3.txt
  
  |------ sub-002_ses-1_2908221917_Actual_Run4.txt
  
  |--- eeg/
  
  |------ .DS_Store
  
  |------ EEG_EXP1.eeg
  
  |------ EEG_EXP1.vhdr
  
  |------ EEG_EXP1.vmrk
  
  |------ EEG_EXP2.eeg
  
  |------ EEG_EXP2.vhdr
  
  |------ EEG_EXP2.vmrk
  
  |------ PSRTT1.eeg
  
  |------ PSRTT1.vhdr
  
  |------ PSRTT1.vmrk
  
  |------ PSRTT2.eeg
  
  |------ PSRTT2.vhdr
  
  |------ PSRTT2.vmrk
  
  |------ PSRTT3.eeg
  
  |------ PSRTT3.vhdr
  
  |------ PSRTT3.vmrk
  
  |------ PSRTT4.eeg
  
  |------ PSRTT4.vhdr
  
  |------ PSRTT4.vmrk
  
  |------ .ipynb_checkpoints/
  
  |--------- EEG_processing_Test-checkpoint.ipynb
  
  |--- phyiso/
  
  |------ EEG_EXP1.edf
  
  |------ EEG_EXP1.h5
  
  |------ EEG_EXP1.txt
  
  |------ EEG_EXP2.edf
  
  |------ EEG_EXP2.h5
  
  |------ EEG_EXP2.txt
  
  |------ PSRTT1.edf
  
  |------ PSRTT1.h5
  
  |------ PSRTT1.txt
  
  |------ PSRTT2.edf
  
  |------ PSRTT2.h5
  
  |------ PSRTT2.txt
  
  |------ PSRTT3.edf
  
  |------ PSRTT3.h5
  
  |------ PSRTT3.txt
  
  |------ PSRTT4.edf
  
  |------ PSRTT4.h5
  
  |------ PSRTT4.txt

and after running the script I realised that the bids directory for the first subject has been updated to the following:
Screenshot 2022-09-09 at 3.12.18 PM

thank you for your help and attention!

Regards,
Vae

I have figured it out!

I needed to set the montage for the dataset! I am using acti-champ, so i have selected the easycap-M1 for different systems different caps must be selected.

set montage for channels.tsv

    montage = mne.channels.make_standard_montage("easycap-M1", head_size="auto")
    raw.set_montage(montage)

Hope this helps!