Handling of voxelized diffusion tensor imaging data

Dear NGSolve team,

We have voxelized diffusion tensor imaging (DTI) data that we want to use in a CoefficientFunction as material properties.
We already used the VoxelCoefficient function to load voxelized MRI data (i.e., only one scalar value per voxel).
However, we could not figure out what the best way is to load tensor data (i.e., one tensor per voxel).
Could you please suggest us a good solution or share your experience?
We thought about loading the tensor component-wise into a VoxelCoefficient and then turning it into a matrix CoefficientFunction.

Thanks for your help and best regards,
Julius

Yes the voxelcf can currently only handle 1 dimensional data. It would not be too hard to extend it to higher dimensional data though, if for example you have always n**2 entries in the values array. Then lookup would have to be done only once resulting in faster evaluation. If you are motivated pull requests are welcome :wink:
It would be enough to implement a vector version, you can then reshape the 4 vector in a 2x2 matrix.

Thanks for the reply :slight_smile:
We will have a look into the code and see how to contribute with a PR.

I implemented a possible solution: Add VectorialVoxelCoefficientfunction by j-zimmermann · Pull Request #60 · NGSolve/ngsolve · GitHub

Can you please have a look?

Best,
Julius