From 338dab587b28ec386e19c93858f7b7fc955b490b Mon Sep 17 00:00:00 2001 From: Tim Coalson Date: Mon, 29 Apr 2024 18:50:39 -0500 Subject: [PATCH 1/3] give outer diffusion script a seconds option for echo spacing --- DiffusionPreprocessing/DiffPreprocPipeline.sh | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/DiffusionPreprocessing/DiffPreprocPipeline.sh b/DiffusionPreprocessing/DiffPreprocPipeline.sh index 641c216c6..304effe98 100755 --- a/DiffusionPreprocessing/DiffPreprocPipeline.sh +++ b/DiffusionPreprocessing/DiffPreprocPipeline.sh @@ -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." @@ -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, other scripts expect 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 @@ -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}" From 1e71908d2b0c9c2cf792672f056200c2e1bce647 Mon Sep 17 00:00:00 2001 From: Tim Coalson Date: Mon, 29 Apr 2024 22:47:43 -0500 Subject: [PATCH 2/3] Update DiffusionPreprocessing/DiffPreprocPipeline.sh Co-authored-by: Michael Harms --- DiffusionPreprocessing/DiffPreprocPipeline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DiffusionPreprocessing/DiffPreprocPipeline.sh b/DiffusionPreprocessing/DiffPreprocPipeline.sh index 304effe98..f21151730 100755 --- a/DiffusionPreprocessing/DiffPreprocPipeline.sh +++ b/DiffusionPreprocessing/DiffPreprocPipeline.sh @@ -260,7 +260,7 @@ then log_Err_Abort "You must not specify both --echospacing-seconds and --echospacing" fi -#internally, other scripts expect milliseconds +#internally, PreEddy script expects milliseconds if [[ "$echospacingsec" != "" ]] then echospacingmilli=$(echo "$echospacingsec * 1000" | bc -l) From 814e15cedf47a3b1ef6e2320dd0c17697cab4f23 Mon Sep 17 00:00:00 2001 From: Tim Coalson Date: Mon, 29 Apr 2024 22:56:52 -0500 Subject: [PATCH 3/3] update diffusion example to seconds --- Examples/Scripts/DiffusionPreprocessingBatch.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/Scripts/DiffusionPreprocessingBatch.sh b/Examples/Scripts/DiffusionPreprocessingBatch.sh index 7f2a33b4e..7c924b21f 100755 --- a/Examples/Scripts/DiffusionPreprocessingBatch.sh +++ b/Examples/Scripts/DiffusionPreprocessingBatch.sh @@ -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 @@ -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"