<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">Hi Rainer,</span>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Thanks for sending the data. I looked into this a bit more thoroughly, and my verdict is the following:</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">The current code in FieldTrip that deals with wavefront object files makes some strong assumptions about the exact content of the obj-file.</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">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.</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">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.</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">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).</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">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).</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">I have pushed this to the master branch on the github-repository of fieldtrip (<a href="https://github.com/fieldtrip/fieldtrip" class="">https://github.com/fieldtrip/fieldtrip</a>). 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). </div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class="">
</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Best wishes,</div>
<div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div><br class="">
</div>
<div>PS: the data you sent to me looks like this if loaded in into FieldTrip + visualised with ft_plot_mesh</div>
<div><br class="">
</div>
<div><img apple-inline="yes" id="5FF54B8A-A262-46D3-A544-1EC80790B933" width="560" height="496" src="cid:5FFDDD23-6C60-4F4E-B8B5-94BD36960B0C@home" class=""></div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 6 Jul 2020, at 13:17, Rainer Scharf <<a href="mailto:rainer.scharf@student.tugraz.at" class="">rainer.scharf@student.tugraz.at</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi  Jan,
<div class=""><br class="">
</div>
<div class="">Thanks so much for your reply!</div>
<div class="">Thats really seems to be the case. I inspected the object file closely and found the miss-match.</div>
<div class=""><br class="">
</div>
<div class="">The list of geometric vertices (v) has not the same amount as the texture coordinates (vt)</div>
<div class="">I tried different scans and different export options, it has an effect on it but it is never matching. </div>
<div class="">Other programs like Cinema 4D can open it easily (so I assume the file is not corrupted).</div>
<div class=""><br class="">
</div>
<div class="">By a bit research I found that v and vt seems do not necessarily need to match in general.</div>
<div class=""><br class="">
</div>
<div class="">In the following link you can find my scan. Skanect is exporting the files exactly like that.</div>
<div class="">As mentioned before, Skanect is providing .png instead of .jpg</div>
<div class=""><br class="">
</div>
<div class=""><a href="https://www.dropbox.com/sh/9pnjpq5wofs2h7i/AABieWNZhPstKlDE8m3OFX0ia?dl=0" class="">https://www.dropbox.com/sh/9pnjpq5wofs2h7i/AABieWNZhPstKlDE8m3OFX0ia?dl=0</a></div>
<div class=""><br class="">
</div>
<div class="">Best</div>
<div class="">Rainer</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">Am 06.07.2020 um 09:31 schrieb Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl" class="">jan.schoffelen@donders.ru.nl</a>>:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<font size="4" class="">Hi Rainer,</font>
<div class=""><font size="4" class=""><br class="">
</font></div>
<div class=""><font size="4" class="">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). </font><span style="font-size: large;" class="">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. </span></div>
<div class=""><span style="font-size: large;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: large;" class="">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?</span></div>
<div class=""><span style="font-size: large;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: large;" class="">Would it be possible to share the combined (obj/jpg/mtl) files so that we can have a look?</span></div>
<div class=""><span style="font-size: large;" class=""><br class="">
</span></div>
<div class=""><span style="font-size: large;" class="">Best wishes,</span></div>
<div class=""><span style="font-size: large;" class="">JM</span></div>
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 5 Jul 2020, at 12:37, Rainer Scharf <<a href="mailto:rainer.scharf@student.tugraz.at" class="">rainer.scharf@student.tugraz.at</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear Community,
<div class=""><br class="">
</div>
<div class="">I’m trying to localize electrodes using a 3D Scanner according to the 3dscanner tutorial.</div>
<div class="">Everything works for the scan provided in the tutorial.</div>
<div class=""><br class="">
</div>
<div class="">I use the Skanect Occipital Structure sensor (for computer) not the one for the iPad as shown in the tutorial.</div>
<div class=""><br class="">
</div>
<div class="">After exporting the data from Skanect I get an OBJ- ,PNG- and MTL-File.</div>
<div class="">(The fieldtrip code is expecting a jpg-file)</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class="">(Other programs like cinema 4D are matching it without any problems.)</div>
<div class=""><br class="">
</div>
<div class="">When I run the code I get an error in the <b class="">refine</b> - function:</div>
<div class="">
<div class=""><font color="#ff2600" class="">Error using refine (line 72)</font></div>
<div class=""><font color="#ff2600" class="">invalid size of texture</font></div>
</div>
<div class=""><br class="">
</div>
<div class="">I’m using fieldtrip-20200607 </div>
<div class=""><br class="">
</div>
<div class="">Thanks in advances for your advices and support,</div>
<div class=""><br class="">
</div>
<div class="">All the Best </div>
<div class="">Rainer</div>
<div class=""><br class="">
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</body>
</html>