This shows you the differences between two versions of the page.
biac:analysis:topup_correction [2019/02/21 17:10] 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 B0s using TOPUP ====== | ||
- | |||
- | Correcting DWI images using 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 | ||
- | </ | ||