-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot resample very high-res surfaces (due to encoding of written GIFTI files) #34
Comments
Thank you Steven, this is very helpful! You mentioned that you have sphere files in the same resolution as the surface, Part of the problem seems to be that the Connectome Workbench command "-surface-resample", which ciftiTools depends on, does not generate surfaces with the same resolution as this surface. For example, resampling a default surface at a requested resolution of 158681 yields a surface with a resolution of 158762. |
Sure! Those files are at https://drive.google.com/drive/folders/13oLnnjtnD0fpMN1InQZEygSShNFLjXyM?usp=sharing |
Thanks! It looks like the spheres are actually in 32k, whereas the surface is in ~150k?
(The warning is caused by metadata in the surface GIFTI, and occurs with |
Sorry for the misunderstanding, I meant originally that the spheres match the template surface and func cifti, not the high-res subject surface. |
I see. Either way, it looks like the Connectome Workbench command "-surface-resample" cannot resample an input surface that is very-high resolution. This example causes the same problem:
Note that a surface can be resampled to a very-high resolution; the error seems to occur when a surface is resampled from a very-high resolution to any other resolution, larger or smaller. I will have to look into this more, but it seems like for now, there isn't a way that |
I wonder if it has to do with the temporary file location, I found this at the top of the error message after scrolling past the zero triangle warnings:
and then it began those error messages about the zeros in the triangle array. Also, I posted about this in the workbench github in case it is something on their end, but they indicate that they commonly work with very high res surfaces. Best, |
Thanks again Steven for looking into this problem with us! To recap the original problem: to resample the subject surface you've provided here, you will need to have a sphere at the same resolution (158681 vertices). But when I try to make such a sphere with the Workbench command "-surface-create-sphere", the resulting sphere has 158762 vertices, not 158681. So unless you already have a sphere with 158681 vertices, I'm not sure how you can resample this file. I looked more into this follow-up problem, where it seemed like the Connectome Workbench cannot resample any large surface GIFTI file. Actually, it seems like it cannot resample any large surface GIFTI file in which the faces data is encoded with ASCII. I will look for a solution to the follow-up problem. Meanwhile, as the developers of the Workbench recommended, you could use
|
Great, thanks for the thorough investigation! |
Finally checked back on this. wb_command can operate on ascii-encoded large gifti files it generates:
Perhaps something is going wrong in the library you are writing with, and your file ends up corrupted. It looks like we don't check for an insufficient number of items in ASCII encoding in workbench, so it may fill any missing parts of the file with 0 before it gets to the sanity check that you hit. Do a line count between the start and end tags of the triangles data array, and see if it makes sense, like so:
538772 - 179634 = 359138, and this triangle array's Dim0 is 359120 (for 179562 actual vertices, since |
Thank you Tim! I will do the line count check, and look into |
Hi @coalsont, Sorry for the delay with my response. To restate the problem: If I write a large ASCII-encoded surface geometry GIFTI file with Here's what I see in the command line for a large non-ASCII-encoded surface geometry GIFTI file ( Non-ASCII large GIFTI file
ASCII large GIFTI file
I'm not sure how to interpret this result. Here is the problematic GIFTI file: "bigInflated2.L.surf.gii". https://drive.google.com/file/d/1UwRAsGzG5G8eiMxQRJvqegyrto1noNfE/view?usp=sharing . Is truncation happening, or do you have any other ideas what the problem is? Thanks for your help! Damon |
Well, it wasn't truncated, but I found the issue in your file:
When reading an integer from text, we don't support scientific notation. I was worried that this was also causing a rounding error, but it looks like it only abbreviated exactly 100,000 this way (and presumably would do so for 200k, and 300k, and...). |
Thank you @coalsont !! I added a patch to |
To be clear, I believe we do support scientific notation when the array is of type float32, it is just unexpected for integer types (because they need to remain exact). |
Hi, I am still getting this error using the most recent version of ciftitools. |
Yes, unfortunately Could you try using the new
|
The error persists on this version of |
The error is different than the original error ( Command
Error
|
Here is where that error text is, it is a simple sanity check that the input files look compatible: Excerpt from the help info:
Check the contents of |
Thank you @smeisler for letting me know about this persisting problem, and thanks very much @coalsont for the guidance! I will look into this problem. I may have some follow-up questions, but in the meantime, @smeisler could you use the If you don't have the compatible freesurfer spheres, I'm think that resampling will not be possible with the Connectome Workbench, nor will it be possible with |
I re-read the thread above. To try to clarify: it seems like there were originally two problems.
I believe the first problem has been fixed. But the second problem persists, and cannot be fixed. I think the only solution is to use |
Yes, I have the original FS spheres (
What would I put in for |
Weird, I try the original
So it looks like this subject got further than the other, but is running into a later error. |
Hi @smeisler to create
With the proper |
I was able to resurface the sphere and surface using the wb-commands directly. Minimal example:
(REPEAT WITH RH, INPUT RESAMPLED SPHERES)
Will I have to resample my func.gii before inputting to BayesGLM if I want to completely bypass the built in resampling method? |
That's great you were able to! Unfortunately yes, you would need to resample separately as you did here, and then call BayesGLM after. But I will look into implementing this type of resampling within BayesGLM. |
Sorry I didn't see this earlier. The current-sphere and new-sphere need to be "in register", so if one of them is a native mesh sphere and the other is a standard template sphere, one of them will need to be the "after registration" sphere, otherwise your data won't line up with other subjects using that standard mesh. However, if you are resampling to a standard mesh other than fsaverage, then freesurfer's Edit: I will also note that the HCP pipelines use MSMSulc and MSMAll registration rather than freesurfer registration, which result in less mesh distortion, and particularly for MSMAll, better functional area alignment across subjects as measured by task data. Running MSMSulc may be fairly straightforward on data that hasn't been processed with the HCP pipelines, but running MSMAll would be more of a challenge (it needs a fair number of files, and expects them in the HCP pipelines organization). |
Hello,
Crosspost of mandymejia/BayesfMRI#16
All relevant surface fmriprep outputs for a single subject, as well as the 32k surface fsLR template from templateflow, can be found here.
The goal is to resample the high-density subject surface (
sub-047EPKL011005_ses-1_hemi-L_midthickness.surf.gii
) to the same resolution as the template (tpl-fsLR_den-32k_hemi-L_midthickness.surf.gii
), which matches the cifti (e.g.sub-047EPKL011005_ses-2_task-read_run-1_space-fsLR_den-91k_bold.dtseries.nii
).I also included things like confounds and events, in case these data need to be tested further on BayesfMRI. These data are public (openneuro dataset ds003126), so I have no concerns with sharing derivatives.
Command
test <- resample_surf(surf=fname_gifti_left, resamp_res = 32492, hemisphere='left')
Error
And (I cut out most of the error message because it is very big and repetitive, the last part is below):
triangle 317355, vertex 0Vertex used twice in one triangle: triangle 317356, vertex 0Vertex used twice in one triangle: triangle 317356, vertex 0Vertex used twice in one triangle: triangle 317357, vertex 0Vertex used twice in one triangle: triangle 317357, vertex 0...
Please let me know if I can provide more info or help in any way.
Thanks,
Steven
The text was updated successfully, but these errors were encountered: