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

🔧 Generalize desc-ref_bold and the niworkflows-style sbref sub-workflow #2173

Open
3 tasks
sgiavasis opened this issue Jan 24, 2025 · 2 comments · May be fixed by #2180
Open
3 tasks

🔧 Generalize desc-ref_bold and the niworkflows-style sbref sub-workflow #2173

sgiavasis opened this issue Jan 24, 2025 · 2 comments · May be fixed by #2180

Comments

@sgiavasis
Copy link
Collaborator

Related problem

This is related to #2047.

When a user chooses to use the coregistration_prep_fmriprep nodeblock (which requests the overly-specific desc-ref_bold resource, and produces the sbref resource), but they do not use the bold_mask_fsl_afni BOLD masking (which produces desc-ref_bold), they will get the "missing resource" error for desc-ref_bold.

  • What if we want to use that sbref nodeblock with a different BOLD masking strategy?
  • desc-ref_bold is too vague - what is the resource and what is it used for?

Proposed feature

  • The unifize part of the workflow in FSL-AFNI BOLD masking can be generalized into its own function.
  • coregistration_prep_fmriprep should check if desc-ref_bold (or whatever it is ideally renamed to) exists in the resource pool; if it doesn't, invoke the unifize sub-workflow to create it. That way, any other BOLD mask can be used in conjunction with this sbref generation.
  • Also: desc-ref_bold should be more descriptive, reflecting what is unique about this resource created by the part of the workflow in the FSL-AFNI BOLD masking nodeblock.

Note: related but tangential, this unifize sub-workflow needs an update.

Acceptance criteria

  • Any BOLD masking nodeblock can be used when coregistration_prep_fmriprep is enabled, without getting a missing resource error.
  • The unifize sub-workflow is generalized into a function, and regression testing shows no change in output calculation.
  • desc-ref_bold is renamed to something more descriptive.

Alternatives

No response

Additional context

No response

@birajstha
Copy link
Contributor

birajstha commented Jan 27, 2025

@sgiavasis ,
looks like coregistration_prep_fmriprep just renames desc-ref_bold to sbref hence, resource desc-ref_bold is basically sbref generated by applying space-bold_desc-brain_mask to the "bold-image"?
it is also generated by nodeblock bold_mask_ccs

The "bold-image" passed to create desc-ref_bold looks different between these 2 nodeblocks (bold_mask_ccs and bold_mask_fsl_afni).
Should these be handled separately?

bold_mask_ccs

graph TD
    A[Input Data]
    A1["desc-motion_bold"]
    A2["desc-preproc_bold"]
    A3["desc-brain_T1w"]
    A4["desc-preproc_T1w"]
    A5["desc-reorient_T1w"]

    A --> A1
    A --> A2
    A --> A3
    A --> A4
    A --> A5

    B[Run 3dAutomask]
    A1 -->|bold| B
    B --> B1["Initial BOLD Mask"]

    C[Extract 8th Volume as ROI]
    A1 -->|bold| C
    C --> C1["Func ROI"]

    D[Apply Initial Mask on ROI]
    C1 -->|roi_file| D
    B1 -->|mask_file| D
    D --> D1["Masked Func ROI"]

    E[Register ROI to Anatomical]
    D1 -->|in_file| E
    A3 -->|reference| E
    E --> E1["Func-to-Anat Transform"]

    F[Inverse Func-to-Anat Transform]
    E1 -->|out_matrix_file| F
    F --> F1["Inverse Transform"]

    G[Transform Anatomical Brain to Func Space]
    A3 -->|in_file| G
    C1 -->|reference| G
    F1 -->|in_matrix_file| G
    G --> G1["Anat Brain in Func Space"]

    H[Binarize and Dilate Anat Brain Mask]
    G1 -->|in_file| H
    H --> H1["Dilated Anat Brain Mask"]

    I[Binarize Detectable Func Signals]
    A2 -->|bold| I
    I --> I1["Binarized Func Signals"]

    J[Merge Masks]
    B1 -->|mask_file| J
    H1 -->|mask_file| J
    J --> J1["Merged Masks"]

    K[Take Intersection of Masks]
    J1 -->|operand_files| K
    I1 -->|in_file| K
    K --> K1["Intersected Mask"]

    L[Generate Example Func Brain]
    C1 -->|roi_file| L
    K1 -->|mask_file| L
    L --> L1["Masked Func Brain"]

    M[Generate Outputs]
    K1 -->|space-bold_desc-brain_mask| M
    L1 -->|desc-ref_bold| M
Loading

bold_mask_fsl_afni

graph TD
    A[Input Data]
    A1["motion-basefile"]
    A2["desc-preproc_bold"]
    A3["FSL-AFNI-bold-ref"]
    A4["FSL-AFNI-brain-mask"]
    A5["FSL-AFNI-brain-probseg"]

    A --> A1
    A --> A2
    A --> A3
    A --> A4
    A --> A5

    B[Initialize Transforms with antsAI]
    A3 -->|fixed_image| B
    A4 -->|fixed_image_mask| B
    A1 -->|moving_image| B
    B --> B1["Affine Transform"]

    C[Set up Spatial Normalization]
    A3 -->|fixed_image| C
    A1 -->|moving_image| C
    B1 -->|initial_moving_transform| C
    C --> C1["Normalized Transform"]

    D[Map Brain Mask]
    A5 -->|input_image| D
    A1 -->|reference_image| D
    C1 -->|transforms| D
    D --> D1["Mapped Brain Mask"]

    E[Binarize Mask]
    D1 -->|in_file| E
    E --> E1["Binary Mask"]

    F[Dilate Pre-Mask]
    E1 -->|in_file| F
    F --> F1["Dilated Mask"]

    G[Fix Precision Errors]
    F1 -->|image| G
    G --> G1["Precision-Corrected Image"]

    H[Run N4BiasFieldCorrection]
    G1 -->|mask_image| H
    A1 -->|input_image| H
    H --> H1["Bias-Corrected Image"]

    I[Create Generous BET Mask]
    H1 -->|in_file| I
    I --> I1["BET Mask"]

    J[Dilate BET Mask]
    I1 -->|in_file| J
    J --> J1["Dilated BET Mask"]

    K[Apply BET Mask]
    I1 -->|in_file| K
    J1 -->|mask_file| K
    K --> K1["BET Masked Image"]

    L[Unifize for T2 Contrast]
    K1 -->|in_file| L
    L --> L1["Unifized Image"]

    M[Run 3dAutomask]
    L1 -->|in_file| M
    M --> M1["3dAutomask Output"]

    N[Take Intersection of Masks]
    I1 -->|in_file| N
    M1 -->|operand_file| N
    N --> N1["Final Mask"]

    O[Apply Final Mask]
    L1 -->|in_file| O
    N1 -->|mask_file| O
    O --> O1["Masked Brain"]

    P[Generate Outputs]
    N1 -->|space-bold_desc-brain_mask| P
    O1 -->|desc-ref_bold| P
Loading

@birajstha
Copy link
Contributor

birajstha commented Jan 27, 2025

could this be a common workflow for generating sbref?

graph TD

    A[space-bold_desc-brain_mask]
    B[desc-motion_bold]
    C[Unifize workflow]
    D[coregistration_prep_fmriprep]

    A --> C
    B --> C
    C --desc-ref_bold --> D
    D --> E[sbref]
Loading

@birajstha birajstha moved this from 🏗 In progress to 🚫 Blocked in C-PAC Development Jan 28, 2025
@birajstha birajstha moved this from 🚫 Blocked to 🏗 In progress in C-PAC Development Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

2 participants