Closed tashrifbillah closed 4 years ago
Omit applytopup
entirely, introduce --iout
with topup
:
https://github.com/pnlbwh/pnlNipype/blob/topup-mask/scripts/fsl_topup_epi_eddy.py#L361
When both masks are provided:
if primaryMask and secondaryMask:
# threshold the mean of corrected primary,secondary mask at 0.5 to obtain modified mask
# use that mask for eddy_openmp
primaryMaskCorrect = tmpdir / 'primary_mask_corrected.nii.gz'
applytopup[f'--imain={primaryMask}',
f'--datain={self.acqparams_file}',
'--inindex=1',
f'--topup={topup_results}',
f'--out={primaryMaskCorrect}',
'--verbose',
'--method=jac',
'--interp=trilinear',
applytopup_params.split()] & FG
secondaryMaskCorrect = tmpdir / 'secondary_mask_corrected.nii.gz'
applytopup[f'--imain={secondaryMask}',
f'--datain={self.acqparams_file}',
'--inindex=2',
f'--topup={topup_results}',
f'--out={secondaryMaskCorrect}',
'--verbose',
'--method=jac',
'--interp=trilinear',
applytopup_params.split()] & FG
fslmerge('-t', topupMask, primaryMaskCorrect, secondaryMaskCorrect)
fslmaths[topupMask, '-Tmean', topupMask] & FG
fslmaths[topupMask, '-thr', '0.5', topupMask, '-odt', 'char'] & FG
Otherwise,
# apply bet on the mean of topup output to obtain modified mask
# use that mask for eddy_openmp
topupOutMean= tmpdir / 'topup_out_mean.nii.gz'
fslmaths[--iout, '-Tmean', topupOutMean] & FG
# toupOutMean is already masked, so -thr against 0
fslmaths[topupOutMean, '-thr', '0', topupMask, '-odt', 'char'] & FG
QC outputs:
B0 PA corrected, primary_mask_corrected
B0 AP corrected, secondary_mask_corrected
topupOutMean, topupMask
Idea:
B0 PA corrected
B0 AP corrected
are in topupOut
.
topupOutMean
is always generated.
primary_mask_corrected, secondary_mask_corrected
are generated if both masks are provided.
-thr 0.5
masking methodhttps://github.com/pnlbwh/pnlNipype/blob/master/scripts/fsl_topup_epi_eddy.py#L381