Closed tashrifbillah closed 4 years ago
See issue https://github.com/pnlbwh/multi-shell-dMRIharmonization/issues/13 for details.
@suheyla2 @yrathi , I am sorry that I have to ask you to look at actual code, but I need your feedback on this gist.
A couple of things to note:
(i) b0 volumes in the reconstructed signal are no longer given b0 volumes, rather average of all b0 volumes
(ii) This is the vital block of the program that loads the rish features of a subject and multiplies the signal with them. Finally, it multiples the product with basis B of the spherical harmonics.
shs_same_level= [[0, 1], [1, 6], [6, 15], [15, 28], [28, 45]]
for i in range(0, N_shm+1, 2):
# load data and mask
fileName= os.path.join(directory, 'harm', f'{prefix}_L{i}.nii.gz')
img= load(fileName).get_data()
ind= int(i/2)
for level in range(shs_same_level[ind][0], shs_same_level[ind][1]):
mapped_cs.append(img * shm_coeff[ :,:,:,level])
S_hat= np.dot(np.moveaxis(mapped_cs, 0, -1), B.T)
# keep only upper half of the reconstructed signal
S_hat= S_hat[..., :int(S_hat.shape[3]/2)]
np.nan_to_num(S_hat).clip(min= 0., max= 1., out= S_hat)
Here is the math I broke out:
As you can see in the last line, the reconstructed signal differs from original signal by
For your convenience, you may compare this gist with how signal is reconstructed for harmonized data.
(iii)
You can run the gist by downloading it in to dMRIharmonization/lib
folder and then editing the __main__
section.
Fixed by PR #57
@tashrifbillah mentioned a hack @suheyla2 will give feedback @tashrifbillah may need to engineer this if the hack isn't easy to apply