Skip to content

NHP fMRIVolume#372

Open
TakJim wants to merge 33 commits intoWashington-University:masterfrom
RIKEN-BCIL:NHPUnifiedFMRIVolume
Open

NHP fMRIVolume#372
TakJim wants to merge 33 commits intoWashington-University:masterfrom
RIKEN-BCIL:NHPUnifiedFMRIVolume

Conversation

@TakJim
Copy link
Contributor

@TakJim TakJim commented Dec 15, 2025

This PR applies fMRIVolume to NHP data.

Some additional modifications are still required. The parts that I have not been able to address yet are listed below.

TODO

  • In GenericfMRIVolumeProcessingPipelineBatchNHP.sh, accept arguments via opts_AddMandatory / opts_AddOptional
  • In BatchNHP.sh, reorganize the parameters defined in hcppipe_conf.txt and allow users to specify them directly within BatchNHP.sh
  • Apply the IsLongitudinal=TRUE processing logic to PipelineBatchNHP.sh

@glasserm glasserm self-requested a review December 15, 2025 14:39
Copy link
Contributor

@glasserm glasserm left a comment

Choose a reason for hiding this comment

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

My overall comment is that I think we should properly merge the NHP changes in to the fMRIVolume pipeline rather than bifurcate the pipelines. There is a lot of reused code between fMRIVolume and the BBR code and these are not really a completely separate process like they were for FreeSurferNHP. On initial review the changes to one step resampling and motion correction looked okay.

@TakJim
Copy link
Contributor Author

TakJim commented Dec 23, 2025

@glasserm
#372 (review)

Thank you for the comment — that makes sense.

To confirm, should
fMRIVolume/scripts/DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbasedNHP.sh
also be combined into the main DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbased.sh, rather than being kept as an NHP-specific variant?

After discussing with @takuya-hayashi, we felt that this script includes quite a lot of NHP-specific logic.
I’d appreciate your thoughts on whether it should still be merged or kept separate.

@glasserm
Copy link
Contributor

@glasserm #372 (review)

Thank you for the comment — that makes sense.

To confirm, should fMRIVolume/scripts/DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbasedNHP.sh also be combined into the main DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbased.sh, rather than being kept as an NHP-specific variant?

After discussing with @takuya-hayashi, we felt that this script includes quite a lot of NHP-specific logic. I’d appreciate your thoughts on whether it should still be merged or kept separate.

Yes please.

@mmilch01
Copy link
Contributor

betspecieslabel is not currently defined for human stream (including in SetUpSpecies.sh on main branch) and breaks processing.

- Fix ${10}/${11} positional parameter expansion in MotionCorrection.sh
- Fix IsLongitudinal condition that always evaluated False
- Add --species option to OneStepResampling.sh
- Delete unused GenericfMRIVolumeMotionCorrectXRunsNHP.sh
@glasserm
Copy link
Contributor

betspecieslabel is not currently defined for human stream (including in SetUpSpecies.sh on main branch) and breaks processing.

This will be followed up with a specific location where there is an issue.

@glasserm
Copy link
Contributor

@coalsont We need to rebase this PR with the PreFreeSurfer merged PR so that all of this PR's dependencies are present. @mmilch01 has more details on this issue.

@coalsont
Copy link
Member

@TakJim did rebase it against our master after the PreFS merge.

- Rename --bbr/BBR to --bbr-contrast/BBRContrast for clarity
- Fix jacobian comment in human code path, remove in NONE path
- Use (( ! IsLongitudinal )) syntax in DistortionCorrection script
- Restructure OneStepResampling.sh: full else for human/nonhuman
- Revert multi-echo code changes: restore else clause, remove duplicate
Copy link
Contributor

Choose a reason for hiding this comment

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

This command would currently fail because tcsEchoesGdc, etc. are being defined in the next block. I'll wait for this to be fixed before continuing testing the human stream.

Complete the reversion of echo array changes that was flagged as
incomplete in PR Washington-University#372 review comments r2853580713 and r2853593232.
# fMRI name filter: leave empty to process all fMRI runs in each session
# Set to a specific fMRI name (without extension) to process only that run
fmriname=""

Copy link
Contributor

@mmilch01 mmilch01 Mar 20, 2026

Choose a reason for hiding this comment

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

Suggested change
#structural image resolution
StructRes=0.4


# Set up pipeline environment variables and software
source "$EnvironmentScript"

Copy link
Contributor

@mmilch01 mmilch01 Mar 20, 2026

Choose a reason for hiding this comment

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

Suggested change
if [ -z "$StructRes" ]; then
StructResOption=""
else
StructResOption="--structres=$StructRes"
fi
echo "StructResOption: $StructResOption"

Copy link
Member

@coalsont coalsont Mar 21, 2026

Choose a reason for hiding this comment

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

--structres is mandatory, so it doesn't need the flag in a variable.

Comment on lines +129 to +130
source "$HCPPIPEDIR"/Examples/Scripts/SetUpSPECIES.sh --species="$SPECIES"
source "$HCPPIPEDIR"/FreeSurfer/custom/SetUpFSNHP.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
source "$HCPPIPEDIR"/Examples/Scripts/SetUpSPECIES.sh --species="$SPECIES"
source "$HCPPIPEDIR"/FreeSurfer/custom/SetUpFSNHP.sh
source "$HCPPIPEDIR"/Examples/Scripts/SetUpSPECIES.sh --species="$SPECIES $StructResOption"
source "$HCPPIPEDIR"/FreeSurfer/custom/SetUpFSNHP.sh "$SPECIES" "$isFLAIR" "$isT1wDivFLAIR"

Copy link
Member

@coalsont coalsont Mar 21, 2026

Choose a reason for hiding this comment

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

Suggested change
source "$HCPPIPEDIR"/Examples/Scripts/SetUpSPECIES.sh --species="$SPECIES"
source "$HCPPIPEDIR"/FreeSurfer/custom/SetUpFSNHP.sh
source "$HCPPIPEDIR"/Examples/Scripts/SetUpSPECIES.sh --species="$SPECIES" --structres="$StructRes"
source "$HCPPIPEDIR"/FreeSurfer/custom/SetUpFSNHP.sh "$SPECIES" "$isFLAIR" "$isT1wDivFLAIR"

# T1w: T1w-based BBR (e.g. for MION fMRI)
# T2w: T2w-based BBR (default)
BBRContrast="T2w"

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#Whether T2w image is FLAIR, 0 or 1
isFLAIR=0
#Whether T2 image is T1w divided by FLAIR, 0 or 1
isT1wDivFLAIR=1

ResampRefIm=$FSLDIR/data/standard/MNI152_T1_2mm
elif [[ $(echo "${FinalfMRIResolution} == 1" | bc) == "1" ]] ; then
ResampRefIm=$FSLDIR/data/standard/MNI152_T1_1mm
# If not a human, just custom fMRI resolution, else, if 1mm or 2mm use standard fMRI resolutions, else, use a custom fMRI resolution.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# If not a human, just custom fMRI resolution, else, if 1mm or 2mm use standard fMRI resolutions, else, use a custom fMRI resolution.
# If not a human, just use -applyisoxfm

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.

5 participants