Skip to content
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

Updates for shape injection and surf processing of injected surfaces #374

Merged
merged 13 commits into from
Feb 13, 2025

Conversation

akhanf
Copy link
Member

@akhanf akhanf commented Feb 11, 2025

This PR makes changes to injection and surface processing for dealing with native surf with nnunet + injection.

  • high-res ref space for hipp, dentate from shape inject (hipp default 0.3, dentate 0.1)
    • required adding a label wildcard to the dsegtissue and upsampled_ref
      files
  • fixes to get injected dentate/hipp working well (enough)
  • updated template upenn tissue dseg to include DG (only local
    currently)
  • updates to greedy registration for shape inject
    • downsampling for greedy template shape reg
    • enforce det=1 for template shape reg moments (was flipping)
  • dilate dentate pd src/sink (not used yet)
  • adjust decimation
  • use workaround for transforming surfaces (need to look into this bug - perhaps provide an example to HCP devs)
  • use two different, new, sdt threshold approaches

TODO:

  • update dentate dseg tissue for upenn - used:
    c3d tpl-upenn_desc-DGtissue_dseg.nii.gz -retain-labels 1 2 -as DG -binarize -popas MASK -push DG -shift 8 -push MASK -multiply tpl-upenn_desc-hipptissue_dseg.nii.gz -maximum -o tpl-upenn_desc-hippdentate_dseg.nii.gz
  • note: this messes up the hipp coords, so in the code I make use of a hipp-specific and dentate-specific tissue dseg (which we have in separate images ultimately anyways since they are resampled differently).

akhanf and others added 11 commits February 8, 2025 23:29
- splits into different rules for extracting the boundary, and getting
distances to src/sink masks
- those new rules now produce surface maps (for easier introspection),
which are passed along to the laplace beltrami rule
- the dentate AP src in bbhist hemi-L was problematic with existing
approach, since the PD src/sink were always closer than the AP src, so
no vertices were being labelled with AP src.
- in this version, we do things a little different:
  1. AP and PD are done independently now
  2. Instead of nearest neighbor, we use a distance threshold, which is
defined based on a signed distance transform of the mask, mapped to the
surface.
  3. Actually there is a minimum distance, and maximum distance, along
with the minimum number of vertices required in the src/sink. The
threshold is swept until the desired number is reached, to deal with
cases such as the above.

- TODO: the get_boundary_vertices script could be further improved to
perform connected components and picking the largest one, to avoid being
affected by holes or other defects..

- TODO: the laplace beltrami solver doesn't take as long to run now that
I am decimating alot, but if we want to further optimize things, I think
the step of altering the laplacian based on the boundary conditions, after it has been made a sparse matrix, is where the inefficiency lies (based on profiling). Could try to avoid setting those weights in the first place instead of setting it after the fact..

- NOTE: solve_laplace_beltrami_open_mesh() is kept as is (except for some
logging statements)
- required adding a label wildcard to the dsegtissue and upsampled_ref
files
- adds bbhist template and atlas files too (only locally for now)..
- updated template upenn tissue dseg to include DG (only local
currently)
  - TODO add rule, used:
     c3d tpl-upenn_desc-DGtissue_dseg.nii.gz -retain-labels 1 2 -as DG -binarize -popas MASK -push DG -shift 8 -push MASK -multiply tpl-upenn_desc-hipptissue_dseg.nii.gz -maximum -o tpl-upenn_desc-hippdentate_dseg.nii.gz
- downsampling for greedy template shape reg
- dilate dentate pd src/sink (not used yet)
- enforce det=1 for template shape reg moments (was flipping)
- adjust sdt dist thresholds to get upenn-injected labels working (will need to customize these based on application)
- adjust trimming for upsampled coords ref (was cutting off surf)
- adjust decimation
percentile-based for AP, and firstminima for PD
@akhanf akhanf marked this pull request as ready for review February 12, 2025 01:37
@akhanf
Copy link
Member Author

akhanf commented Feb 13, 2025

updated upenn dseg is uploaded to osf now, so I will merge this now to move things along..

Will see if I can try to get the updated src/sink labels and new gyrification done before I am travelling tomorrow..

@akhanf akhanf merged commit 32b66fe into dev-v2.0.0 Feb 13, 2025
6 checks passed
@akhanf akhanf deleted the hires-inject branch February 13, 2025 15:35
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.

1 participant