[FieldTrip] Electrode localization stl file

Stout, Megan stout at wustl.edu
Wed Dec 11 23:00:31 CET 2024


Hello Fieldtrippers!

*I am new to matlab so please excuse any ignorance!

I am using fieldtrip for electrode localization on a 3D scan, following the Localizing Electrodes Using a 3D Scanner<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.fieldtriptoolbox.org%2Ftutorial%2Felectrode%2F&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C82ce0d0ae0604044cfb308dd1a2f44e4%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638695512642644751%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C20000%7C%7C%7C&sdata=xjMX6%2BKZeZJnt5K9H9LJkfBkxDoXbG2Xd0zsQ%2BS9MOQ%3D&reserved=0> tutorial and I end up with a .fig file of the 3D head with the electrodes, but I need an .stl or .obj file. I used ft_write_headshape to convert to stl (which just uses matlab's stlwrite), but it will only convert the headshape mesh without the electrodes. I am not entirely sure of the issue, but I believe it may have something to do with the fact that the electrodes do not have their own triangulation (tri), just the pos, and both tri and pos are required for stlwrite in this case. I have attached the code below. Can anyone help me figure out how to get the headshape with electrodes converted into an stl or obj file?

Code for localizing electrodes (using tutorial above):

>> headshape = ft_read_headshape("C:\Users\stout\Downloads\testfile\testfile.obj")
>> headshape = ft_convert_units(headshape, 'mm');
>> ft_plot_headshape(headshape)

>> cfg = [];
cfg.method = 'interactive';
headshape = ft_meshrealign(cfg, headshape);
>> ft_plot_headshape(headshape, 'axes', true)

>> cfg = [];
cfg.method = 'headshape';
cfg.channel = {'nas', 'lpa', 'rpa'};
fiducials = ft_electrodeplacement(cfg, headshape);

>> cfg = [];
cfg.method        = 'fiducial';
cfg.coordsys      = 'ctf';
cfg.fiducial.nas  = fiducials.elecpos(1,:); %position of NAS
cfg.fiducial.lpa  = fiducials.elecpos(2,:); %position of LPA
cfg.fiducial.rpa  = fiducials.elecpos(3,:); %position of RPA
headshape = ft_meshrealign(cfg, headshape);

>> ft_plot_mesh(headshape, 'axes', true)
>> cfg = [];
cfg.method = 'headshape';
elec = ft_electrodeplacement(cfg, headshape);

>> ft_plot_headshape(headshape)
ft_plot_sens(elec, 'label', 'on', 'fontsize', 15, 'elecshape', 'disc', 'elecsize', 10)


%Subsequent code for converting to stl:

>> ft_write_headshape('testelec.stl', elec, 'format', 'stl')
Unrecognized field name "tri".

Error in ft_write_headshape (line 194)
    stlwrite(filename, mesh.tri, mesh.pos);
                       ^^^^^^^^

>> ft_write_headshape('test.stl', headshape, 'format', 'stl')
Wrote 939812 facets




Best,

Megan Stout
Clinical Research Assistant II
Department of Neurology
Washington University School of Medicine



________________________________
The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20241211/4f3ba2dc/attachment.htm>


More information about the fieldtrip mailing list