Skip to content

Conversation

@birajstha
Copy link
Contributor

@birajstha birajstha commented Mar 24, 2025

Fixes

Fixes #2200 by @birajstha
related to #2193 by @tamsinrogers

Alignment issues during applying mask ingressed from Freesurfer outputs.
image

Description

Resources from ingress_freesurfer are skipping reorient and are used directly like in here.

This causes the files ingressed to have different orientation and is incompatible with rest of the data causing alignment issues such as above.

This PR solves the above issue by aligning the ingressed resources to common orientation.

Technical details

Tests

Screenshots

After the fix
image

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I updated the changelog.
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@birajstha birajstha requested a review from a team March 24, 2025 19:02
Copy link
Member

@shnizzedy shnizzedy left a comment

Choose a reason for hiding this comment

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

Just a quibble with a comment, otherwise looks great to me!

This is only an issue for ingress, not if we're running FreeSurfer in the pipeline?

@birajstha birajstha linked an issue Mar 24, 2025 that may be closed by this pull request
14 tasks
@birajstha
Copy link
Contributor Author

birajstha commented Mar 24, 2025

@shnizzedy , I havent't checked running freesurfer in the pipeline but, we should probably do that as well.
I guess it wont hurt to put a reorient workflow in there just to be safe.

@shnizzedy
Copy link
Member

I guess it wont hurt to put a reorient workflow in there just to be safe.

I think if we're doing it in both places, we should abstract it to its own node or nodeblock that's included in both flows.

Comment on lines +2048 to +2049
# reorient *.mgz
if outfile.endswith(".mgz"):
Copy link
Member

Choose a reason for hiding this comment

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

These

C-PAC/CPAC/pipeline/engine.py

Lines 2014 to 2018 in 325deb5

"pipeline-fs_raw-average": "mri/rawavg.mgz",
"pipeline-fs_subcortical-seg": "mri/aseg.mgz",
"pipeline-fs_brainmask": "mri/brainmask.mgz",
"pipeline-fs_wmparc": "mri/wmparc.mgz",
"pipeline-fs_T1": "mri/T1.mgz",
need reoriented but these

C-PAC/CPAC/pipeline/engine.py

Lines 2019 to 2035 in 325deb5

"pipeline-fs_hemi-L_desc-surface_curv": "surf/lh.curv",
"pipeline-fs_hemi-R_desc-surface_curv": "surf/rh.curv",
"pipeline-fs_hemi-L_desc-surfaceMesh_pial": "surf/lh.pial",
"pipeline-fs_hemi-R_desc-surfaceMesh_pial": "surf/rh.pial",
"pipeline-fs_hemi-L_desc-surfaceMesh_smoothwm": "surf/lh.smoothwm",
"pipeline-fs_hemi-R_desc-surfaceMesh_smoothwm": "surf/rh.smoothwm",
"pipeline-fs_hemi-L_desc-surfaceMesh_sphere": "surf/lh.sphere",
"pipeline-fs_hemi-R_desc-surfaceMesh_sphere": "surf/rh.sphere",
"pipeline-fs_hemi-L_desc-surfaceMap_sulc": "surf/lh.sulc",
"pipeline-fs_hemi-R_desc-surfaceMap_sulc": "surf/rh.sulc",
"pipeline-fs_hemi-L_desc-surfaceMap_thickness": "surf/lh.thickness",
"pipeline-fs_hemi-R_desc-surfaceMap_thickness": "surf/rh.thickness",
"pipeline-fs_hemi-L_desc-surfaceMap_volume": "surf/lh.volume",
"pipeline-fs_hemi-R_desc-surfaceMap_volume": "surf/rh.volume",
"pipeline-fs_hemi-L_desc-surfaceMesh_white": "surf/lh.white",
"pipeline-fs_hemi-R_desc-surfaceMesh_white": "surf/rh.white",
"pipeline-fs_xfm": "mri/transforms/talairach.lta",
don't, is that right?

Copy link
Contributor Author

@birajstha birajstha Mar 26, 2025

Choose a reason for hiding this comment

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

Good question ! It looks like all pipeline-fs_hemi* are not used in CPAC but are only ingressed.
I am not sure about pipeline-fs_xfm. It probably needs reorient/resample as well.
I will loop in @sgiavasis here for further clarification.
Steve, do we need to resample this xfm?
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

We've had extensive conversation on this off of GitHub, but going forward from here, let's resolve whatever requested changes there are and merge this.

For the reorient for running Freesurfer as part of the C-PAC pipeline, let's open a separate but related PR for it, as it will be an extension of this one but different.
I'd like to get some runs going with this change for now (since it will be ingressed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am adding this below for documentation purposes.
Tested applying the xfm mentioned above to wmparc from

  1. Freesurfer native orientation

image
and
2. reoriented one from this PR
image

There appears to be no difference in the output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So reorienting only .mgz files.

Copy link
Member

@shnizzedy shnizzedy left a comment

Choose a reason for hiding this comment

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

So reorienting only .mgz files.

https://github.com/FCP-INDI/C-PAC/pull/2199/files#r2035560042

If that's what we're doing, then I think this PR's good to go.

@birajstha
Copy link
Contributor Author

Thanks for the review. I also added #2208 to follow up with your comment on adding reorientation to the FS outputs when ran natively with CPAC.

@birajstha birajstha requested a review from sgiavasis April 9, 2025 15:52
@sgiavasis sgiavasis merged commit 2ffff67 into develop Apr 9, 2025
27 checks passed
@birajstha birajstha deleted the fs_ingress_reorient branch April 10, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

🐛Freesurfer output data skips reorientation

4 participants