Dear All/Rob,
Please address the above post if possible, I feel there may be smth wrong with dwipreproc and I am stuck.
Mine is I assume a common diffusion scheme with two sets of opposing PE and same diffusion gradient vectors, concatenated for preprocessing with topup/eddy. As intended, these could be processed with dwipreproc and -rpe_header or -rpe_all options.
If using the command (which I prefer):
dwipreproc -rpe_header predwi_denoised.mif predwi_denoised_preproc.mif
the applytopup command (line 450 in dwipreproc) generates (as it should) a 70-vol image, dwi_post_topup.nii.gz, resulting from the pairing of the corresponding 70+70 vols in the concatenated mif input, predwi_denoised.mif.
However, with the next command,
mrconvert dwi_post_topup.nii.gz -grad grad.b - |
a mismatch between the no of vols in the image, and the grad.b table (140 entries, see the end of the post), is introduced, generating the dwimask mismatch error (1st in my previous post).
If using command:
dwipreproc -rpe_all -pe_dir AP predwi_denoised.mif predwi_denoised_preproc.mif
instead,
grad_pairs output (line 233 in dwipreproc) looks like
[[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [0, 75], [0, 76], [0, 77], [0, 78], [0, 79], [11, 81], [12, 82], [13, 83], [14, 84], [15, 85], [16, 86], [17, 87], [18, 88], [19, 89], [20, 90], [21, 91], [22, 92], [23, 93], [24, 94], [25, 95], [26, 96], [27, 97], [28, 98], [29, 99], [30, 100], [31, 101], [32, 102], [33, 103], [34, 104], [35, 105], [36, 106], [37, 107], [38, 108], [39, 109], [40, 110], [41, 111], [42, 112], [43, 113], [44, 114], [45, 115], [46, 116], [47, 117], [48, 118], [49, 119], [50, 120], [51, 121], [52, 122], [53, 123], [54, 124], [55, 125], [56, 126], [57, 127], [58, 128], [59, 129], [60, 130], [61, 131], [62, 132], [63, 133], [64, 134], [65, 135], [66, 136], [67, 137], [68, 138], [69, 139]]
and len(grad_pairs) = 78, instead of 70 (140/2), hence the error 2 above.
Obviously, the correct grad_pairs should look like
[[0, 70], [1, 71], [2, 72], [3, 73], [4, 74], [5, 75], [6, 76], [7, 77], [8, 78], [9, 79],[10,80], [11, 81], [12, 82], [13, 83], [14, 84], [15, 85], [16, 86], [17, 87], [18, 88], [19, 89], [20, 90], [21, 91], [22, 92], [23, 93], [24, 94], [25, 95], [26, 96], [27, 97], [28, 98], [29, 99], [30, 100], [31, 101], [32, 102], [33, 103], [34, 104], [35, 105], [36, 106], [37, 107], [38, 108], [39, 109], [40, 110], [41, 111], [42, 112], [43, 113], [44, 114], [45, 115], [46, 116], [47, 117], [48, 118], [49, 119], [50, 120], [51, 121], [52, 122], [53, 123], [54, 124], [55, 125], [56, 126], [57, 127], [58, 128], [59, 129], [60, 130], [61, 131], [62, 132], [63, 133], [64, 134], [65, 135], [66, 136], [67, 137], [68, 138], [69, 139]]
So it seems that the -rpe_all option works correctly only if there is only one b=0 image for each DWI set of opposing PE dir.
With the risk of too long of a post (for which I apologize), I attach here the grad.b gradient file generated by dwipreproc via dwgrad. I can also ftp the input .mif (predwi_denoised.mif) if wanting to test it.
Thank you,
Octavian
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0.9999665937 0.005779769848 0.005779769848 700.0000368
0.5875926931 0.3829750433 -0.7127867446 700.0002071
-0.8965316409 0.02854692621 -0.4420589213 700.000186
-0.7297876840999999 -0.4174306552 -0.5414439808 700.0000497
0.1536670776 0.9661813907 0.2070747437 699.9998396
-0.1157393372 0.7788450582999999 0.6164452781999999 699.9999132
-0.4077204677 0.4213358983 -0.8100864652 699.9999392
-0.2101675197 0.7588345748999999 -0.6164411583 699.9999357
0.09406538893999999 0.9714638658 0.2177375944 700.0001645999999
-0.1338656833 0.03835077523 -0.9902571367 700.0001743
0.1414193641 -0.7561122484 0.6389795233 700.0000583999999
0.6349663947999999 0.7495585392 0.1870285373 699.9999454
-0.07897827875000001 0.9735814178 -0.2142467137 699.9998449
0.1053177552 0.02634857879 0.9940894944000001 700.0000642
-0.2985741736 0.3936984116 -0.8693992314 700.0000299
-0.2061008557 0.8080201324 0.5519292553 699.9999612
0.330717313 0.04518756768 -0.9426474116 700.0000719
-0.8023465825 0.5941747345 -0.05653623948 700.000013
-0.3362168467 -0.7549717477 0.563006121 700.0000970999999
0.5904156618 0.7653146424 0.2563256608 699.9999956
-0.08771089305 0.4718639226 0.8772976904999999 700.0001109
-0.5275911142 0.4379350937 0.727915153 700.0001481
-0.3670493312 0.9283692136 0.05835573337 699.9999191000001
-0.310691844 0.9285377328 0.2031951203 700.0003426
0.6850654949 0.4457889702 0.5761574973 700.0000308
-0.02947340731 0.9686296317 -0.2467548475 700.0001276
0.3364008703 0.7499107038 0.5696212697 700.0001237
0.5762407491 0.02994827839 0.8167311061 700.0000752
0.2700293981 0.7533021311 0.5996832692 700.0001652
-0.935704635 -0.1912383069 0.2964536152 700.0000224
-0.8889692825 0.3163268711 0.3311660088 700.0002165
-0.8863728578 -0.03891974464 -0.4613332964 700.000193
-0.5446834922 0.592151255 0.5938659651 699.9999172
-0.3514880656 0.02077607915 0.9359618017 700.0000573
0.4139362044 0.9025600041 -0.1185000327 700.0000867
-0.7348035679 -0.008301839411 0.6782291619 700.0000993
-0.7375225303 -0.6167724619 0.2750495364 700.0000183
0.256068723 0.4135049094 0.8737519666 699.9997652
0.9173711924 0.3788423623 0.1221006136 699.9998437
-0.2561567026 -0.7709836178 0.5830677532 700.0000403
0.5895746762 0.4405645371 -0.6769819716 699.999914
-0.8920502727 -0.1924893606 0.4088938212 699.9999958
-0.6804012780000001 0.1484654387 0.7176434452 700.000107
-0.8800430634 0.3162582104 0.3542667793 700.0000423
-0.6197260936 0.7022418021 0.3504226311 700.0001953
-0.8948303882999999 -0.4363450894 -0.09424191772 700.0000338999999
0.1627313891 0.4241828577 -0.8908352251 700.0000077
-0.5060559555 0.7822293085000001 -0.363352004 699.9999847
-0.10541933 -0.4534475631 0.8850265942 699.9998669
-0.8818681135999999 0.4412505868 -0.1661521888 700.0000101000001
-0.5996046607 0.03527683298 -0.7995184776000001 699.9998816999999
-0.6934537158 0.7024538956 0.1602512667 700.0000286
0.3922631547 0.9029053048 -0.1757601432 700.0000545
-0.7614106176 0.4093902526 -0.5026464886000001 700.0000596
-0.2101465957 0.40228334 0.8910704364000001 699.9998955999999
0.3756599196 0.3857284298 0.8426702815 699.9999643
-0.7343735380999999 -0.6164237728 0.2841077944 700.0001751999999
-0.9866537536 0.1519988129 -0.05840146725 700.0000658
-0.5268015073 0.8112047227 -0.2538248802 700.0002197
0.6632603418 -0.4789704279 0.5750417795 700.0001229
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0.9999665937 -0.005779769848 0.005779769848 700.0000368
0.5875926931 0.3829750433 -0.7127867446 700.0002071
-0.8965316409 0.02854692621 -0.4420589213 700.000186
-0.7297876840999999 -0.4174306552 -0.5414439808 700.0000497
0.1536670776 0.9661813907 0.2070747437 699.9998396
-0.1157393372 0.7788450582999999 0.6164452781999999 699.9999132
-0.4077204677 0.4213358983 -0.8100864652 699.9999392
-0.2101675197 0.7588345748999999 -0.6164411583 699.9999357
0.09406538893999999 0.9714638658 0.2177375944 700.0001645999999
-0.1338656833 0.03835077523 -0.9902571367 700.0001743
0.1414193641 -0.7561122484 0.6389795233 700.0000583999999
0.6349663947999999 0.7495585392 0.1870285373 699.9999454
-0.07897827875000001 0.9735814178 -0.2142467137 699.9998449
0.1053177552 0.02634857879 0.9940894944000001 700.0000642
-0.2985741736 0.3936984116 -0.8693992314 700.0000299
-0.2061008557 0.8080201324 0.5519292553 699.9999612
0.330717313 0.04518756768 -0.9426474116 700.0000719
-0.8023465825 0.5941747345 -0.05653623948 700.000013
-0.3362168467 -0.7549717477 0.563006121 700.0000970999999
0.5904156618 0.7653146424 0.2563256608 699.9999956
-0.08771089305 0.4718639226 0.8772976904999999 700.0001109
-0.5275911142 0.4379350937 0.727915153 700.0001481
-0.3670493312 0.9283692136 0.05835573337 699.9999191000001
-0.310691844 0.9285377328 0.2031951203 700.0003426
0.6850654949 0.4457889702 0.5761574973 700.0000308
-0.02947340731 0.9686296317 -0.2467548475 700.0001276
0.3364008703 0.7499107038 0.5696212697 700.0001237
0.5762407491 0.02994827839 0.8167311061 700.0000752
0.2700293981 0.7533021311 0.5996832692 700.0001652
-0.935704635 -0.1912383069 0.2964536152 700.0000224
-0.8889692825 0.3163268711 0.3311660088 700.0002165
-0.8863728578 -0.03891974464 -0.4613332964 700.000193
-0.5446834922 0.592151255 0.5938659651 699.9999172
-0.3514880656 0.02077607915 0.9359618017 700.0000573
0.4139362044 0.9025600041 -0.1185000327 700.0000867
-0.7348035679 -0.008301839411 0.6782291619 700.0000993
-0.7375225303 -0.6167724619 0.2750495364 700.0000183
0.256068723 0.4135049094 0.8737519666 699.9997652
0.9173711924 0.3788423623 0.1221006136 699.9998437
-0.2561567026 -0.7709836178 0.5830677532 700.0000403
0.5895746762 0.4405645371 -0.6769819716 699.999914
-0.8920502727 -0.1924893606 0.4088938212 699.9999958
-0.6804012780000001 0.1484654387 0.7176434452 700.000107
-0.8800430634 0.3162582104 0.3542667793 700.0000423
-0.6197260936 0.7022418021 0.3504226311 700.0001953
-0.8948303882999999 -0.4363450894 -0.09424191772 700.0000338999999
0.1627313891 0.4241828577 -0.8908352251 700.0000077
-0.5060559555 0.7822293085000001 -0.363352004 699.9999847
-0.10541933 -0.4534475631 0.8850265942 699.9998669
-0.8818681135999999 0.4412505868 -0.1661521888 700.0000101000001
-0.5996046607 0.03527683298 -0.7995184776000001 699.9998816999999
-0.6934537158 0.7024538956 0.1602512667 700.0000286
0.3922631547 0.9029053048 -0.1757601432 700.0000545
-0.7614106176 0.4093902526 -0.5026464886000001 700.0000596
-0.2101465957 0.40228334 0.8910704364000001 699.9998955999999
0.3756599196 0.3857284298 0.8426702815 699.9999643
-0.7343735380999999 -0.6164237728 0.2841077944 700.0001751999999
-0.9866537536 0.1519988129 -0.05840146725 700.0000658
-0.5268015073 0.8112047227 -0.2538248802 700.0002197
0.6632603418 -0.4789704279 0.5750417795 700.0001229