pnlbwh / dMRIharmonization

Multi-site dMRI harmonization
Other
43 stars 14 forks source link

b-values near 0 being remapped to `bNew` #71

Closed kcho closed 3 years ago

kcho commented 3 years ago

Hi Tashrif,

Some diffusion data has very low b-value, eg. 5, 0.1, 4 etc., for their b0 bvalue.

In remapBval function in lib/bvalMap.py,

Below is the test-simulation snippet

import dipy.io
import numpy as np

bvals = np.array([800, 800, 4, 0])
print(f'Bvalue :{bvals.astype(int)}')
bNew = 1000

# part of remapBval in dMRIharmonization/lib/bvalMap.py
ratio= []
bvalsNew= []
for b in bvals:
    if b:
        bvalsNew.append(bNew)
        if (b > 1.01*bNew or b < 0.99*bNew):
            print(f'\tbvalue to remap: {b}')
            ratio.append(bNew / b)
        else:
            ratio.append(1.)
    else:
        ratio.append(1.)
        bvalsNew.append(0)

ratio= np.reshape(ratio, (1, len(bvals)))

print(f'Ratio : {ratio.astype(int)}')
print(f'New bvalue: {bvalsNew}')

which returns incorrect new bvalues.

Bvalue :[800 800   4   0]
    bvalue to remap: 800
    bvalue to remap: 800
    bvalue to remap: 4
Ratio : [[  1   1 250   1]]
New bvalue: [1000, 1000, 1000, 0]

Maybe we should do something like below to bypass b0 indices, using the information stored in where_b0

for index, b in enumerate(bvals):
    if index not in where_b0:

to the line https://github.com/pnlbwh/dMRIharmonization/blob/58405565c0b076bd519ddca112d7a1da64c5beef/lib/bvalMap.py#L31-L32

Thanks!

tashrifbillah commented 3 years ago

Thank you for your contribution. We were made aware of this issue in the past and I am pretty confident that I fixed it. Now that I am thinking about it, the fix may have been in a different branch.

Regardless, I have fixed it here again. The fix is deployed across PNL platforms. Similar fix in multi-shell software to follow soon.

tashrifbillah commented 3 years ago

Similar fix in multi-shell software to follow soon.

Done