I have a diffusion set collected as part of the myconnectome (Long-term neural and physiological phenotyping of a single human | Nature Communications) acquisition.
The data are 2 full difffusion-sets, one acquired with a R->L phase-encoding, and the other in the opposite direction (L->R). However, dwipreproc
with -rpe_all
doesn’t recognize the matching gradients/volumes across the 2 sets:
I’m running the following code (see myconnectomeDWI/scripts/advpreproc at master · AlistairPerry/myconnectomeDWI · GitHub):
mrcat rawdataRLdn.mif rawdataLRdn.mif allDWIs.mif -axis 3 -force -nthreads $ncpus
dwipreproc -rpe_all -export_grad_mrtrix adjencoding.b -pe_dir RL allDWIs.mif eddycorr.mif -eddy_options " --repol --data_is_shelled --mb=3 --ol_type=both " -nthreads $ncpus -force -tempdir . -nocleanup -debug
Which produces the following error:
dwipreproc: [DEBUG] phaseEncoding.dir() (from dwipreproc:167): rl → [-1, 0, 0]
dwipreproc: [ERROR] Unable to determine matching DWI volume pairs for reversed phase-encode combination
This is very strange as I have embedded the same gradient encoding to the RL
and LR
sets, and manually set the PhaseEncodingDirection:
mrconvert rawdataLR.mif rawdataLRgrad.mif -grad rawencoding.b -set_property PhaseEncodingDirection i -nthreads $ncpus -force
mrconvert rawdataRL.mif rawdataRLgrad.mif -grad rawencoding.b -set_property PhaseEncodingDirection i- -nthreads $ncpus -force
The data were unfortunately extracted as compressed nii's
(.nii.gz), and hence the json files are not embedded.
Checking the image headers nevertheless suggests nothing wrong:
[alistaiP@hpcpbs01 preproc]$ mrinfo rawdataRLdn.mif
Dimensions: 128 x 128 x 78 x 64
Voxel size: 1.74219 x 1.74219 x 1.7 x 5
Data strides: [ 1 2 3 4 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 1 0 0 -109.8
-0 1 0 -120
-0 0 1 -3.101
PhaseEncodingDirection: i-
[alistaiP@hpcpbs01 preproc]$ mrinfo rawdataLRdn.mif
Dimensions: 128 x 128 x 78 x 64
Voxel size: 1.74219 x 1.74219 x 1.7 x 5
Data strides: [ 1 2 3 4 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 1 0 0 -109.8
-0 1 0 -120
-0 0 1 -3.101
PhaseEncodingDirection: i
The dwipreproc
python script (lines 223-235) is looking for the number of matching gradient pairs to equal half the number of volumes in the dwi
series:
elif PE_design == ‘All’:
grad_matchings = [ num_volumes ] * num_volumes
grad_pairs =
for index1 in range(num_volumes):
if grad_matchings[index1] == num_volumes: # As yet unpaired
for index2 in range(index1+1, num_volumes):
if grad_matchings[index2] == num_volumes: # Also as yet unpaired
if grad[index1] == grad[index2]:
grad_matchings[index1] = index2;
grad_matchings[index2] = index1;
grad_pairs.append([index1, index2])
if not len(grad_pairs) == num_volumes/2:
app.error(‘Unable to determine matching DWI volume pairs for reversed phase-encode combination’)