[FieldTrip] Electrode localization stl file

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Thu Dec 12 08:48:58 CET 2024


Dear Megan,

Could you elaborate on your expectations/the requirement that the electrodes can be saved into an *.stl file? Is there external software that needs electrodes in in stl format?

Practically, ft_write_headshape is typically used to write a headshape mesh into a file, where indeed the expectation is that the object to-be-written (at least when the requested dataformat is .stl) contains both a set of points/vertices, and a description of a surface (triangles). The electrode definition is an object that indeed only contains points, and no triangles.

Best wishes,
Jan-Mathijs






On 11 Dec 2024, at 23:00, Stout, Megan via fieldtrip <fieldtrip at science.ru.nl> wrote:

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%7C1a78c37a74e64a5226c208dd1a817016%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638695865404904139%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=aO4zgnZdkl7Bgji4jce0xKiTgam3kmca97phsr370XE%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.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C1a78c37a74e64a5226c208dd1a817016%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638695865404935964%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=jzRRHQgZ2mXHi7BZM1kEqRZfike1mc07VZ89cISY%2BbI%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C1a78c37a74e64a5226c208dd1a817016%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638695865404960690%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=YT%2FjLJ4S3Tn%2F6ggwixhA0NN%2FSV10x7xa2gizdFWUycA%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20241212/17a5923f/attachment.htm>


More information about the fieldtrip mailing list