Automatic localization of SEEG electrodes

Thanks for the prompt reply.
I'm struggling to automate localization of SEEG electrodes. I can go through manually and enter them, but it would help to have the software automatically localize the artifact and attempt to make SEEG contacts that I can then modify instead of individually going through post-implant CT and marking them manually.
#Anatomical_labelling section shows a way to use an atlas to automatically place SEEG electrodes, but the option does not appear on my subject channel file.
image

The recorded data I have channel file marks the type of recordings as EEG when in fact they are SEEG recordings. Does that make a difference? I am trying to avoid editing the channel file. I see if I make channel type SEEG it opens the options for iEEG atlas. In another test subject I tried to make a SEEG implant and manually entered locations of electrodes entry/target and then exported positions as .pol file, then I right click channel file then add electrode positions and import the .pol file. It had variable success. I once edited the SEEG implant by adjusting an electrdoe, then all the positions became removed outside of the skull in same reference to each other, but not in reference to CT or MRI.
For the channel file edited as SEEG type, I ran the options as in the tutorial. I save a tsv file, then right click channel file and click add electrode positions. The channel file also has the problem that the channels are grouped only as one group E. I can go through and edit the groups to reflect individual channels. Would that help? Or must I still go and manually select entry and target points for each electrode?

If I try to do SEEG implant as if to do manual localization of electrodes, then the SEEG channel file is empty with 0 contacts. I cannot right click it to try to get iEEG atlas to work.

Any help, much appreciated. I am trying to rely on the tutorials, but I'm stuck when it comes to applying to my own data. I was successful briefly for one trial raw recording to have electrodes displayed in Raw block001, but none of the other trials work

Thanks,

Cory Myers

I moved this post to a new thread.
Please create a new thread for each new question or bug report.

it would help to have the software automatically localize the artifact and attempt to make SEEG contacts that I can then modify instead of individually going through post-implant CT and marking them manually.

At this moment, Brainstorm doesn't include any solution for automated SEEG contact identification.
There are semi-automated methods available (e.g. GARDEL:presentation - WikiMEG) but we haven't tested them or integrated them with Brainstorm yet. This will be part of the developments of the next few years.

#Anatomical_labelling section shows a way to use an atlas to automatically place SEEG electrodes, but the option does not appear on my subject channel file.

There are no tools in Brainstorm to place SEEG electrodes automatically.
The sections "Anatomical labelling" in the SEEG and the ECOG tutorials explain how to export as a table the labels of the anatomical regions in which the existing SEEG contacts are located.

The recorded data I have channel file marks the type of recordings as EEG when in fact they are SEEG recordings. Does that make a difference?

Yes, you need to edit the channel file to change the type of the channels.
https://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy#Prepare_the_channel_file

In another test subject I tried to make a SEEG implant and manually entered locations of electrodes entry/target and then exported positions as .pol file, then I right click channel file then add electrode positions and import the .pol file.

This seems unnecessarily complicated.
Link your SEEG recordings to the database, edit the channel file to mark the channels as SEEG, then edit the positions as explained in the tutorials.

I once edited the SEEG implant by adjusting an electrdoe, then all the positions became removed outside of the skull in same reference to each other, but not in reference to CT or MRI.

I'm not sure I understand what this means.

The channel file also has the problem that the channels are grouped only as one group E. I can go through and edit the groups to reflect individual channels. Would that help?

Yes, edit the groups of the channels manually.
If the electrodes are all identified as part of the group "E", they all start with the letter "E".
The SEEG tools in Brainstorm will work only if your channels are labelled following the widely used conventions of having each SEEG shaft represented with a letter (e.g. "A") and the contacts along this shaft numbered from 1 to n, 1 being the deepest contact (e.g. A1, A2, ..., An).

Immediately after linking your recordings to the database: you can edit the channel file and rename the channels to match this convention.

Or must I still go and manually select entry and target points for each electrode?

You need to do both. Set the groups/names first, then define the position of the electrodes.

Thank you for the detailed response. I will try to keep it simple and edit channel file and MRI registratoin on the channel file, rather than a separate SEEG/ECOG registration then adding positions to channel file.

5 more questions as follow-up:

  1. I changed channel group as SEEG for all electrodes and I renamed all the electrode groups by letters ascending alphabetical order, but when I go to edit electrodes there is only 1 electrode letter E.

It appears I must change the name of the electrode to different letters for different electrodes.
You see in the screenshot, the electrodes are named ascending numeric order up to total number electrode contacts. I think I'm missing the point of the channel group. I can make groups by lobe or region I guess, but not sure how to easily focus on them.

  1. I'm using postop CT SPM reslice for MRI registration to set the electrode tip and entry points. Is it better to use MNI normalized SPM of postop CT?

  2. Is Cat12 or Brainsuite preferred for surface generation? Brainsuite takes longer and my computer overheated during processing, CAT12 is faster but the brain looks a little like knife-blade gyri of FTD even though patient only has moderate age-related atrophy.

  3. Is iEEG atlas labeling of contacts meant to "find" what tissue space the electrode is going through, gray matter vs white and also if a specific location based on parcellations?
    Besides the table format of the information, how else can it be visualized? Is there a way to analyze all the contacts that are in gray matter as a group for example? Or all that are in frontal lobe?

  4. Any suggestion for the workflow since there are about 15 patients that I'm interested to analyze and each has about 10-16 electrodes totaling 200+ contacts and 5 recording sessions that are about 5 min each. If I edit channel file for one recording of 5min duration and there are 4 other recordings, can I copy the electrode positions and names from the first modified file to the others to save time instead of manually entering letters and repeating the registration/target/entry of electrodes? Moreover there are events that are marked in succession as a single timepoint at time at start of event and then the event ends when the next event starts, but the block of time is not marked from what I can tell.

In the future I'm considering figuring out how to use mia to do group analysis of the different subjects recordings for trends of effects on SEEG signals from the events the amplifier generates/records. Seems like it may influence the answer to above questions.

Many thanks.

Pleast post the follow-up questions in the same thread as the original ones if they are about the same topic, and use public messages instead of private messages unless there are privacy issues with the data you need to share.

I changed channel group as SEEG for all electrodes and I renamed all the electrode groups by letters ascending alphabetical order, but when I go to edit electrodes there is only 1 electrode letter E.

Your screen capture shows that you didn't edit the channel names. With these channel names, indeed, it defines 1 SEEG shaft with 205 contacts on it.
Don't you have access to the implantation scheme of the neurosurgeon?
I guess they don't use these labels E001..E205 for the clinical evaluation.

Maybe something like:
E001 => A1 or A12
E002 => A2 or A11
E012 => A12 or A1
E013 => B1 or B16

When you open for display the channel file for the first time, Brainstorm parses the channel names and creates groups and intracranial electrodes automatically (IntraElectrodes in the channel file: https://neuroimage.usc.edu/brainstorm/Tutorials/Epileptogenicity#On_the_hard_drive).
If you later edit the channel names/types/groups, the IntraElectrodes doesn't get updated automatically. To force updating it: in the iEEG tab, delete ALL the electrodes in the list, close everything (big cross in the toolbar), save the changes, and open the channel file again. It would re-create the IntraElectrodes with the new information from the channel file.

If you are not comfortable with the manipulation of the channel files, I recommend you start by following step by step the three EEG/SEEG/ECOG tutorials using the example dataset before processing your own data:

I think I'm missing the point of the channel group

One channel group = one IntraElectrode created at the first time the channel file is loaded for display (or when there is no IntraElectrode defined, i.e. when it all the Electrodes has been deleted)

I'm using postop CT SPM reslice for MRI registration to set the electrode tip and entry points. Is it better to use MNI normalized SPM of postop CT?

Never use volumes normalized to MNI space when working with SEEG. Localize the electrodes only on volumes in the original patient space.

Is Cat12 or Brainsuite preferred for surface generation?

No formal comparison of the surfaces generated with the two programs has been published to my knowledge, therefore we can't give you any recommendation.
CAT12 is much faster, indeed.

Is iEEG atlas labeling of contacts meant to "find" what tissue space the electrode is going through, gray matter vs white and also if a specific location based on parcellations?

I think this is clearly documented in the tutorials, please let me know if you think some part of the documentation is not clear.
https://neuroimage.usc.edu/brainstorm/Tutorials/Epileptogenicity#Anatomical_labelling

For more information about this procedure, I recommend you refer to the section " 2. Electrode localization and anatomy" of this article:
https://www.sciencedirect.com/science/article/pii/S1053811922005559

Besides the table format of the information, how else can it be visualized?

The label of the current voxel in the selected atlas is displayed at the top-right corner in the MriViewer (but this is only one single voxel, not the most prevalent label in a sphere, as for the anatomic labelling menu).
https://neuroimage.usc.edu/brainstorm/Tutorials/ExploreAnatomy#Subcortical_regions:_Volume

Any suggestion for the workflow since there are about 15 patients that I'm interested to analyze and each has about 10-16 electrodes totaling 200+ contacts and 5 recording sessions that are about 5 min each

In the first place, you could use a file format that documents correctly the channel names, so that you don't have to edit all the channels files.

If I edit channel file for one recording of 5min duration and there are 4 other recordings, can I copy the electrode positions and names from the first modified file to the others to save time instead of manually entering letters and repeating the registration/target/entry of electrodes?

If the acquisition context and the order of the channels is exactly the same: yes, you can copy-paste the channel file from the first file to the others of the same patient.

Moreover there are events that are marked in succession as a single timepoint at time at start of event and then the event ends when the next event starts, but the block of time is not marked from what I can tell.

I'm not sure I understand what this means. If you need help with events management, please post a create a new thread and provide some more context.

In the future I'm considering figuring out how to use mia to do group analysis of the different subjects recordings for trends of effects on SEEG signals from the events the amplifier generates/records. Seems like it may influence the answer to above questions.

@as_dub Do you have any suggestions?

1 Like

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8695687/

Not sure if you came across this article, but is a matlab based GUI software that can localize leads. Any chance this will be added to brainstorm? Or can I use independently and still have registration with brainstorm?

Thanks for your responses above.

1 Like

No, I didn't try this new tool yet.
I added it to my read (and test) list for when I'll be back at working on SEEG:
https://neuroimage.usc.edu/brainstorm/Next#ECOG.2FSEEG

Have you tested it yourself?
I guess you should be able to use this program independently from Brainstorm and only import the SEEG location. Co-registration with the Brainstorm space might be tricky, but hopefully the program can export coordinates in MNI coordinates computed with SPM. If it saves everything in a big Matlab file, it might need some reformatting to a format that Brainstorm can interpret.
If you want to try it out, I'll probably be able to help you plug the coordinates back into Brainstorm.

An integration of the entire application directly into Brainstorm is most likely not going to be possible, just by seeing how the app is assembled. It is clearly not designed to be modular and can't co-exist with any other Matlab-based software, even SPM12 (as it is based on a modified version of SPM).
But hopefully the detection algorithm can be executed as low-level Matlab functions independently from the GUI. If this is the case, we could imagine reusing this in Brainstorm, at least to get a first estimate of the locations, that could be then edited in the Brainstorm MRI Viewer.
I'd need to dive deeper in the code to evaluate what would be possible.

Thanks for the suggestion!

I tried it briefly, but I was unable to load the executable version. I ran source code from Matlab to try on same file that my imaging data was accidentally deleted or lost from the epileptogenicity guideline.
I was able to get it to do its basic function of coregistering MRI and CT scans and to automatically identify electrodes, but the accuracy was not great for either. *The ability to slide CT overlaid on MRI for visualization was very helpful to see accuracy of coregistration. The CT was tilted compared to the MRI for coregistration and I was unable to find a way to adjust that simple sagittal plane tilt to improve overlap of cerebrums. I ignored the small imperfection there so I could get approximates of the electrode locations.

It's a good way to get a scaffold of 3d space for electrodes and would be helpful just for that function. The numbers of electrodes was incorrect so it missed a few for example a 16 contact electrode it only put 15 or 13. I could manually add electrodes easily. When it came to the step for editing contact labels in a table I got stuck and frustrated. It just wasn't working as described in the instructions. I hit ctrl+up arrow and it would autofill every cell in the table with NaN. It felt like a glitch. I gave up and went back to localizing in brainstorm. By the way, it kept my electrodes locations associated with the channel file for the SEEG recording, but the anatomy files were lost, so I re-imported the MRI and CT and made the surfaces with CAT12. When I went to look at the electrodes they shifted 3d location, but were in the same relative orientation and close to the original locations, so I was more easily able to re-do the electrode locations.

For clinical purposes I am using brainlab a proprietary software. That software allows automated coregistration of images, overlap viewing. It allows making objects based on houndsfield unit threshold windowing of CT scan. That's very helpful to easily locate electrodes. There's usually some extraneous areas of wires or bolts that get included, but they can be easily "erased" with eraser.
I may make a small request to add preset windows for contrast/brightness for CT to see brain tissue and to see bone window or metal. That would facilitate electrode localization.

Thanks for your responsiveness. You are better than any of the proprietary software customer service.

I forgot to mention it requires you to rename the dicom containing folder to "DICOM" or it won't work. I was able to copy paste both DICOM images of CT and MRI in same "DICOM" folder and that worked. Once the electrodes are created, it creates a folder called "registered" in the patient's imaging folder. I looked and the folder size is 6GB so I think there is some waste of file space to copy the images. I see the image files are .nii format and are the reason the folder has a large file size.

It just wasn't working as described in the instructions

For anything that is not working: open issues on their github repository.
User feedback will help them improve their software!

I may make a small request to add preset windows for contrast/brightness for CT to see brain tissue and to see bone window or metal. That would facilitate electrode localization.

At the moment, I'm using the same logic to display the MRI and the CT images. My heuristic to detect background and elements of interest works OK for most MRIs but not so well for CT scans... I'll put that on my todo list too.
Would you have suggestions on how to proceed?

Thanks for your responsiveness. You are better than any of the proprietary software customer service.

I'll quote you next time we ask money for the software support from the NIH :wink:
Thanks

Re preset CT windows, on most imaging platflorms it's just a button that presets to a specific houndsfield unit threshold to display. "W" "L" are the two numbers to adjust. Bone/ Brain are the two most useful options in my practice. ASPECTS score for strokes was set to W/L 40 brightness and 40 contrast to optimize detection of early ischemia as one way to make a preset brain window. Most preset brains are a little brighter to see other anatomy. My institution preset is W70/L30. My bone window is 2000W/ 500L. That allows easy visualization of the metal from electrodes usually, but if you want to window out the bone then you can see only metal artifact. So higher cutoffs at 2100 or so may make near automated detection of the electrodes. I also noticed using the 3d viewer in addition to the 3 plane "MRI viewer can be very helpful because I can right click and option to display MIPs and that really brings out the full length of the electrodes and better visual estimation of their trajectory and spatial relation against one another. The cutoff for houndsfield units as a sliding bar that allows darkening similar to right click and scroll is also helpful. Then users can see what direction they're moving in. I have trouble intuiting which direction on CT I'm going darker or brighter or higher or lower contrast partly also because of lag in display. I have played with using the digital number values and it is helpful, too.
Hope this makes sense and is helpful.

hi thanks for all your comment
I use Gardel to localize electrodes' contacts
I would like to add channel loalization to Brainstorm so I can use it in brainsuite
How can I do that ?
Here an example
MRIcentered.txt (9.0 KB)

@PapaZita33, you need to reformat the data in the localization file (MRIcentered.txt ) as a supported format, the more direct would be a .csv file with the electrode name, and X, Y, Z coordinates. For example the first row in the shared document would go from

H	1	16.1826032146042	-13.2080299808146	-28.1307368998786	2	white

to

H_1, 16.1826032146042, -13.2080299808146, -28.1307368998786
  • The header of the files needs to be removed as well

  • Note that electrode name must match the electrode name in Brainstorm

To import the locations Right-click on the channel file > Add EEG positions > Import from file. Then select format "**EEG: ASCII: NAME, XYZ_World (.), and when asked select the multiplier 1 as the coordinates are already in mm

Once imported, doublet-click on the channel file to see the updated positions.

1 Like