Skip to content

Resample surfaces to any space/density using Connectome Workbench. #473

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

feilong
Copy link

@feilong feilong commented May 1, 2025

Adding init_resample_surfaces_wb_wf, which is similar to init_resample_surfaces_wf but not limited to fsLR spaces.
It can resample surfaces to the specified space and density if the corresponding files exist in TemplateFlow.

For non-fsLR templates, it needs the space-fsLR files of the template, which connects the registered sphere (fsLR space) with the template (template space).
For example, with tpl-onavg_space-fsLR_hemi-L_den-10k_sphere.surf.gii it can resample the subject's surfaces to space-onavg_hemi-L_den-10k.

The code is mostly copied and modified from init_resample_surfaces_wf.

@feilong
Copy link
Author

feilong commented May 1, 2025

I believe the failed docs check was because TemplateFlow S3 hasn't been updated.

@effigies
Copy link
Member

@feilong I think we can do this just by updating the parameterization of the existing workflow. I pushed my suggestion directly, but feel free to force-push back to yours.

Here are the diffs:

@mgxd This needs your review, since you use this function in nibabies.

sphere_reg_fsLR
GIFTI surface mesh corresponding to the subject's fsLR registration sphere
GIFTI surface mesh corresponding to the subject's fsLR registration sphere.

Outputs
-------
``<surface>``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``<surface>``
``<surface>_<space>``


fslr_density = '32k' if grayord_density == '91k' else '59k'
workflow = Workflow(name=name)

inputnode = pe.Node(
niu.IdentityInterface(fields=[*surfaces, 'sphere_reg_fsLR']),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the goal is to make this generalizable, this should be sphere_reg_{space}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that what @feilong has is registrations from fsLR to onavg.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, by default the sphere.reg generated by MSM is always registered to fsLR.

sphere_reg_fsLR
GIFTI surface mesh corresponding to the subject's fsLR registration sphere
GIFTI surface mesh corresponding to the subject's fsLR registration sphere.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GIFTI surface mesh corresponding to the subject's fsLR registration sphere.
GIFTI surface mesh corresponding to the subject's ``space`` registration sphere.

Comment on lines 1402 to 1412
resampler.inputs.new_sphere = [
str(
tf.get(
template='fsLR',
density=fslr_density,
template=space,
density=density,
suffix='sphere',
hemi=hemi,
space=None,
space=(None if space == 'fsLR' else 'fsLR'),
extension='.surf.gii',
)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

altering space in this templateflow query feels brittle - for instance, it will not be able to handle:

https://github.com/nipreps/nibabies/blob/1e6afd415ec2776a4bf749628fa1a58646d536db/nibabies/workflows/anatomical/surfaces.py#L502-L512

thinking we can either extract this out, or add a parameter tf_space to handle this - don't particularly love either tbh

Copy link
Author

@feilong feilong May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of space- here resembles tpl-dhcpAsym_cohort-42_space-fsaverage_hemi-L_den-41k_desc-reg_sphere.surf.gii.
It is supposed to get the sphere file that bridges two spaces (e.g., dhcpAsym and fsaverage, onavg and fsLR).

I'm not familiar with dhcpAsym templates. Do the templates also imply space-fsLR when space is not specified?

I prefer to use atlas to refer to the registration target, because the registration target is mainly about the cortical folding patterns, but atlas is also an overloaded term...

@feilong
Copy link
Author

feilong commented May 22, 2025

@effigies Your suggestions make a lot of sense to me. The only reason I kept init_resample_surfaces_wf in my version was to avoid breaking workflows that depend on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants