New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualization problem with tensors ? #1396

Closed
carpre opened this Issue Jan 4, 2018 · 1 comment

Comments

Projects
2 participants
@carpre
Copy link

carpre commented Jan 4, 2018

Hi,

I did an experiment with 2 gradient tables. The second gradient table is the same than the first but with x and y flipped (-x and -y).

I computed the tensors and tried to plot 3 slices (coronal, axial and sagittal) using vtk as shown in the examples.

I can see that I get different eigen vectors for the 2 gradient tables when I print them.
Original evec [[[-0.71158536 0.21049986 0.67032535]
[ 0.69739829 0.09573807 0.71026041]
[ 0.08533406 0.97289467 -0.21492805]]]
Flipped evec [[[-0.71158536 -0.21049986 0.67032535]
[ 0.69739829 -0.09573807 0.71026041]
[-0.08533406 0.97289467 0.21492805]]]
However, I get the exact same tensors for the 3 planes when plotting the same slices.

I am not sure to understand how I can get the same tensors oriented the same way when my evecs are not in the same direction ? If I would have a flip in the 3 axes, it would obviously be the same direction, but not if only 2 out of 3 are flipped ? I did the same processing with MRtrix and there is a clear flip in sagittal when I plot the tensors with mrview.

I assume it's the way I am plotting my tensors, but I can't figure out what's wrong.
This is how I am doing it:
tenmodel = TensorModel(gtab)
tenfit = tenmodel.fit(data)
RGB = color_fa(tenfit.fa, tenfit.evecs)
sphere = get_sphere('symmetric724')
ren = fvtk.ren()
fvtk.add(ren, fvtk.tensor(tenfit.evals[:,:28], tenfit.evecs[:,:28], RGB[:,:28]/RGB[:,:,28].max(), sphere))
fvtk.record(ren, n_frames=1, out_path='out.png', size=(1000, 1000))

For the other planes, I am making sure to give it as a NxMx1x3 or NXMx1x3x3 like so:
evals = tenfit.evals[:, 40:41, :].squeeze()
evecs = tenfit.evecs[:, 40:41, :].squeeze()
rgb = (RGB[:, 40:41, :]/RGB[:, 40:41, :].max()).squeeze()
ren = fvtk.ren()
fvtk.add(ren, fvtk.tensor(evals[:, :, np.newaxis, :], evecs[:, :, np.newaxis, :, :], rgb[:, :, np.newaxis, :], sphere))

Doing that, the tensors look exactly the same in the 3 planes, even though the gradients are suppose to be flipped in x and y and that the evecs are not the same (some signs are different). Any idea what I am doing wrong ?

Also, is there a way to put the corresponding FA slice under the tensors so it's easier to look at ? I tried adding an actor using vtk.add(ren, fvtk.slicer(fa[:, :, 28])) before the tensors, but the FA is not at the right place under the tensors.

Thank you very much for your help :)

@carpre carpre changed the title Different gradients gives the same tensors ? Visualization problem with tensors ? Jan 5, 2018

@dmreagan dmreagan added this to Issues in Viz Module Jan 29, 2018

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented Sep 20, 2018

This issue was moved to fury-gl/fury#12

@skoudoro skoudoro closed this Sep 20, 2018

@skoudoro skoudoro moved this from Issues to Done in Viz Module Oct 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment