Skip to content

Conversation

@birajstha
Copy link
Contributor

@birajstha birajstha commented Jul 7, 2025

Fixes

Fixes

Description

Modified ccs-options Tight/Loose brain mask generation nodeblocks to name the masks appropriately so that it moves downstream to the rest of pipeline and can be used in brain extraction as swappable T1w brain masks.

Technical details

Converts the tight/loose brain masks into generic mask that can be used downstream.

outputs["space-T1w_desc-brain_mask"] = outputs.pop("space-T1w_desc-loose_brain_mask")

Adding metadata info into the nodeblock decorator as

    outputs={
        "space-T1w_desc-brain_mask": {
            "Description": "Brain mask extracted using FreeSurfer-BET-Loose method",
            "Method": "FreeSurfer-BET-Loose",
            "Threshold": "loose"
        }

Tests

Run CPAC with config where these brain extraction methods are enabled and then see if the respective outputs are available in the output/anat dir.

anatomical_preproc:
  run: On
  brain_extraction:
    run: On
    using: [FreeSurfer-BET-Tight, FreeSurfer-BET-Loose]

Screenshots

Ran Config with
image

and checked the output/anat
image

CPAC Variant info in the metadata
image

Final Masked Brain from Tight (left) Loose (right)
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 self-assigned this Jul 7, 2025
@birajstha birajstha changed the base branch from main to develop July 7, 2025 22:40
@birajstha birajstha marked this pull request as draft July 7, 2025 22:47
@codecov
Copy link

codecov bot commented Jul 7, 2025

Codecov Report

Attention: Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.

Project coverage is 28.8%. Comparing base (e2d6a31) to head (266f7a4).

Files with missing lines Patch % Lines
CPAC/anat_preproc/anat_preproc.py 66.7% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #2265     +/-   ##
=========================================
+ Coverage     28.7%   28.8%   +0.1%     
=========================================
  Files          230     230             
  Lines        26169   26195     +26     
  Branches      4113    4113             
=========================================
+ Hits          7503    7541     +38     
+ Misses       18018   18006     -12     
  Partials       648     648             
Files with missing lines Coverage Δ
CPAC/anat_preproc/tests/test_anat_preproc.py 41.3% <100.0%> (+24.4%) ⬆️
CPAC/anat_preproc/anat_preproc.py 12.4% <66.7%> (+0.7%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@birajstha birajstha moved this to 🏗 In progress in C-PAC Development Jul 8, 2025
@birajstha birajstha force-pushed the fix/ccs-options-brain-masking branch from e07c6eb to 737e557 Compare July 8, 2025 17:00
@birajstha birajstha requested a review from a team July 8, 2025 17:07
@birajstha birajstha marked this pull request as ready for review July 8, 2025 18:13
@birajstha birajstha moved this from 🏗 In progress to 👀 In review in C-PAC Development Jul 8, 2025
@birajstha birajstha linked an issue Jul 8, 2025 that may be closed by this pull request
17 tasks
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.

I think as long as clearing

# CCS brain mask is in FS space, transfer it back to native T1 space
fs_fsl_brain_mask_to_native = pe.Node(
interface=freesurfer.ApplyVolTransform(),
name=f"fs_fsl_brain_mask_to_native_{node_id}",
)
fs_fsl_brain_mask_to_native.inputs.reg_header = True
fs_fsl_brain_mask_to_native.inputs.interp = "nearest"
wf.connect(
binarize_combined_mask, "out_file", fs_fsl_brain_mask_to_native, "source_file"
)
node, out = strat_pool.get_data("pipeline-fs_raw-average")
wf.connect(node, out, fs_fsl_brain_mask_to_native, "target_file")
node, out = strat_pool.get_data("freesurfer-subject-dir")
wf.connect(node, out, fs_fsl_brain_mask_to_native, "subjects_dir")
out is intentional then this looks good.

@sgiavasis sgiavasis merged commit 1d39110 into develop Jul 28, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in C-PAC Development Jul 28, 2025
@shnizzedy
Copy link
Member

Since this PR is recent and ccs-options masking, I wonder if this change is causing #2279?

@birajstha
Copy link
Contributor Author

Since this PR is recent and ccs-options masking, I wonder if this change is causing #2279?

@shnizzedy , yeah looks like it. It seems like the subjects I ran tests with had same image for FS and T1w space so it passes all my tests. Will look into this

@birajstha
Copy link
Contributor Author

birajstha commented Sep 9, 2025

Oh I remember why we removed that step. It produced a noise.
C-PAC Architecture - CCS Freesurfer BET brain masks

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.

🐛 Repair Freesurfer FSL ccs-options brain mask workflow 🐛 Change output names of Freesurfer FSL ccs-options brain masking outputs

4 participants