Digitize EEG sensor locations and head shape using 3D scanners
Authors: Chinmay Chinara, Wayne Mead, Yash Shashanka Vakilna, Anand Joshi, Takfarinas Medani, Raymundo Cassani, John Mosher, Richard Leahy
This page describes the 3D scanner Digitize GUI for the updated version 2024.
For the legacy (previous) version, visit:
https://neuroimage.usc.edu/brainstorm/Tutorials/TutDigitize3dScannerLegacy
Contents
Background
This tutorial shows a fast, accurate and automated way of localizing and labeling EEG electrodes from a 3D model that was acquired using Revopoint Range 2, an affordable and advanced 3D scanner that uses structured light approach for mapping the scalp surface (with the EEG cap on).
The first part of the tutorial covers how to digitize the EEG electrodes from an available 3D model. The second part shows how to use the Revopoint Range 2 3D scanner to capture data.
Digitize using 3D scanner
Jump to Acquiring using 3D scanner section to generate your own data.
Example dataset
Description
This data consists of 3D model of a subject wearing a custom EEG cap ANT Waveguard 65 that was captured using the Revopoint Range 2 3D scanner by the steps mentioned in Acquiring using 3D scanner at The University of Texas Health Science Center at Houston, USA.
License
This tutorial dataset was obtained at the University of Texas Health Science Center at Houston, USA. It is made available under the Creative Commons Attribution-NonCommercial 4.0 International Public License. Any questions regarding the data, please contact: wayne.f.mead@uth.tmc.edu or yash.shashank.vakilna@uth.tmc.edu
Files
The example dataset can be downloaded from here. The files that will be imported in this tutorial are the following:
sub1_Waveguard_ANT_65/
sub1/sub1_mesh_tex.obj: The 3D model file.
sub1/sub1_mesh_tex.jpg: The texture file associated with the 3D model.
sub1/sub1_mesh_tex.mtl: The material file associated with the 3D model.
The 3D model has been defaced using MeshLab.
Loading the 3D model
If running from source code, we recommend having MATLAB R2018b or higher for best performance.
Create a new protocol called Tutorial_Digitizer.
Go to File>Digitize>3D scanner.
Enter the Subject ID in the pop-up window that opens up. Make sure that it is unique and does not match to any other subject in the same protocol. Name it sub1.
The subject gets created with the Default Anatomy.
From the Import surfaces... window, do the following:
File type: Wavefront OBJ (*.obj)
Choose sub1_mesh_tex.obj
Click Open.
Adjust the scale factor based on the prompt. This would bring the units of the vertices of the 3D model to the Brainstorm units m. For this example data, Brainstorm detected that the units were in mm so choosing 0.001 as the scaling factor would fix the units of the vertices.
The 3D model gets loaded into the protocol for the subject and the Digitize GUI opens up along with the model loaded. The Brainstorm GUI will be hidden during the use of the application and will reappear after exiting the Digitize GUI.
- This application allows you to collect:
- Three head localization coils (HPI) for computing the head coordinate system (optional)
- Three anatomical landmarks for Sensor-MRI co-registration
- EEG sensor locations
- Scalp points for head shape
When complete the coordinates can be saved in a variety of formats including CTF (*.pos), megDraw (*.eeg) or tab-delimited ASCII text.
Configure EEG cap point collection
Go to File>Edit Settings.... This opens up the 3DScanner configuration window.
List anatomy and possibly MEG fiducials in desired order: A comma separated list of all the anatomy and possibly MEG fiducials to be recorded. For this example, we will only be collecting the anatomy fiducials so we set it as NAS, LPA, RPA.
Number of times to collect the three fiducials: These collections will occur at the beginning of the session and will be averaged together to compute the transformation to the HPI or head coordinate system. For this example, we just need one set of fiducial so set it to 1.
Distance threshold (mm): It defines the threshold allowed between the respective anatomical fiducial points when there is repeated collection of them. For this example, since we are collecting just one round of fiducials, this is not used.
Beep: This will generate a beep sound with each point collection (this is often helpful to realize a click while collecting a point from the 3D model). For this example, we set it to 1.
Configure EEG montage
The next step is to configure EEG montage to select the cap layout we want to select. Brainstorm by default has a bunch of cap layouts already predefined. For this example, we use the ANT Waveguard 65 cap.
Go to EEG montage>Add EEG Montage...>Use default EEG cap>ICBM152>ANT>ANT Waveguard 65 to load the layout to the Coordinates section where the collected points will also be updated.
Collect the required number of anatomical fiducials
Click on the figure, and press Ctrl+P to activate collection mode (you will see the mouse cursor change to a crosshair). Click on the desired location on the 3D model and press key 'C' to collect the NAS, LPA and RPA fiducials in order. Refer the tutorial Coordinate Systems for more details on this. The change can be seen in the Coordinates section along each of the respective labels.
When collecting more than one set of fiducials, an error message is displayed if the difference between the sets is > 5mm
- If the MEG HPI coils are not used, then the head coordinate system is computed with the anatomical fiducials and the points are plotted on the 3D point display. Unless the user changes the anatomy for the Brainstorm Digitize subject, the default anatomy is used. It may not match exactly the subject being digitized, but should be a good quality control image to ensure the points are positioned where expected.
Note that the 3D figure is a standard Brainstorm window, where you can use all the mouse operations (rotation, zoom, popup menu) and the keyboard shortcuts (predefined view, screen capture...) introduced in the previous tutorials.
The coordinates are displayed in the coordinate list in cm
Once the fiducials are collected, the collection automatically moves to EEG positions
Collect EEG points
Make sure collection mode is active (crosshair visible as per Step-1 in the previous section Collect Anatomical Fiducials).
The coordinate list on the left shows the order in which the points should be collected. For this example data, we are going to collect points in the order Fpz, T7, T8, Oz,... all the way to AFz. Click on the desired location on the 3D model and press key 'C' to collect the point. Once collected, the GUI updates with the prompt label for the next point to be collected. The figures below (top to bottom) show the manual collection of few points Fpz, T7, T8, Oz.
While this is all good, manually marking all the electrodes can be pretty time consuming when done for dense caps like these. You can see that there is this button Auto which is a feature that enables users to automatically detect and label these electrodes. Currently, this is an experimental feature that only supports a few caps so make sure that you verify the results carefully.
The way it works is we need a minimal set of manual points as initialization that will help detect the rest of the electrodes. If your cap is supported then hovering on the Auto button should tell you the set of points that you need to manually collect. For this example, since this cap is supported, on hovering you see that you need to collect a minimum of Fpz, T7, T8, Oz for the button to be active.
If it is not supported you will see a tooltip as under.
Click on Auto to automatically detect the positions and labels for the sensors on the EEG cap. Click Yes on the disclaimer that pops up.
If the electrode detection does not work as expected with those initial marking of electrodes, try to manually set few more electrodes before pressing the Auto button.
Edit EEG points
If there are any bad detections or misalignments, you can manually select and press Delete key to delete these points from the Coordinates list and the figure (one at a time). Then in the point selection mode (press Ctrl+P while on the figure) click on the correct location on the 3D model and press key C to remark them manually which also updates in the Coordinates panel. Below you can see that FCz is misaligned and how it can be rectified.
Collect the desired number of head shape points
- In order to take full advantage of the Sensor-MRI co-registration algorithms in Brainstorm, it is recommended to collect approximately 100-150 points from the head: 5-10 points from the boney part of the nose, 10-15 points across the eyebrows, then an even coverage of the scalp from the eyebrows to the inion. It is NOT recommended to collect points below the inion on the neck, since the shape of the neck can change between lying in the MRI scanner and sitting during point collection. Even coverage is more important that dense coverage.
To automatically choose 150 random points, click on Random. These can be seen as the green points in the figure and the numbered 001-150 in the Coordinates list on the GUI.
If user wants to add head shape points manually, it can be done by clicking on the figure, and press Ctrl+P to activate collection mode. Click on the desired location on the 3D model and press key 'C' to collect. The points 151-155 in the figure below were collected manually.
- Each point is displayed on the 3D points display.
- The counter is incremented each time a point is collected and therefore indicates which point will to be collected next.
Save
- The user can save the points to a text file in a variety of formats.
The points can be saved as a *.pos file for import into CTF datasets or your Brainstorm database. Select Save as... and confirm the file name and location.
When exiting the program, select File > Save in database and exit to ensure the points are saved in the Brainstorm database.
View on scalp surface
Once saved, go to the functional tab, you can see the channel created under the subject name with all the electrodes assigned. Double click on it to see the electrodes on the default scalp (top row image below). Right click on the channel file, MRI Registration>Check to see how well the alignment is (bottom row image below). There will be some errors due to the scalp not matching the head shape of the subject.
To align it, right click on the channel file, MRI Registration>Refine using head points to align it to the default head shape. Refer to Automatic Registration for more details.
Acquiring using 3D scanner
The Hardware
Revopoint hardware package comes with the 3D scanner with tripod and a USB to USB-C cable. More details on the hardware can be found in their website.
System requirements
- Windows: Windows 10/11 (64-bit)
- RAM: 8 GB or better
- Processor: Intel Core i5 10th Generation or better
- Mac OS X: 10.7+
Prepare the EEG cap
The EEG cap can be made of shiny materials and these can lead to bad scanning. To reduce the effect of shine make sure to spray it with any commercially available dry shampoo before each subject scan.
Prepare the subject
- Make sure the subject has no glasses on. Since the scanning involves use of flashing white light, the reflections from the glasses could lead to bad scanning.
- Minimize structures floating over the cap such as additional wires or hair. If the cap has removable electrodes with exposed wires, scan the cap without electrodes attached. A stocking over the cap can be used if exposed wires cannot be removed.
- While the scanning is on, make sure the subject sits as steady as possible and has the eyes closed.
Revo Scan software
Revopoint uses the Revo Scan software to do the scanning of a subject wearing EEG cap and generate a 3D model. This model can then be imported into Brainstorm to detect and label the electrodes in it.
Installation
Download the software from their webpage based on your Operating System (OS).
Install it by keeping the defaults. After it has finished installing click on Complete.
Start new project
Connect the 3D scanner to your PC and launch the Revo Scan software. It will take few seconds to initialize and show Scanner Connected as under.
- If you are connecting it for the first time, it might ask for calibration of the device which is a very essential step. Calibrating a Revopoint 3D scanner resets its internal parameters to ensure accurate scanning data and alignment. Follow the onscreen steps and prompts to complete the calibration.
Click on New Project and give it a File Name and Location. Click New. Make sure to start a new project per subject.
This should now take you to the scanning window.
Pre-scanning setup (Scan Mode)
Depth Camera exposure (top left section): Use the plus/minus buttons behind the scanner to increase/decrease the exposure. Blue/Red artefacts in this window indicate under/over exposed camera. Use the buttons to adjust the exposure so that there are minimal/no artefacts. For e.g. in the scan below, the exposure of 1 was gave underexposed artefacts and increasing it to 2 gave good results. This exposure depends largely on the environment your scanning is done in and can vary from case to case.
Scan Settings (right section):
Accuracy: High Accuracy
Tracking Mode: Feature Tracking
Object Type: Body
Color Scanning: On
Base Removal: Default (90%)
Scanning Distance: ~ 400 mm to 900 mm
Get a good scanning distance: Pointing the camera to the subject, move close and away from them. You can see the range meter on the right just to the left of the Scan Settings going from Too Near to Too Far. You want to be in the Excellent range to get the best results. Note/mark this distance to help maintain a scanning range.
Scanning
From the marked position above, click on the Play button on the back of the Revopoint to start the scanning. Move the camera continuously with a steady hand, balance speed and stability to improve the quality of your scans. Most scans for the entire head can be accomplished in 30 seconds. The green color on the scanning mesh being generated indicate that the scan is going correctly and in Excellent range. If otherwise, then pause the scanning at that instant by pressing the Play button again. There are 2 things that can be done from here:
If you want to resume over the same scan, pressing Play again will resume the scan and automatically start aligning to the already generated scan. This is not recommended as the result might contain a lot of over scanning artefacts.
The other option is to click on Complete button and start a new scan and then later you can choose to merge multiple scans together. This is recommended as this reduces the creation of artefacts.
Processing
The different buttons available for processing the scanned mesh is shown below.
This section does not cover each and every button in details rather the ones that are a minimum requirement for cleaning and processing the scanned 3D model before it can be exported. More details for each of them can be found in the software's User Manual.
Fusion: This merges the raw point cloud mesh to a more unified and accurate point cloud model.
Fusion Method: Advanced
Point distance(mm): 1
Click on Apply
Clean the mesh using the clipping tool on the right to remove unwanted mesh area. We do not need any area other than the cap and face.
Isolation: This identifies and removes and floating or noisy points that are isolated from the main point cloud data to make it more clean.
Isolation Rate: 50%
Click on Apply
Overlap Detection: This is to remove any misalignments or overlapping data in the point cloud for a more accurate and consistent model.
Overlap distance(mm): 3
Click on Detect
Mesh: It converts the point cloud data to a solid 3D model.
Turn off the color by pressing the color icon on the top for better visualization of the meshing process
Quality: 5.8
Hole Filling(Auto): Turned off
Click on Apply
Simplify: This makes the 3D model more manageable for storage and processing. We do not require a very dense mesh for working with in Brainstorm so anything around 100000-200000 vertices would be sufficient.
Ratio: 50%
Click on Apply
Texture Mapping: Maps the texture to the 3D model
Turn on the color back by pressing the grayed out icon on the top
Texture: Color image
Click on Apply
Saving and exporting
Click on Export>Texture Model and save as .obj. This will save 3 files to the disk:
.obj: The 3D model file
.jpg: The texture file associated with the 3D model
.mtl: The material file associated with the 3D model
Walkthrough Video
Digitize using 3D scanner
Additional documentation
Related tutorials
Forum discussions
Articles
Simon Homölle, Robert Oostenveld
Using a structured-light 3D scanner to improve EEG source modeling with more accurate electrode positions.
Journal of Neuroscience Methods, Volume 326, October 2019.