This shows you the differences between two versions of the page.
biac:analysis:topup_correction [2019/02/21 18:41] cmp12 |
biac:analysis:topup_correction [2023/02/23 18:43] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== EPI Correction with polarity images using TOPUP ====== | ||
- | Steps to setup and apply [[https:// | ||
- | |||
- | ==== Create your acquisition parameters ==== | ||
- | |||
- | There will be two series of single timepoint EPI images. | ||
- | |||
- | You need to calculate readout time in seconds ( the physical time it takes to get the acquisition matrix of a single slice ) and get the polarity direction ( phase encode direction ). | ||
- | |||
- | the readout time in seconds for the parameter file will be: | ||
- | < | ||
- | |||
- | echospacing in the BXH header is in microseconds | ||
- | </ | ||
- | |||
- | |||
- | the polarity for the entry will have to be determined from the **seriesdescription**, | ||
- | |||
- | reverse will be " | ||
- | |||
- | < | ||
- | echo '0 1 0 readout' | ||
- | echo '0 -1 0 readout' | ||
- | |||
- | example output: | ||
- | 0 1 0 0.077312 | ||
- | 0 -1 0 0.077312 | ||
- | |||
- | </ | ||
- | |||
- | ==== Create your Blip Up/Down image ==== | ||
- | |||
- | Merge the two polarity images together into a 4D file with fsl_merge. Put them in the order of your acq_params.txt file. In the example above, it would be regular, then reversed. | ||
- | |||
- | < | ||
- | fslmerge -t bud ../ | ||
- | | ||
- | tesla:00273 cmp12$ fslinfo bud.nii.gz | ||
- | data_type | ||
- | dim1 128 | ||
- | dim2 128 | ||
- | dim3 70 | ||
- | dim4 2 | ||
- | </ | ||
- | |||
- | {{: | ||
- | |||
- | ==== Run topup to calculate the field and coefficients images for correction ==== | ||
- | |||
- | < | ||
- | #run popup calculate the field/coef | ||
- | topup --verbose --imain=bud --datain=acq_params.txt --config=$FSLDIR/ | ||
- | </ | ||
- | |||
- | ==== Now apply the correction to your functional runs ==== | ||
- | **inindex** references the " | ||
- | |||
- | < | ||
- | #apply it | ||
- | applytopup --imain=../ | ||
- | applytopup --imain=../ | ||
- | applytopup --imain=../ | ||
- | </ | ||
- | |||
- | The top two images are an example of the polarity images after correction, which is not necessary. | ||
- | The bottom two images are the mean functional image of a series uncorrected, | ||
- | |||
- | {{: | ||
- | |||
- | If you want to re-generate a valid BXH for the corrected data, you can generate a new BXH and merge in the original info | ||
- | |||
- | < | ||
- | fslwrapbxh run008 | ||
- | mv run008.bxh tmp.bxh | ||
- | bxh_merge ../ | ||
- | rm tmp.bxh | ||
- | </ | ||
- | |||
- | |||
- | |||
- | --------------- | ||
- | |||
- | ====== DWI Correction with RPE B0s using TOPUP ====== | ||
- | |||
- | Correcting DWI images using reverse phase encoded B0s is almost the same as the above. | ||
- | |||
- | ==== Create your acq_params.txt file === | ||
- | |||
- | the readout time in seconds for the parameter file will be: | ||
- | < | ||
- | |||
- | echospacing in BXH header is in microseconds | ||
- | </ | ||
- | |||
- | the regular B0s will get the " | ||
- | |||
- | < | ||
- | echo '0 1 0 [readout]' | ||
- | echo '0 1 0 [readout]' | ||
- | echo '0 -1 0 [readout]' | ||
- | echo '0 -1 0 [readout]' | ||
- | |||
- | example output: | ||
- | 0 1 0 0.10656 | ||
- | 0 1 0 0.10656 | ||
- | 0 -1 0 0.10656 | ||
- | 0 -1 0 0.10656 | ||
- | </ | ||
- | |||
- | ==== Create your Blip Up/Down image ==== | ||
- | |||
- | First, you'll need to extract your B0s from the regular DWI acquisition. | ||
- | |||
- | If you look at the gradient directions within the DWI acquisition the B0s will be "0 0 0". | ||
- | |||
- | Within the BXH the first 2 directions are B0: | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | Extract them with bxhselect: | ||
- | < | ||
- | bxhselect --timeselect 0:1 bia6_00197_012.bxh bu | ||
- | bxhselect --timeselect 0:1 bia6_00197_013.bxh bd | ||
- | </ | ||
- | |||
- | This will create bu.nii.gz / bd.nii.gz with the first 2 gradient directions ( the B0s ) | ||
- | |||
- | Now merge the extracted B0s from the regular acquisition with the images from the reversed acquisition. | ||
- | < | ||
- | fslmerge -t bud bu.nii.gz bd.nii.gz | ||
- | |||
- | tesla:HCP cmp12$ fslinfo bud.nii.gz | ||
- | data_type | ||
- | dim1 256 | ||
- | dim2 256 | ||
- | dim3 92 | ||
- | dim4 4 | ||
- | </ | ||
- | |||
- | {{: | ||
- | |||
- | ==== Run topup to calculate the field and coefficients images for correction ==== | ||
- | |||
- | < | ||
- | #run popup calculate the field/coef | ||
- | topup --verbose --imain=bud --datain=acq_params.txt --config=$FSLDIR/ | ||
- | </ | ||
- | |||
- | ==== Now apply the correction to your DWI ==== | ||
- | |||
- | **inindex** references the " | ||
- | ms. | ||
- | txt file | ||
- | |||
- | < | ||
- | #apply it | ||
- | applytopup --imain=bia6_00197_012.nii.gz --inindex=1 --method=jac --datain=acq_params.txt --topup=dwi_topup --out=dwi_corrected --verbose | ||
- | </ | ||
- | |||
- | {{: | ||
- | |||
- | If you want to re-generate a valid BXH for the corrected data, you can generate a new BXH and merge in the original info | ||
- | |||
- | < | ||
- | fslwrapbxh dwi_corrected.nii.gz | ||
- | mv dwi_corrected.bxh tmp.bxh | ||
- | bxh_addgradients --fsl tmp.bxh bvecs bvals dwi_corrected.bxh | ||
- | rm tmp.bxh | ||
- | </ | ||
- | |||
- | |||
- | --------------- | ||
- | |||
- | ====== DWI Correction with MRTRIX3 and RPE Data ====== | ||
- | |||
- | [[https:// | ||
- | |||
- | ==== Calculate your readout time ==== | ||
- | < | ||
- | |||
- | echospacing in BXH header is in microseconds | ||
- | </ | ||
- | |||
- | ==== Prepare your input datasets ==== | ||
- | |||
- | there are 2 scenarios that typically apply here | ||
- | 1) a short acquisition with RPE B0s | ||
- | 2) an entire acquisition with the same gradient table and reverse phase encoding | ||
- | |||
- | ===== Scenario 1 ===== | ||
- | |||
- | For scenario 1, create your blip up / blip down B0 data the same way as above. | ||
- | < | ||
- | bxhselect --timeselect 0:1 bia6_00197_012.bxh bu | ||
- | bxhselect --timeselect 0:1 bia6_00197_013.bxh bd | ||
- | fslmerge -t bud bu.nii.gz bd.nii.gz | ||
- | < | ||
- | |||
- | Prepare your dwi series for input to mrtrix3. | ||
- | |||
- | < | ||
- | #pull the gradient table from BXH in FSL format | ||
- | extractdiffdirs --fsl bia6_00414_013.bxh bvecs bvals | ||
- | |||
- | #convert nii.gz data into mif while inserting the gradients | ||
- | mrconvert -fslgrad bvecs bvals bia6_00414_013.nii.gz dwi.mif | ||
- | |||
- | #you can verify the table | ||
- | tesla:00414 cmp12$ mrinfo dwi.mif -dwgrad | ||
- | 0 | ||
- | 0 | ||
- | 1 | ||
- | | ||
- | -0.264866 | ||
- | | ||
- | 0.0630209 | ||
- | -0.679047 | ||
- | | ||
- | -0.232946 | ||
- | | ||
- | -0.111021 | ||
- | -0.132016 | ||
- | |||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- |