pnlbwh / pnlNipype

PNL pipeline for NIFTI images
Other
10 stars 15 forks source link

`applytopup --inindex` inaccurate for multiple b0s #79

Closed tashrifbillah closed 3 years ago

tashrifbillah commented 3 years ago

https://github.com/pnlbwh/pnlNipype/blob/17c74e0e7ba01dbbfc4caa6be3df044bcc7b0cf7/scripts/fsl_topup_epi_eddy.py#L382 and https://github.com/pnlbwh/pnlNipype/blob/17c74e0e7ba01dbbfc4caa6be3df044bcc7b0cf7/scripts/fsl_topup_epi_eddy.py#L429

inindex=2 wouldn't hold true if num_b0=-1

See how HCP has done it.

tashrifbillah commented 3 years ago

Edit: No action is necessary, it was correct.


Solution for the first block:

            B0_PA_correct= 'B0_PA_corrected.nii.gz'
            applytopup[f'--imain={B0_PA}',
                       f'--datain={self.acqparams_file}',
                       '--inindex=1,1,1,... (#of vols in B0_PA times)',
                       f'--topup={topup_results}',
                       f'--out={B0_PA_correct}',
                       applytopup_params.split()] & FG

            B0_AP_correct= 'B0_AP_corrected.nii.gz'
            applytopup[f'--imain={B0_AP}',
                       f'--datain={self.acqparams_file}',
                       '--inindex=2,2,2,... (#of vols in B0_AP times)',
                       f'--topup={topup_results}',
                       f'--out={B0_AP_correct}',
                       applytopup_params.split()] & FG

On the other hand, if you have many lines in acqparms.txt file, you can do:

'--inindex=1,2,3,4,...,#of vols in B0_PA',

'--inindex=#of vols in B0_PA+1,...,#of vols in B0_AP',
tashrifbillah commented 3 years ago

Edit: No action is necessary, it was correct.


Solution for the second block:

                # binarise the mean of corrected primary,secondary mask to obtain modified mask
                # use that mask for eddy_openmp
                primaryMaskCorrect = 'primary_mask_corrected.nii.gz'
                applytopup[f'--imain={primaryMask}',
                           f'--datain={self.acqparams_file}',
                           '--inindex=1',
                           f'--topup={topup_results}',
                           f'--out={primaryMaskCorrect}',
                           applytopup_params.split()] & FG

                secondaryMaskCorrect = 'secondary_mask_corrected.nii.gz'
                applytopup[f'--imain={secondaryMask}',
                           f'--datain={self.acqparams_file}',
                           f'--inindex={firstB0dim+1}',
                           f'--topup={topup_results}',
                           f'--out={secondaryMaskCorrect}',
                           applytopup_params.split()] & FG

On the other hand, if you have many lines in acqparams.txt, it should be:

--inindex=#of vols in B0_PA+1
tashrifbillah commented 3 years ago
tashrifbillah commented 3 years ago

If we had used a self.acqparams_file with more than two lines, only then the second applytopup must have --inindex=#of vols in B0_PA+1'. This is the case with HCP pipeline where they use acqp_topup.txt as input to applytopup. But we use the one as input where there are only two lines. So this issue is a false alarm!

tashrifbillah commented 3 years ago

Raise an error if self.acqparams_file has more than two lines! We should just refer people to use HCP pipeline.

Fixed by https://github.com/pnlbwh/pnlNipype/commit/8fec5976162fb241ad2aa0b6dc65b41d51f73c11