Best pipeline to compute FA give dwi.mif

Hi there,

I would like to know the best pipeline to compute the Fractional Anisotropy (FA) values from a DWI (Diffusion-Weighted Imaging) dataset using MRtrix3,

I have found this:

Step 1: Denoise and preprocess DWI data (if needed)

Example: Denoising using dwidenoise

dwidenoise input_dwi.mif denoised_dwi.mif

Step 2: Estimate the diffusion tensor

Example: Using dwi2tensor

dwi2tensor denoised_dwi.mif dt.mif

Step 3: Compute FA from the diffusion tensor

Example: Using tensor2metric

tensor2metric -fa dt.mif fa.mif

Does is correct?

Have a nice day,

Aldo

Hi @Aldo_Camargo,

There are some missings steps in the pipeline, a most complete and accurate one would be:

  • denoise: dwidenoise input_dwi.mif denoised_dwi.mif
  • remove gibbs ring artifacts: mrdegibbs denoised_dwi.mif denoised_unr_dwi.mif
  • corrections for eddy current and head movement (and EPI geometric distortions if data permits): dwifslpreproc denoised_unr_dwi.mif denoised_unr_eddy_dwi.mif -rpe_none -pe_dir ap -readout_time 0.55. For the purpose of this example I just assumed that your data has been acquired with a single phase encoding in the AP direction with a readout time of 0.55.
  • estimate tensor: dwi2tensor denoised_unr_eddy_dwi.mif dt.mif
  • Create FA map: tensor2metric -fa dt.mif fa.mif

I hope this helps.

Best regards,

Manuel

Hi Manuel:

I used the commands you sent me but I am getting this in the second step:

dwifslpreproc denoised_unr_dwi.mif denoised_unr_eddy_dwi.mif -rpe_none -pe_dir ap -readout_time 0.0380995
dwifslpreproc:
dwifslpreproc: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwifslpreproc:
dwifslpreproc: Generated scratch directory: /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-69P98N/
Command: mrconvert /home/acamargofb/test_mrtrix3/test_subj4/denoised_unr_dwi.mif /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-69P98N/dwi.mif -json_export /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-69P98N/dwi.json
dwifslpreproc: Changing to scratch directory (/home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-69P98N/)
Command: dirstat dwi.mif -output asym
dwifslpreproc: [WARNING] sampling of b=200 shell is strongly asymmetric; distortion correction may benefit from use of: -eddy_options " … --slm=linear … "
dwifslpreproc: [WARNING] sampling of b=410 shell is strongly asymmetric; distortion correction may benefit from use of: -eddy_options " … --slm=linear … "
dwifslpreproc: [WARNING] sampling of b=1000 shell is strongly asymmetric; distortion correction may benefit from use of: -eddy_options " … --slm=linear … "
Command: mrinfo dwi.mif -export_grad_mrtrix grad.b
Command: dwi2mask dwi.mif - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3
Command: mrconvert dwi.mif -import_pe_table dwi_manual_pe_scheme.txt eddy_in.nii -strides -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt
Command: eddy_cuda10.2 --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --out=dwi_post_eddy --verbose
dwifslpreproc: CUDA version of ‘eddy’ was not successful; attempting OpenMP version
Command: eddy_cpu --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --out=dwi_post_eddy --verbose

dwifslpreproc: [ERROR] eddy* --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --out=dwi_post_eddy --verbose (app.py:199)
dwifslpreproc: [ERROR] Information from failed command:
dwifslpreproc:
=============
eddy_cuda10.2
=============

           Warning: In a future release the first argument will have to be "diffusion" when using eddy on diffusion data, i.e.
           eddy diffusion --imain='my_ima' --acqp='my_acqp' ...

           Warning: Writing of individual text files will be discontinued in favour of a single .json file in future versions

           Reading images
           EDDY::ECScanManager::GetShellIndicies: Data not shelled
           EDDY::ECScanClasses.cpp:::  std::vector<std::vector<unsigned int> > EDDY::ECScanManager::GetShellIndicies(std::vector<double>&) const:  Exception thrown
           EDDY::: Eddy failed with message EDDY::ECScanClasses.cpp:::  EDDY::ECScanManager::ECScanManager(const string&, const string&, const string&, const string&, const string&, const string&, const string&, const string&, const string&, double, double, EDDY::ECModelType, EDDY::ECModelType, EDDY::LongECModelType, const std::vector<unsigned int>&, const std::vector<unsigned int>&, const EDDY::PolationPara&, EDDY::MultiBandGroups, bool):  Exception thrown


           ========
           eddy_cpu
           ========

           Warning: In a future release the first argument will have to be "diffusion" when using eddy on diffusion data, i.e.
           eddy diffusion --imain='my_ima' --acqp='my_acqp' ...

           Warning: Writing of individual text files will be discontinued in favour of a single .json file in future versions

           Reading images
           EDDY::ECScanManager::GetShellIndicies: Data not shelled
           EDDY::ECScanClasses.cpp:::  std::vector<std::vector<unsigned int> > EDDY::ECScanManager::GetShellIndicies(std::vector<double>&) const:  Exception thrown
           EDDY::: Eddy failed with message EDDY::ECScanClasses.cpp:::  EDDY::ECScanManager::ECScanManager(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, double, double, EDDY::ECModelType, EDDY::ECModelType, EDDY::LongECModelType, const std::vector<unsigned int>&, const std::vector<unsigned int>&, const EDDY::PolationPara&, EDDY::MultiBandGroups, bool):  Exception thrown


           =============
           eddy_cuda10.2
           =============


           ========
           eddy_cpu
           ========

dwifslpreproc:
dwifslpreproc: [ERROR] For debugging, inspect contents of scratch directory: /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-69P98N/

==============================================================

Hi,

try the following command:

dwifslpreproc denoised_unr_dwi.mif denoised_unr_eddy_dwi.mif -rpe_none -pe_dir ap -readout_time 0.0380995 -eddy_options " --data_is_shelled --slm=linear"

One quickquestion, I see the values you have are 200, 410 and 1000. Can you confirm those are correct? and how many directions for each value?

Best regards,

Manuel

Hi Manuel:

Thanks a lot for the quick answer. Now I have a different error:

~/test_mrtrix3/test_subj4$ dwifslpreproc denoised_unr_dwi.mif denoised_unr_eddy_dwi.mif -rpe_none -pe_dir ap -readout_time 0.0380995 -eddy_options " --data_is_shelled --slm=linear"
dwifslpreproc:
dwifslpreproc: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwifslpreproc:
dwifslpreproc: Generated scratch directory: /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-35HGP5/
Command: mrconvert /home/acamargofb/test_mrtrix3/test_subj4/denoised_unr_dwi.mif /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-35HGP5/dwi.mif -json_export /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-35HGP5/dwi.json
dwifslpreproc: Changing to scratch directory (/home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-35HGP5/)
Command: mrinfo dwi.mif -export_grad_mrtrix grad.b
Command: dwi2mask dwi.mif - | maskfilter - dilate - | mrconvert - eddy_mask.nii -datatype float32 -strides -1,+2,+3
Command: mrconvert dwi.mif -import_pe_table dwi_manual_pe_scheme.txt eddy_in.nii -strides -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt
Command: eddy_cuda10.2 --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --data_is_shelled --slm=linear --out=dwi_post_eddy --verbose
dwifslpreproc: CUDA version of ‘eddy’ was not successful; attempting OpenMP version
Command: eddy_cpu --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --data_is_shelled --slm=linear --out=dwi_post_eddy --verbose

dwifslpreproc: [ERROR] eddy* --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --data_is_shelled --slm=linear --out=dwi_post_eddy --verbose (app.py:199)
dwifslpreproc: [ERROR] Information from failed command:
dwifslpreproc:
=============
eddy_cuda10.2
=============

           Warning: In a future release the first argument will have to be "diffusion" when using eddy on diffusion data, i.e.
           eddy diffusion --imain='my_ima' --acqp='my_acqp' ...

           Warning: Writing of individual text files will be discontinued in favour of a single .json file in future versions

           Reading images
           Performing volume-to-volume registration
           Running Register

           ...................Allocated GPU # 0...................
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 0, Total mss = 49.4501
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 1, Total mss = 13.9903
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 2, Total mss = 10.6561
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 3, Total mss = 10.4602
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 4, Total mss = 10.3016
           Running sm.ApplyB0LocationReference
           Running sm.PolateB0MovPar
           Running Register
           Loading prediction maker
           Evaluating prediction maker model
           Checking for outliers
           EDDY::ReplacementManager::Update: Mismatched DiffStatsVector object
           EDDY::EddyHelperClasses.cpp:::  void EDDY::ReplacementManager::Update(const EDDY::DiffStatsVector&):  Exception thrown
           EDDY::cuda/EddyInternalGpuUtils.cu:::  static void EDDY::EddyInternalGpuUtils::detect_outliers(const EDDY::EddyCommandLineOptions&, EDDY::ScanType, std::shared_ptr<EDDY::DWIPredictionMaker>, const NEWIMAGE::volume<float>&, const EDDY::ECScanManager&, unsigned int, unsigned int, EDDY::ReplacementManager&, EDDY::DiffStatsVector&):  Exception thrown
           EDDY::cuda/EddyGpuUtils.cu:::  static EDDY::DiffStatsVector EDDY::EddyGpuUtils::DetectOutliers(const EDDY::EddyCommandLineOptions&, EDDY::ScanType, std::shared_ptr<EDDY::DWIPredictionMaker>, const NEWIMAGE::volume<float>&, const EDDY::ECScanManager&, EDDY::ReplacementManager&):  Exception thrown
           EDDY::eddy.cpp:::  EDDY::ReplacementManager* EDDY::Register(const EDDY::EddyCommandLineOptions&, EDDY::ScanType, unsigned int, const std::vector<float, std::allocator<float> >&, EDDY::SecondLevelECModelType, bool, EDDY::ECScanManager&, EDDY::ReplacementManager*, NEWMAT::Matrix&, NEWMAT::Matrix&):  Exception thrown
           EDDY::: Eddy failed with message EDDY::eddy.cpp:::  EDDY::ReplacementManager* EDDY::DoVolumeToVolumeRegistration(const EDDY::EddyCommandLineOptions&, EDDY::ECScanManager&):  Exception thrown


           ========
           eddy_cpu
           ========

           Warning: In a future release the first argument will have to be "diffusion" when using eddy on diffusion data, i.e.
           eddy diffusion --imain='my_ima' --acqp='my_acqp' ...

           Warning: Writing of individual text files will be discontinued in favour of a single .json file in future versions

           Reading images
           Performing volume-to-volume registration
           Running Register
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 0, Total mss = 49.2589
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 1, Total mss = 14.8748
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 2, Total mss = 10.6767
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 3, Total mss = 10.4759
           Loading prediction maker
           Evaluating prediction maker model
           Calculating parameter updates
           Iter: 4, Total mss = 10.3121
           Running sm.ApplyB0LocationReference
           Running sm.PolateB0MovPar
           Running Register
           Loading prediction maker
           Evaluating prediction maker model
           Estimated hyperparameters: -17.028348
           30.274817
           -2.281406
           37.262752
           -17.433979
           -51.557487
           -39.567056
           -16.544664
           73.096892
           105.154341

           EDDY::ReplacementManager::Update: Mismatched DiffStatsVector object
           EDDY::EddyHelperClasses.cpp:::  void EDDY::ReplacementManager::Update(const EDDY::DiffStatsVector&):  Exception thrown
           EDDY::eddy.cpp:::  EDDY::DiffStatsVector EDDY::detect_outliers(const EddyCommandLineOptions&, ScanType, std::shared_ptr<const DWIPredictionMaker>, const NEWIMAGE::volume<float>&, const ECScanManager&, unsigned int, unsigned int, ReplacementManager&):  Exception thrown
           EDDY::eddy.cpp:::  EDDY::DiffStatsVector EDDY::DetectOutliers(const EddyCommandLineOptions&, ScanType, std::shared_ptr<const DWIPredictionMaker>, const NEWIMAGE::volume<float>&, const ECScanManager&, ReplacementManager&):  Exception thrown
           EDDY::eddy.cpp:::  EDDY::ReplacementManager* EDDY::Register(const EddyCommandLineOptions&, ScanType, unsigned int, const std::vector<float, std::allocator<float> >&, SecondLevelECModelType, bool, ECScanManager&, ReplacementManager*, NEWMAT::Matrix&, NEWMAT::Matrix&):  Exception thrown
           EDDY::: Eddy failed with message EDDY::eddy.cpp:::  EDDY::ReplacementManager* EDDY::DoVolumeToVolumeRegistration(const EddyCommandLineOptions&, ECScanManager&):  Exception thrown


           =============
           eddy_cuda10.2
           =============


           ========
           eddy_cpu
           ========

dwifslpreproc:
dwifslpreproc: [ERROR] For debugging, inspect contents of scratch directory: /home/acamargofb/test_mrtrix3/test_subj4/dwifslpreproc-tmp-35HGP5/

==================================================

Hi Manuel:

The values that I have for bvals are:
0 0 0 0 0 0 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 350 0 1000 1000 1000 1000 0 650 650 650 650 650 650 0 350 600 350 400 450 350 400 500 400 400 0 450 350 400 500 450 400 550 400 500 350 0 250 250 250 250 250 250 0 200 200 200 200 200 200 0 150 150 150 150 150 150 0 0 0 0 0 0 0 0 0 0 0

and for bvec:
-0 -0 -0 -0 -0 -0 0.980105489846427 0.328547842788395 0.0614116782396859 0.82038361180978 0.339822007599472 0.905246580899128 -0.647216990810299 -0.692757184406279 -0.897170359742313 -0.542028995371543 0.205405906729763 0.513171124769874 0.651689124244341 0.541236917045882 -0.238712993643805 0.675833908228523 0.659677228629795 0.262228017045577 -0.120836980967841 -0.33935714762429 -0.480362070451523 -0.577352949804822 -0.783906442629846 -0.250576999298605 0.204969031415547 -0.10436102343036 0.898644958363478 -0.097135217927444 0.275730072149536 0.93284926469101 -0 -0.612122768862746 0.520971808347541 -0.414791880254223 0.717608982253733 -0 0.811918118407105 -0.0533575982809114 -0.629710726737728 -0.571097735900934 0.184466926326083 0.760496902163043 -0 0.93389661747462 0.51808995514412 0.0258520084980697 0.97679789300855 -0.426665801405056 -0.985955637812996 0.484057895025748 -0.334216822588869 -0.420604080455578 0.54851433233071 -0 -0.764502545575558 -0.0671488022794986 -0.85879717861969 0.221631916558835 -0.29145289395397 0.162968024407793 -0.8193850607588 0.0593689930851633 0.763312910568777 0.164215996989712 -0 0.890242883196794 0.523918091076279 -0.524903772208842 -0.075841715907884 0.0735733137710951 -0.797907088658973 -0 -0.562128091394615 0.949201042419154 0.457181076833572 0.164570062317337 -0.697816849244215 -0.233540908079131 -0 0.324139858159975 0.926261950253712 -0.680844290003678 0.286560120139935 -0.697292901154419 0.0669851152512792 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0
0 0 0 0 0 0 -0.188396901937463 0.935214552502319 -0.587871791428527 -0.564354733010387 0.654885014700084 0.287075867070129 -0.167410997650151 -0.665772177249132 -0.0568005227606872 0.83120999283783 -0.95260756729403 -0.501639121976354 0.388067073949329 -0.75344088451731 0.161805995692423 0.714398902920601 -0.0875405303374098 -0.162052010513628 -0.844228867060251 0.779055338983436 -0.589865086528528 0.349650969601156 0.496649646901265 -0.279418999264434 0.285374043702258 0.976300218958224 -0.200091990733188 0.587303108636082 0.892556233547719 0.347539098586723 0 -0.396523850204618 -0.604420777592941 0.738953786728651 0.531278986887053 0 0.567401082741314 -0.612841980334379 0.215765906358493 0.820007620806487 0.77782568934764 -0.0484445937630878 0 -0.32751986588381 0.740497935791551 0.0426552140319963 0.0671972926849543 -0.0524089755802839 -0.0870867679866422 0.163948964448983 0.478925745761064 -0.796263152440513 0.836130506572008 0 0.621860630353623 -0.967593032932332 0.240925050109116 -0.804732696995689 0.956044652029395 0.510963076547957 -0.363835026979126 -0.320556962595007 -0.456862946507527 0.980480982019446 0 -0.450967940811145 0.190471033151678 0.0952467586875309 0.924698194384933 -0.757630141655892 -0.596577066297892 0 -0.336117054662074 0.241461010800507 -0.577830097162218 0.428074161993384 0.637575862296088 -0.972287617297903 0 0.712976688058491 -0.132176992902823 0.402291171370158 -0.942978395284141 -0.635408909881789 -0.271349061699917 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -0.0624486674950247 -0.132022936827452 0.806619713792659 0.0920568564875653 0.6750160150949 0.313234854984103 0.74369598940369 0.277191073756845 0.438017175654793 0.123670998951865 0.224381898031395 0.696429169349667 0.651694124218687 0.373348942782007 0.95751497451031 0.181335975374036 0.746433258651089 0.95130206193008 0.522183917825502 0.527171229353124 0.649085095227409 0.737839935773392 0.372598735131327 0.926895997557646 0.936242143541466 0.189596042514695 0.390384981866879 0.803517148604437 0.356814093380687 -0.0949148269280058 0 0.68415974164533 0.602713778267639 0.530937846796391 0.450310988866214 0 -0.137277020018853 0.788401974793322 0.746263676084889 -0.037879782483965 0.600798760048288 0.647531916730497 0 0.143414941209823 0.428071962911265 0.998755328555254 0.203347977706812 0.902889579681486 0.142503947651948 0.859539813692892 0.811744569100706 0.434807083260258 -0.0042193825102117 0 0.169779899064947 0.243423008300572 0.452131094064902 0.55071279266981 0.0321532882753711 0.844013126358184 0.442981032859236 0.945366889808166 0.456759946470519 0.108120997989902 0 -0.0639962916050293 -0.830199144359204 -0.845815632885161 -0.373070078475738 -0.648524121345088 -0.0862559096198796 0 -0.755670122800848 -0.201777009013633 -0.676090113635018 -0.888633336307415 -0.326417929506708 0.0107439957507443 0 -0.621769727987012 -0.352941981098989 -0.61205626071 -0.169337070953597 -0.33171995297768 -0.960147218416538 0 0 0 0 0 0 0 0 0 0 0

Hi,

The bvalues seem very low, I find that a little bit strange, I’m not used to this kind of data. Maybe eddy fails for this reason, could you try to post the message to the fsl forum and see what they reply. Best of luck.

Best regards,

Manuel

Hi Manuel.

I am running in a different computer (more powerfull) and so far I don’t see any error. but is taking too much time ( 4hours now and is not finished yet). One question, how much time in avarage take to run eddy_cpu on one subject?

Thanks a lot,

Aldo Camargo

Hi,

I can’t answer to that, it relly depends of a lot of factors going from the computer itself to the nature of the data. Maybe somebody in the fsl forum will be able to provide you better guidance with eddy.

Best regards,

Manuel

Hi Manuel:

I think that the problem is the amount of bvals and bvects I have in my data. I was wondering if I can reduce it. If so, how can I do it?

Thanks a lot in advance for your help, have a nice day,

Aldo

Hi,

The amount shouldn’t be a problem if they are distributed in shells.

If you want to reduce them you can use dwiextract with the option -shells

Best regards,

Manuel