Visualization of ODF alternatives:

The visualization with ODFs in mrview is nice, but suppose that I would like a bit more control over the plotting of the ‘glyphs’(?) for publications/presentations etc., how would I go about that?

Getting the coefficients out in .nii or .mif is no problem, but I don’t immediately see a way for getting out the corresponding basis functions, or am I missing something?

Thanks,
Martin

Could you be a bit more specific about what you’re trying to do? What do you need extra control for that can’t already be done?

To visualise the basis functions, the simplest would be to use shview. Just create a text file with e.g. 28 zeros (for lmax=6), pick one of the those coefficients and replace it with a 1, then display that using shview. I think that’s what you’re after?

I would like to generate and save glyphs as 3D models (say .ply).

I suppose the most convenient way would be to generate the SH basis functions Y_lm(θ,ϕ). So getting the correct number of basis functions and with the desired angular resolution.

A possible workaround would be to use sh2amp?

Ah, OK.

Hacking sh2amp may sound like the simplest workaround, but it’s designed to operate on entire images, and won’t generate the mesh for you. It depends on how deep you want to go into the code, but assuming you already have the vector of SH coefficients you’re interested in plotting, you could just duplicate or adapt the functionality in my old Matlab demo code (starting with plot_SH.m and eval_SH.m). I’m pretty sure the convention used there is the same as in the main MRtrix code – though I recommend you verify that, this is very old code…

Otherwise, you could adapt the C++ code in the viewer to grab the geometry of whatever is currently displayed. It’s a lot more involved, but I’ve just pushed a branch that should get you 90% of the way there. Currently, it’s only active in shview, and you’d trigger the dump of the vertices and indices to stderr by using the screenshot menu entry. This is just to get started, it would take a bit more work to format that output as an actual PLY, and then to offer the functionality as a standalone button in shview, and expose that functionality within mrview through the ‘inspect ODF at focus’ pop-up window. But it all uses the same code, so it’s just a matter of adding buttons and callbacks in the right places. I’ll leave that as an exercise for the interested user…

Thank you for the response,
I have now managed to find some time to play with this.

Getting it to work with sh2amp was relatively straightforward, but certainly not the most computational/coding elegant way. I’ll have to re-visit and test your matlab code at some other point, but I have the functionality I need for now :slight_smile: