Atlas for 1 year old infants

I have electrode positions computed with MNE as fif objects. Are these importable in Brainstorm? I can send you these fif montage if you want.

Yes, please send me the .fif files with the electrodes positions, I'll try to make these available for download.

There are apparently issues with the ASEG atlas for 0.5m, 1m, 2m and 3m:

Could you please let me know what you should do with the bad ASEG segmentations? (see my message from Jul 8th)

Thanks

Hi @Francois

Can you check if the archive of .fif montage works for you? https://www.dropbox.com/s/d3xkxsmmbr6qxja/montage.tar.gz?dl=0

For the ASEG issues for the 0.5m, 1m, 2m, and 3m, it is probably safer to remove the ASEG from these templates then. I did not have time to go back at these templates to check what happened with the ASEG. My validation of these templates was done only for cortical sources. I think that most of the uses cases will also likely be concentrating on cortical sources. I'll check these more in details if someone needs ASEG for these ages. I'll follow the YAGNI principle here, unless you think these is currently a use case.

I can read the positions from the FIF files. Example script:

ChannelFile = 'C:\Work\Protocols\Test\data\Oreilly\1\channel_GSN_HydroCel_128_E1.mat';
ChannelMat = load(ChannelFile);
FifMat = import_channel(40, 'C:\Work\RawData\Test\Montages Oreilly\ANTS2-0Weeks3T_brain\GSN-HydroCel-129-montage.fif', 'FIF', 0, 0, 0);
for i = 1:length(ChannelMat.Channel)
    ChannelMat.Channel(i).Loc = FifMat.HeadPoints.Loc(:,i);
end
bst_save(ChannelFile, ChannelMat, 'v7');

The alignment is not far off but needs to be improved. I guess the 17 first digitized points include some fiducials, which would help a lot. Do you have the description of all the 146 points (or at least of the 17 first)?

You only have EGI Hydrocel caps?
No 10-10 or 10-20 schemes?

I found this that could let me create an approximate template that non-EGI users could use as well:

1 Like

@christianoreilly Any update on these last questions?

Hi @Francois. Sorry again for being so unresponsive on this issue. I just received the feedback from the NeuroImage journal about this paper, so I will be working at addressing various issues for the next month so it will be a good time for me to make some progresses on all these related issues while I have my hands in that code.

Regarding other nets, these templates are derived from the Neurodevelopmental database from Richards and al. and they published the same data for other nets (10-5, 10-10, 10-20) so it should not be complicated to add these to our templates. You can have a look at the preprint ( https://www.biorxiv.org/content/10.1101/2020.06.20.162131v1.full.pdf+html ) for a short description of how the electrode placement have been generated (section Sensor co-registration). However, as specified in the text, these are available only for the following time points: 3, 4.5, 6, 7.5, 9, 12, and 24 months. The other time points have been estimated by fitting the 3 or the 12-month placement to the corresponding heads and this was done by Jone Richards, not me. So I am not sure if he also has this for the other types of nets, but I can ask him.

Further, in the paper, I described how the brain surfaces have been extracted from a volumetric MRI average optimizing the alignment of brain structures, and the head surfaces have been extracted from a volumetric average optimizing the alignment of the head structures. The issue with that is that the head and brain surfaces ends-up not being co-registered, so I had to co-register them. One reviewer questioned this steps because it is manual so it is subjective, and I am also not fully satisfied by this process myself. I think it may introduces more distortion that it solves. So, I am considering going back and extract all the surfaces directly from the brain averages so that everything would be in a same space without such an additional co-registration... except for the electrode placement that I would need to "project" back from their position in the head averages to the scalp. Anyway, all this to say that I may need to rework these electrode placement files in the next few days or weeks. In any case, it should not drag too much since we have 30 days for the revision. I'll keep you informed.

Ok, thanks for the updates!
I'll wait until you're done before working any further on this then.
Good luck with the revision of the article.

Yes, it is certainly better like that.

For reference, regarding the ASEG missing region issues, does Brainstorm use something else than the aparc+aseg.mgz file to determine the available regions when importing FreeSurfer folders? In the new templates, the aparc+aseg.mgz files contain the following regions for all templates:

['Left-Cerebral-White-Matter',
 'Left-Cerebral-Cortex',
 'Left-Lateral-Ventricle',
 'Left-Cerebellum-Cortex',
 'Left-Thalamus',
 'Left-Caudate',
 'Left-Putamen',
 'Left-Pallidum',
 '3rd-Ventricle',
 '4th-Ventricle',
 'Left-Hippocampus',
 'Left-Amygdala',
 'Left-Accumbens-area',
 'Left-VentralDC',
 'Right-Cerebral-White-Matter',
 'Right-Cerebral-Cortex',
 'Right-Lateral-Ventricle',
 'Right-Cerebellum-Cortex',
 'Right-Thalamus',
 'Right-Caudate',
 'Right-Putamen',
 'Right-Pallidum',
 'Right-Hippocampus',
 'Right-Amygdala',
 'Right-Accumbens-area',
 'Right-VentralDC',
 'Vermis',
 'Midbrain',
 'Pons',
 'Medulla']

The following regions are available in all templates except the 0.5, 1, 2, 3 months templates:

['Left-Cerebellum-White-Matter',
 'Right-Cerebellum-White-Matter']

The following regions are available in all templates except the 0.5, 1, 2, 3, 4.5, 18, and 24 months templates:
['Optic-Chiasm']

So the issue you previously observed should be resolved. If you still observe missing regions (except those mentioned here) when you'll process the updated templates, please let me know.

To your question "Do you have the description of all the 146 points (or at least of the 17 first)?", the 17 first points where actually duplicating the Nasion, LPA, and RPA. This has been removed, leaving 14 points. These 14 points are:

  1. left preauricular point (LPA)
  2. nasion (Nz)
  3. right preauricular point (RPA)
  4. anterior commissure (AC)
  5. posterior commissure (PC)
  6. inion (Iz)
  7. left mastoid (LMA)
  8. right mastoid (RMA)
  9. left outer canthii for EOG (LEOG)
  10. right outer canthii for EOG (REOG)
  11. left EMG cheek (LEMG)
  12. right EMG check (REMG)
  13. mid EOG on nose
  14. vertex (Cz)

The other channels, are all EEG, numbered as you would expect for the corresponding montage.

You were also mentioning some inaccuracy for the position of the channels. These have now been projected to the closest point between their original position and the skin mesh.

Last time, I created the Brainstorm templates through the GUI. To improve reliability of this process, I will try to script it this time. Once I figured this out, the new templates should be ready and they should address the different concerns you had so far. Please let me know if I forget to address something.

Hi Christian,

This sounds good.
When you'll be done with the anatomy templates, I'll repackage them to add the template EEG positions. (and maybe try to figure out a solution for provide 10-10 positions as well?)

The list of the labels (ie. values of the volume) used to import the ASEG atlas in Brainstorm is defined here:

Thanks for the update
Francois

Yes, sorry, I forgot to mention, the modified templates include the electrodes for 5-10, 10-10, and 10-20.

I'll validate the ASEG labels.

Also, if you used code to add the EEG positions to the template previously, I can integrate the EEG positions directly if you want to share this code with me.

No, I haven't written code to import the template EEG positions yet.

I still need to think about how I will integrate the EEG positions. Possible options:

  1. downloaded together with the anatomy templates,
  2. downloaded separately
  3. distributed with the basic Brainstorm package (since the files are small).

If we go for solution 1, I could:

  • help you write code to import the positions from .fif files into the subjects of your Brainstorm database,
  • edit the function that creates the .zip anatomy templates to include (optionally) the channel files (and also the functions that download/deploy the templates in Brainstorm)

How does this sound?
What is your timeline? When would you need this to be ready?

Sounds good. I have some code that create the subjects and import their anatomy that seems to work:

% Create a protocol
ProtocolName='infant_templates';
gui_brainstorm('DeleteProtocol', ProtocolName);
% Create new protocol
gui_brainstorm('CreateProtocol', ProtocolName, 0, 0);

study   = bst_get('Study');
ProtocolSubjects = bst_get('ProtocolSubjects');   
ProtocolInfo = bst_get('ProtocolInfo');

fid_dict = load('/home/christian/brainstorm_db/fiducials.mat');
files = dir("/usr/local/freesurfer/subjects/ANTS*3T");

for noSubject=1:size(files, 1)
    
    subjectName = files(noSubject).name;
    
    nbSubjects = length(ProtocolSubjects.Subject);
    iSubject = noSubject; %nbSubjects + 1;
    sSubject = db_template('Subject');
    sSubject.Name     = subjectName;
    sSubject.FileName = bst_fullfile(subjectName, 'brainstormsubject.mat');
    % Get subjects defaults from protocol
    sSubject.UseDefaultAnat    = ProtocolInfo.UseDefaultAnat;
    sSubject.UseDefaultChannel = ProtocolInfo.UseDefaultChannel;    
    
    sSubject = db_add_subject(sSubject, iSubject);
   
    FsDir = [files(noSubject).folder '/' files(noSubject).name];    
    [BstMriFile, sMri] = import_mri(noSubject, [FsDir '/mri/T1.mgz']);
    
    fiducials_world = getfield(fid_dict, strrep(strrep(subjectName,'ANTS','s'), '-', '_'));
    fiducials_mri = cs_convert(sMri, 'world', 'mri', fiducials_world ./ 1000) .* 1000;
    
	sFid = struct('NAS', fiducials_mri(1, :), ...
                  'LPA', fiducials_mri(2, :), ...
                  'RPA', fiducials_mri(3, :), ...
                  'AC',  fiducials_mri(4, :), ...
                  'PC',  fiducials_mri(5, :), ...
                  'IH',  fiducials_mri(6, :));  

    import_anatomy_fs(iSubject, FsDir, 15000, 0, sFid);
    
    bst_memory('UnloadAll', 'Forced');
    db_reload_subjects(iSubject);
    panel_protocols('UpdateTree');
    db_save();    

end

It generates a bunch of empty BST> ERROR: message though:

Warning: Inputs must be character vectors, cell arrays of character vectors, or string arrays. 
> In import_anatomy_fs (line 321)
  In import_template_to_brainstorm (line 43)
 
BST> ERROR: 

The warning is due to the fact that in the code at line 321 disp(['BST> ERROR: ' strrep(err(1:end-1), char(10), [10 'BST> ERROR: '])]) the variable err is equal to []. I get the same message for line 300, 342, and 362. I am not sure if these really errors...

Also, for some reason export_default_anat(iSubject, subjectName) crashes.

Index exceeds the number of array elements (0).

Error in bst_get (line 2309)
        sTemplates = sTemplates([1, I+1]);

Error in export_default_anat (line 42)
if ~isempty(bst_get('AnatomyDefaults', DefaultName))

Error in import_template_to_brainstorm (line 50)
    export_default_anat(iSubject, subjectName);

The reason why the ASEG is not imported correctly by Brainstorm is also still a mystery. The ASEG file seems fine to me, e.g.:

Labels seems to match.

I don't have any deadline for that. It is OK if this is not wrapped up for the submission of the revised manuscript.

It generates a bunch of empty BST> ERROR: message though:

Sorry, I introduced this a few days ago. I fixed it in this commit:
Bugfix: FreeSurfer import: Read all the .annot in /label folder · brainstorm-tools/brainstorm3@5370198 · GitHub

I also added some code so that the channel files are packaged together with the anatomy templates, and deployed when using the templates:
Anatomy templates: Include EEG channel files · brainstorm-tools/brainstorm3@0e535ff · GitHub

I have some code that create the subjects and import their anatomy that seems to work

Your script looks good.
You could add a few lines to import the channel files (you'd need to fix the indices 17=>14, and check the registration MRI-EEG):

% Create folder for channel file
SubjectName = 'Oreilly_0.5m';
FolderName = file_standardize(str_remove_parenth(RefChannelMat.Comment));
iStudy = db_add_condition(SubjectName, FolderName);
sStudy = bst_get('Study', iStudy);
% Read channel file
FifMat = import_channel([], 'C:\Work\RawData\Test\Montages Oreilly\ANTS2-0Weeks3T_brain\GSN-HydroCel-129-montage.fif', 'FIF', 0, 0, 0);

% Create destination channel file
ChannelMat = RefChannelMat;
ChannelMat.SCS.NAS = FifMat.HeadPoints.Loc(:,2);
ChannelMat.SCS.LPA = FifMat.HeadPoints.Loc(:,1);
ChannelMat.SCS.RPA = FifMat.HeadPoints.Loc(:,3);
for i = 1:length(ChannelMat.Channel)
    ChannelMat.Channel(i).Loc = FifMat.HeadPoints.Loc(:,i+17);
end
ChannelMat.HeadPoints = FifMat.HeadPoints;

% Save channel file
ChannelFile = bst_fullfile(bst_fileparts(file_fullpath(sStudy.FileName)), RefChannelFile);
bst_save(ChannelFile, ChannelMat, 'v7');
db_reload_studies(iStudy);

Also, for some reason export_default_anat(iSubject, subjectName) crashes.

Fixed.

The reason why the ASEG is not imported correctly by Brainstorm is also still a mystery. The ASEG file seems fine to me, e.g.:

Could you share an example FreeSurfer folder that is not importing correctly?

All the fixes to work fine!

The created templates seem to be misplaced in the submenus. When I tried it, the templates created by the script were shown in the MNI submenu. I also tried to create a template through the GUI and this template got placed in the USC submenu. It does not have consequences for what I have to do, but I thought you may want to know about this issue.

I tried to integrated your code for the channel files. I managed make it save the imported file, but it does not add the channel to the study, probably because I did not use the RefChannelMat object you used in your code. How do your get that object/structure? Here is what I got so far:

montages = {'10-5', '10-10', '10-20', 'HGSN128'};
iStudy = db_add_condition(subjectName, 'test');
sStudy = bst_get('Study', iStudy);    

% Create folder for channel file
for no_montage = 1:length(montages)
    montage = [montages{no_montage} '-montage.fif'];
    RefChannelMat = db_template('channelmat');

    % Read channel file
    FifMat = import_channel([], [FsDir '/' montage], 'FIF', 0, 0, 0);

    % Create destination channel file
    ChannelMat = RefChannelMat;
    ChannelMat.SCS.NAS = FifMat.HeadPoints.Loc(:,2);
    ChannelMat.SCS.LPA = FifMat.HeadPoints.Loc(:,1);
    ChannelMat.SCS.RPA = FifMat.HeadPoints.Loc(:,3);
    for i = 15:size(FifMat.HeadPoints.Loc, 2)
        ChannelMat.Channel(i-14).Loc = FifMat.HeadPoints.Loc(:,i);
    end
    ChannelMat.HeadPoints = FifMat.HeadPoints;

    % Save channel file
    ChannelFile = bst_fullfile(bst_fileparts(file_fullpath(sStudy.FileName)), montages{no_montage});
    bst_save(ChannelFile, ChannelMat, 'v7');
end

db_reload_studies(iStudy);  

Here are FreeSurfer for the ASEG issue:

When I tried it, the templates created by the script were shown in the MNI submenu. I also tried to create a template through the GUI and this template got placed in the USC submenu. It does not have consequences for what I have to do, but I thought you may want to know about this issue.

I probably didn't tell you this explicitly: the subjects must be named Oreilly_XXm.
The classification in submenus is only dependent on the name of the subject (= the name of the .zip file).
brainstorm3/toolbox/tree/tree_callbacks.m at master · brainstorm-tools/brainstorm3 · GitHub

probably because I did not use the RefChannelMat object you used in your code. How do your get that object/structure?

This is an existing structure to which you add the modified locations (possibly after changing the order based on the labels). You can simply load any of the default EEG cap in Brainstorm, and use this as you "RefChannelMat".

The import code was making wrong assumptions for the ASEG volumes where the label 7 was missing (white cerebellum). I removed this test, and now it reads everything as if it were coming from FreeSurfer >= 5.

Maybe I'm breaking the import of ASEG atlases processed before 2009, but I could not find any old enough example dataset to try making something smarter...

Can you try again importing the folders with this fix?

Hi

How can I put the Squid sensors to this subjects?

Thanks

@abdallahqusaibe
The MEG sensors positions are defined in the MEG recordings.
The procedures to register these 3D positions with the anatomical information already imported in Brainstorm are described in the introduction tutorials:
https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile#Additional_documentation

Thank you Francois, do you have subject for 10 years old ?

it is correct to exported the meg squid (extracted from vecterview example in bst ) exported to matlab and imported again with this new subject

if yes, as you see below the helmet a little bit flipping o the left

but yes thanks to the edit we can corret it

but fro the back ot seems the distance between sensor and scalp is big,

another question
image
image
despite that we have different type of sensor the display sensors have not the othe options
what should be the problem?

1 Like