[FieldTrip] 3D Scan Data - texture size error

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Tue Jul 7 14:40:55 CEST 2020


Hi Rainer,

Thanks for sending the data. I looked into this a bit more thoroughly, and my verdict is the following:

The current code in FieldTrip that deals with wavefront object files makes some strong assumptions about the exact content of the obj-file.
Specifically, it seems that the texture_mapping (i.e. assigning a color to the objects) assumes each vertex to be assigned a texture, and (implicitly) that all of the vertices in the described object are assigned to a (triangular) face.
The obj-fileformat is much more generic, in that it among others can contain multiple vertices that do not belong to a faces, and the ’texture vertices’ (i.e. the coordinates that map into the image file) are of an arbitrary size.

Also, the current code only specifically looks for a .jpg as accompanying image file, but it seems that it should look for an image file that has been specified in the corresponding *.mtl (which can of course also be a *.png).

After some fooling around, I have made an update to the ft_read_headshape function (and some other relevant functions), so that it now can read your model without error (using the*.png etc).

I have pushed this to the master branch on the github-repository of fieldtrip (https://github.com/fieldtrip/fieldtrip). You can grab the code from there if you’d like to try it out. Alternatively, once our overnight batch of test functions runs through without errors, the updated code will be available in the newest release of the fieldtrip code (i.e. on the release branch of said repository, as well as in the latest release package).

Best wishes,
Jan-Mathijs


PS: the data you sent to me looks like this if loaded in into FieldTrip + visualised with ft_plot_mesh

[cid:5FFDDD23-6C60-4F4E-B8B5-94BD36960B0C at home]

On 6 Jul 2020, at 13:17, Rainer Scharf <rainer.scharf at student.tugraz.at<mailto:rainer.scharf at student.tugraz.at>> wrote:

Hi  Jan,

Thanks so much for your reply!
Thats really seems to be the case. I inspected the object file closely and found the miss-match.

The list of geometric vertices (v) has not the same amount as the texture coordinates (vt)
I tried different scans and different export options, it has an effect on it but it is never matching.
Other programs like Cinema 4D can open it easily (so I assume the file is not corrupted).

By a bit research I found that v and vt seems do not necessarily need to match in general.

In the following link you can find my scan. Skanect is exporting the files exactly like that.
As mentioned before, Skanect is providing .png instead of .jpg

https://www.dropbox.com/sh/9pnjpq5wofs2h7i/AABieWNZhPstKlDE8m3OFX0ia?dl=0

Best
Rainer


Am 06.07.2020 um 09:31 schrieb Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>:

Hi Rainer,

The error message suggests that there’s an unexpected (at least by Fieldtrip) mismatch between the ’texture’ specification in the .obj file, as compared to the number of points that are in the same .obj file.  That is, there’s a mismatch between the variables that are outputted by the function read_obj_new (in fieldtrip/fileio/private). Assuming that the implementation of this referenced function is correct (i.e. that it reads the file correctly), it suggests that your obj-file either is corrupt, or that it has been formatted in a way that is not anticipated by the reading function.

Could you confirm the mismatch by setting a breakpoint in ft_read_headshape and compare the number of returned texture points in relation to the number of point points?

Would it be possible to share the combined (obj/jpg/mtl) files so that we can have a look?

Best wishes,
JM

On 5 Jul 2020, at 12:37, Rainer Scharf <rainer.scharf at student.tugraz.at<mailto:rainer.scharf at student.tugraz.at>> wrote:

Dear Community,

I’m trying to localize electrodes using a 3D Scanner according to the 3dscanner tutorial.
Everything works for the scan provided in the tutorial.

I use the Skanect Occipital Structure sensor (for computer) not the one for the iPad as shown in the tutorial.

After exporting the data from Skanect I get an OBJ- ,PNG- and MTL-File.
(The fieldtrip code is expecting a jpg-file)

I converted the png file to jpg and also tried to let Matlab use the png-file directly, but it seems to me the texture is not matching with the structure information as the code expects it.
(Other programs like cinema 4D are matching it without any problems.)

When I run the code I get an error in the refine - function:
Error using refine (line 72)
invalid size of texture

I’m using fieldtrip-20200607

Thanks in advances for your advices and support,

All the Best
Rainer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200707/df603831/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2020-07-07 at 14.39.52.png
Type: image/png
Size: 309201 bytes
Desc: Screenshot 2020-07-07 at 14.39.52.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200707/df603831/attachment-0001.png>


More information about the fieldtrip mailing list