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

Diffusion echo spacing units #291

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions DiffusionPreprocessing/DiffPreprocPipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ opts_AddMandatory '--posData' 'PosInputImages' 'data_RL1@data_RL2@...data_RLn' "

opts_AddMandatory '--negData' 'NegInputImages' 'data_LR1@data_LR2@...data_LRn' "An @ symbol separated list of data with 'negative' phase encoding direction; e.g., data_LR1@data_LR2@...data_LRn, or data_AP1@data_AP2@...data_APn"

opts_AddMandatory '--echospacing' 'echospacing' 'Number in msec' "Echo spacing in msecs"
opts_AddOptional '--echospacing-seconds' 'echospacingsec' 'Number in sec' "Echo spacing in seconds, REQUIRED (or deprecated millisec option)"
opts_AddOptional '--echospacing' 'echospacing' 'Number in millisec' "DEPRECATED: please use --echospacing-seconds"

opts_AddMandatory '--gdcoeffs' 'GdCoeffs' 'Path' "Path to file containing coefficients that describe spatial variations of the scanner gradients. Applied *after* 'eddy'. Use --gdcoeffs=NONE if not available."

Expand Down Expand Up @@ -248,6 +249,36 @@ then
TopupConfig="${HCPPIPEDIR_Config}/b02b0.cnf"
fi

#resolve echo spacing being required and exclusivity
if [[ "$echospacing" == "" && "$echospacingsec" == "" ]]
then
log_Err_Abort "You must specify --echospacing-seconds or --echospacing"
fi

if [[ "$echospacing" != "" && "$echospacingsec" != "" ]]
then
log_Err_Abort "You must not specify both --echospacing-seconds and --echospacing"
fi

#internally, PreEddy script expects milliseconds
if [[ "$echospacingsec" != "" ]]
then
echospacingmilli=$(echo "$echospacingsec * 1000" | bc -l)
else
#could add a deprecation warning here, if we want to remove the old parameter in the future
echospacingmilli="$echospacing"
fi

#check for input unit errors
if [[ $(echo "$echospacingmilli < 10 && $echospacingmilli > 0.01" | bc) == 0* ]]
then
log_Err_Abort "$echospacingmilli milliseconds is not a sane value for echo spacing"
fi
if [[ $(echo "$echospacingmilli < 1 && $echospacingmilli > 0.1" | bc) == 0* ]]
then
log_Warn "$echospacingmilli milliseconds seems unlikely for echo spacing, continuing anyway"
fi

"$HCPPIPEDIR"/show_version

# Verify required environment variables are set and log value
Expand Down Expand Up @@ -320,7 +351,7 @@ pre_eddy_cmd=("${HCPPIPEDIR}/DiffusionPreprocessing/DiffPreprocPipeline_PreEddy.
"--PEdir=${PEdir}"
"--posData=${PosInputImages}"
"--negData=${NegInputImages}"
"--echospacing=${echospacing}"
"--echospacing=${echospacingmilli}"
"--b0maxbval=${b0maxbval}"
"--topup-config-file=${TopupConfig}"
"--printcom=${runcmd}"
Expand Down
6 changes: 3 additions & 3 deletions Examples/Scripts/DiffusionPreprocessingBatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ for Subject in $Subjlist ; do
PosData="${RawDataDir}/${SubjectID}_3T_DWI_dir95_RL.nii.gz@${RawDataDir}/${SubjectID}_3T_DWI_dir96_RL.nii.gz@${RawDataDir}/${SubjectID}_3T_DWI_dir97_RL.nii.gz"
NegData="${RawDataDir}/${SubjectID}_3T_DWI_dir95_LR.nii.gz@${RawDataDir}/${SubjectID}_3T_DWI_dir96_LR.nii.gz@${RawDataDir}/${SubjectID}_3T_DWI_dir97_LR.nii.gz"

# "Effective" Echo Spacing of dMRI image (specified in *msec* for the dMRI processing)
# "Effective" Echo Spacing of dMRI image (now specified in seconds for the dMRI processing)
# EchoSpacing = 1/(BWPPPE * ReconMatrixPE)
# where BWPPPE is the "BandwidthPerPixelPhaseEncode" = DICOM field (0019,1028) for Siemens, and
# ReconMatrixPE = size of the reconstructed image in the PE dimension
# In-plane acceleration, phase oversampling, phase resolution, phase field-of-view, and interpolation
# all potentially need to be accounted for (which they are in Siemen's reported BWPPPE)
EchoSpacing=0.78
EchoSpacingSec=0.00078

PEdir=1 #Use 1 for Left-Right Phase Encoding, 2 for Anterior-Posterior

Expand All @@ -158,7 +158,7 @@ for Subject in $Subjlist ; do
"${queuing_command[@]}" "${HCPPIPEDIR}"/DiffusionPreprocessing/DiffPreprocPipeline.sh \
--posData="${PosData}" --negData="${NegData}" \
--path="${StudyFolder}" --subject="${SubjectID}" \
--echospacing="${EchoSpacing}" --PEdir="${PEdir}" \
--echospacing-seconds="${EchoSpacingSec}" --PEdir="${PEdir}" \
--gdcoeffs="${Gdcoeffs}" \
--printcom="$PRINTCOM"

Expand Down