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/21 15:54] – [Now apply the correction to your DWI] cmp12 | biac:analysis:topup_correction [2021/08/24 16:04] – 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 ETL for the parameter file will be: | + | the readout time in seconds |
- | < | + | < |
+ | |||
+ | echospacing | ||
+ | </ | ||
+ | |||
+ | unfortunately at this point the polarity of the images will have to be determined from visual inspection. we aren't provided enough information in the metadata to give an entry into the BXH file ( yet ). | ||
+ | |||
+ | Here is a rough guide to help with inspection. | ||
+ | {{: | ||
- | the polarity for the entry will have to be determined from the **seriesdescription**, | ||
reverse will be " | reverse will be " | ||
< | < | ||
- | 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 58: | Line 65: | ||
applytopup --imain=../ | applytopup --imain=../ | ||
applytopup --imain=../ | applytopup --imain=../ | ||
+ | </ | ||
+ | |||
+ | If you have the scenario where the functional data was acquired with acceleration, | ||
+ | |||
+ | < | ||
+ | echospacing in the BXH header is in microseconds | ||
</ | </ | ||
Line 78: | Line 91: | ||
--------------- | --------------- | ||
- | ====== 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 119: | Line 135: | ||
< | < | ||
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 147: | Line 164: | ||
**inindex** references the " | **inindex** references the " | ||
- | ms.txt file | + | ms. |
+ | txt file | ||
< | < | ||
Line 159: | Line 177: | ||
< | < | ||
- | fslwrapbxh dwi_corrected..nii.gz | + | fslwrapbxh dwi_corrected.nii.gz |
mv dwi_corrected.bxh tmp.bxh | mv dwi_corrected.bxh tmp.bxh | ||
bxh_addgradients --fsl tmp.bxh bvecs bvals dwi_corrected.bxh | bxh_addgradients --fsl tmp.bxh bvecs bvals dwi_corrected.bxh | ||
rm tmp.bxh | rm tmp.bxh | ||
</ | </ | ||
+ | |||
+ | |||
+ | --------------- | ||
+ | |||
+ | ====== DWI Correction with MRTRIX3 and RPE Data ====== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | If you are running dwidenoise, do it BEFORE dwipreproc. | ||
+ | |||
+ | ==== Calculate your readout time ==== | ||
+ | < | ||
+ | |||
+ | echospacing in BXH header is in microseconds | ||
+ | </ | ||
+ | |||
+ | ==== Prepare your input datasets ==== | ||
+ | |||
+ | there are 2 scenarios that typically apply here | ||
+ | 1) DWI and a short acquisition with RPE B0s | ||
+ | 2) 2 entire acquisitions 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 ===== | ||
+ | |||
+ | ==== Prepare your input datasets ==== | ||
+ | |||
+ | Specify that a set of images (typically b=0 volumes) will be provided for use in inhomogeneity field estimation only | ||
+ | |||
+ | 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 | ||
+ | rm bu.* bd.* | ||
+ | </ | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | < | ||
+ | dwifslpreproc 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_00 | ||
+ | 7_LAS.bxh bia6_00260_008_LAS.bxh both | ||
+ | |||
+ | #extract the gradients | ||
+ | extractdiffdirs --fsl both.bxh 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 -rpe_all ==== | ||
+ | |||
+ | 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