biac:analysis:topup_correction
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
biac:analysis:topup_correction [2019/02/20 15:27] – cmp12 | biac:analysis:topup_correction [2019/02/21 19:27] – cmp12 | ||
---|---|---|---|
Line 7: | Line 7: | ||
There will be two series of single timepoint EPI images. | There will be two series of single timepoint EPI images. | ||
- | You need to calculate | + | You need to calculate |
+ | |||
+ | the readout time in seconds for the parameter file will be: | ||
+ | < | ||
+ | |||
+ | echospacing in the BXH header is in microseconds | ||
+ | </ | ||
- | the ETL for the parameter file will be: | ||
- | < | ||
the polarity for the entry will have to be determined from the **seriesdescription**, | the polarity for the entry will have to be determined from the **seriesdescription**, | ||
Line 17: | Line 21: | ||
< | < | ||
- | echo '0 1 0 [ETL]' > acq_params.txt | + | echo '0 1 0 readout' > acq_params.txt |
- | echo '0 -1 0 [ETL]' >> acq_params.txt | + | echo '0 -1 0 readout' >> acq_params.txt |
example output: | example output: | ||
- | 0 1 0 0.604 | + | 0 1 0 0.077312 |
- | 0 -1 0 0.604 | + | 0 -1 0 0.077312 |
</ | </ | ||
Line 78: | Line 82: | ||
--------------- | --------------- | ||
- | ====== DWI Correction with B0s using TOPUP ====== | + | ====== DWI Correction with RPE B0s using TOPUP ====== |
- | Correcting DWI images using B0s is almost the same as the above. | + | Correcting DWI images using reverse phase encoded |
- | ==== Create your acq_params.txt file === | + | ==== Create your acq_params.txt file === |
- | the ETL for the parameter file will be: | + | |
- | < | + | the readout time in seconds |
+ | < | ||
+ | |||
+ | echospacing | ||
+ | </ | ||
the regular B0s will get the " | the regular B0s will get the " | ||
< | < | ||
- | echo '0 1 0 [ETL]' > acq_params.txt | + | echo '0 1 0 [readout]' > acq_params.txt |
- | echo '0 1 0 [ETL]' >> acq_params.txt | + | echo '0 1 0 [readout]' >> acq_params.txt |
- | echo '0 -1 0 [ETL]' >> acq_params.txt | + | echo '0 -1 0 [readout]' >> acq_params.txt |
- | echo '0 -1 0 [ETL]' >> acq_params.txt | + | echo '0 -1 0 [readout]' >> acq_params.txt |
example output: | example output: | ||
- | 0 1 0 0.740 | + | 0 1 0 0.10656 |
- | 0 1 0 0.740 | + | 0 1 0 0.10656 |
- | 0 -1 0 0.740 | + | 0 -1 0 0.10656 |
- | 0 -1 0 0.740 | + | 0 -1 0 0.10656 |
</ | </ | ||
Line 118: | Line 126: | ||
< | < | ||
bxhselect --timeselect 0:1 bia6_00197_012.bxh bu | bxhselect --timeselect 0:1 bia6_00197_012.bxh bu | ||
+ | bxhselect --timeselect 0:1 bia6_00197_013.bxh bd | ||
</ | </ | ||
- | This will create bu.nii.gz with the first 2 gradient directions ( the B0s ) | + | |
+ | 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. | Now merge the extracted B0s from the regular acquisition with the images from the reversed acquisition. | ||
< | < | ||
- | fslmerge -t bud bu.nii.gz | + | fslmerge -t bud bu.nii.gz |
tesla:HCP cmp12$ fslinfo bud.nii.gz | tesla:HCP cmp12$ fslinfo bud.nii.gz | ||
Line 131: | Line 141: | ||
dim3 92 | dim3 92 | ||
dim4 4 | 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 | ||
+ | |||
+ | In both scenarios it is important to create your data with normal phase encoding direction first, followed by reversed. | ||
+ | |||
+ | ===== Scenario 1 ===== | ||
+ | |||
+ | For scenario 1, create your blip up / blip down B0 data the same way as above. | ||
+ | < | ||
+ | bxhselect --timeselect 0 bia6_00197_012.bxh bu | ||
+ | bxhselect --timeselect 0 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 | ||
+ | |||
+ | #export the table back out in their format | ||
+ | mrinfo dwi.mif -export_grad_mrtrix grads.b | ||
+ | |||
+ | #put THOSE back into the mif header | ||
+ | mrconvert -grad grads.b dwi.mif dwi.mif -force | ||
+ | </ | ||
+ | |||
+ | The last step seems redundant, but there is an issue with how mrtrix3 tools are handling the multi-shell GE data produced on our scanners. | ||
+ | |||
+ | ===== Run dwipreproc -rpe_pair ===== | ||
+ | |||
+ | Run [[https:// | ||
+ | |||
+ | < | ||
+ | dwipreproc dwi.mif dwi_corr.mif -rpe_pair -se_epi bud.nii.gz -pe_dir AP -readout_time 0.10656 | ||
+ | |||
+ | -rpe_pair specifies you're providing a pair of B0s ( regular, reversed ) | ||
+ | -se_epi is you bud image | ||
+ | -pe_dir is your dwi's phase encode direction | ||
+ | -readout_time is from calculation above | ||
+ | </ | ||
+ | |||
+ | dwipreproc will run topup, eddy and apply topup. | ||
+ | |||
+ | You can generate a BXH header for a mif file with: | ||
+ | < | ||
+ | mif2bxh dwi_corr.mif dwi_corr.bxh | ||
+ | </ | ||
+ | |||
+ | ===== Scenario 2 ===== | ||
+ | |||
+ | You have an entire acquisition with the same gradient table as your DWI sequence, but with reverse phase encoding. | ||
+ | |||
+ | Calculate the readout time in the same way as above | ||
+ | |||
+ | ==== Prepare your input datasets ==== | ||
+ | |||
+ | This time you'll concatenate the 2 DWI acquisitions. | ||
+ | |||
+ | < | ||
+ | #concat the 2 series ( regular, reversed ) | ||
+ | bxh_concat bia6_00260_007_LAS.bxh bia6_00260_008_LAS.bxh both | ||
+ | |||
+ | #extract the gradients | ||
+ | extractdiffdirs --fsl both bvecs bvals | ||
+ | |||
+ | #convert to mif | ||
+ | mrconvert -fslgrad bvecs bvals both.nii.gz dwi.mif | ||
+ | |||
+ | #re-extract table | ||
+ | mrinfo dwi.mif -export_grad_mrtrix grads.b | ||
+ | |||
+ | #put corrected table back in | ||
+ | mrconvert -grad grads.b dwi.mif dwi.mif -force | ||
+ | |||
+ | #remove the temporary files ( bvecs, bvals, both.* ) | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Run dwipreproc ==== | ||
+ | |||
+ | Run dwipreproc with the " | ||
+ | |||
+ | < | ||
+ | dwipreproc dwi.mif dwi_corr.mif -rpe_all -pe_dir AP -readout_time 0.10656 -debug | ||
+ | |||
+ | -rpe_all signals that you've replicated ALL the directions with a rpe acquisition | ||
+ | -pe_dir is the phase encode direction of your regular acquisition | ||
+ | -readout_time from above | ||
+ | </ | ||
+ | |||
+ |
biac/analysis/topup_correction.txt · Last modified: 2024/06/21 15:44 by 127.0.0.1