# Lacunae Orientation

Hi all,

I’m struggling to visualise the orientation of lacunae in bone. What I would like to have is each lacunae (already segmented) coloured according to their orientation relative to the X,Y,Z planes in the data.

Bonej has the ability to draw an ellipse corresponding to lacunae shape and can provide the orientation calculated from the eigenvalues/vectors, centroid etc, but these are difficult to visualise. There is a 2D orientation function in orientationj, but I need this calculated on the 3D volume.

I could be missing something, but I’ve been hunting high and low for this functionality across a range of visualisation software (Avizo, Fiji, 3dSlicer, Paraview), but there seems to be very little capacity for converting the measured eigenvalues etc of particles into a visualisation package. Any pointers would be appreciated.

1 Like

Interesting suggestion.

Orientation is in general a difficult thing to visualise, especially if you have to communicate via a 2D static medium (e.g. figure in a paper).

Is it important for you to have the orientation per lacuna?

Or could you plot each lacuna as a dot on a polar/radius plot (where direction is rotation and radius is elevation)?

It should be reasonably straightforward to code the eigenvectors as colours, but the challenge is finding a look-up table that is intuitively understood. e.g. yellow-blue for rotation around the z axis and saturation for rotation in the orthogonal direction.

In the meantime BoneJ has the option to display the axes of either the ellipsoid or the moments of inertia of each particle. Adding colour would in principle be straightforward (once the LUT is worked out), and could be done to either the surface mesh of each particle or to its pixels (like the size stack, but orientation instead of size).

Out of interest, are you using BoneJ1 or 2?

1 Like

Agreed, the visualisation of orientation can be problematic, but trends in orientation can be seen and even the volume calculated using the 2D version in orientationj is interesting, albeit misleading. I’m interested in orientation in relation to overall bone structure in different comparative treatments.

The problem is not new. I have managed to find a few papers that have done something similar, but the methods are either poorly explained or very complicated (for me at least - I’m no data analysis guru).

Similar visualisation is done in diffusion tensor MRI, where the use of coloured ellipses are used to show orientation, but really an extension of the functionality in bonej would be perfect.

Conceptually, the idea is simple. Translating this into reality is the trick. Thanks for the feedback this far.

I’m using bonej 2 as far as I know. Only intsalled it last week.

1 Like

Could you point us to an example colour scheme that’s particularly contrasty and informative and accessible to people with colour vision differences?

1 Like

This is the type of visualisation I am thinking of. But rather than an array format as shown here the ellipses would be mapped to the lacunae.

Figure 6 in the Suniaga paper (link below) would be ideal, but the methodology is not stated clearly.

Mader et al 2013 (html link attached) on the other hand also achieve visualisation of orienation, but the methodology is not… easily packaged.

Suniaga 2018 link https://www.nature.com/articles/s41598-018-21776-1

Many thanks

1 Like

Thanks for these examples

Colours don’t map to orientations in this scheme, perhaps they are a LUT for eccentricity?

This kind of thing is possible, but bear in mind that they have displayed only the first or second semi axis of the best-fit ellipsoid.

Out of curiosity I had a go at coming up with a LUT based on the axis-angle derived from the rotation matrix of the inertia tensor. It’s not beautiful (and maybe not quite what you want).

It would help a great deal if you could come up with a LUT that is meaningful for your samples. What would you like the colours to mean? And how do you make sure that the same colour isn’t used for two states?

Thanks for trying to progress this, it’s much appreciated.

Ultimately, what I would like to have is lacunae with the same or similar orientation along the longest axis share the same or similar colour. A complication might be that there is no directional aspect, just orientation.

Attached is an output from OrientationJ’s Analysis, which is nice, but only a 2D interpretation.

The OrientationJ Analysis plugin uses a HSB colour survey to map the orientations. I guess the trick is having the second orientation to deal with.

Right - that is what has to be clarified first. For a single vector (the long axis for example) an HSV or HSL representation might be OK, because hue can map as a circle and all 2 pi radians in the circle are distinct. Then elevation can be mapped to saturation or lightness / value. Essentially that is mapping hue as the longitude and lightness as the latitude, and the unit vector of the principal axis pointing to one spot on the surface. Each spot is unique. The limitation is that getting another rotation is tricky if not impossible, so you have to do two images, one for the first principal axis and one for the second.

Having the ability to visualize each of the three vectors separately would be a useful feature.

This is an axis-angle representation in HSB where hue is the angle of rotation around the axis and saturation and brightness relate to the axis deviation (a bit hard to see). For particles that have their long axes more-or-less aligned already, this effectively shows the orientation of the second axis. The hue colour circle is packed into a half-circle because orientation ranges between 0 and pi not between 0 and 2× pi. (The opposite side of the wheel is the same colour not the complementary colour). Particles here are mouse osteocyte lacunae in SR-microtomography.

As vectors (little lines with/without length) or as colours of the particles?

Hi Michael,

Very promising. How do I implement this in my own version of bonej? Is it an update or do I use the code? Would love to test this on my data. Regarding the last point, I was intending to just use colour for the different vectors, but anything that might enhance the visualisation would be of interest.

The best way is to check out this particular git branch and build your own copy using Git and Maven.

Once you have Git and Maven installed:

`git clone https://github.com/bonej-org/BoneJ2.git`
Gets you following the official release repository copied into a directory called `pom-bonej`. `cd` into it.

`git remote add mdoube-bonej https://github.com/mdoube/BoneJ2.git`
Creates a new ‘remote’, which tracks my personal fork of BoneJ2

`git fetch mdoube-bonej`
Refreshes your local copy of my fork with updated commit and branch information (i.e. whatever work I was just doing).

`git checkout mdoube-bonej/particle-analyser`
Loads all the up-to-date code on my `particle-analyser` branch, which is where I’m working on these Particle Analyser features.

`./IJinstall_naughty.sh <path to your>/Fiji.app/`
Installs BoneJ plugins to your Fiji, using whatever code you happen to have checked out with Git. Replace `<path to your>` with the directory path to Fiji on your system.

Restart Fiji and try the plugins. We’ve built this on Ubuntu, but it ought to work elsewhere (Mac OS X, Windows I guess).

`git branch -a`
Lists all the branches available for you to check out in case you want to try something else.

`git checkout master`
Gets you back to the release branch of your copy of `bonej-org`

`git pull`
Updates your branch with new commits from the remote.

There are tons of Git tutorials about. If you want to start contributing to BoneJ, you will need to make a fork on GitHub and clone that; that will be your ‘origin’. You would then push your commits (code changes) to your fork, and send us a pull request by asking to merge your commits into `bonej-org/master`.

Let us know how you get on with these instructions - they could form the basis of a Wiki entry for bleeding edge testers like you.

Hi Michael,

Apologies, you will have to excuse my ignorance. I’m not a coder or familiar with working with Git etc. I have installed Git and Maven (in Windows 10) and think this is all working OK. In Git I can see your branch and workings but I am not sure how to get this into Fiji.

In particular, these steps:

`git checkout mdoube-bonej/particle-analyser`
Loads all the up-to-date code on my `particle-analyser` branch, which is where I’m working on these Particle Analyser features.

`./IJinstall_naughty.sh <path to your>/Fiji.app/`
Installs BoneJ plugins to your Fiji, using whatever code you happen to have checked out with Git. Replace `<path to your>` with the directory path to Fiji on your system.

Can you break this down a little further? I am not sure where you are entering these greyed out sections (command line input somewhere, I guess if you are using Ubuntu)

Cheers

Jeremy

Git for Windows comes with Git BASH, which is an environment much like the command line in Ubuntu and Mac OS X - that’s where you should type your Git commands. I’m not sure if `IJinstall_naughty.sh` will work in Git BASH, or if you have to use the Windows 10 Bash Shell. Please try it and report here. You don’t need to install a full Linux as in the instructions in the link, just the shell (Linux-style command prompt).

You could also try installing one of these GUIs, which should have some menu-driven commands (e.g. right click on a branch to check it out), as well as some visualisation tools that can help to understand how all the code changes to relate to one another.

Success, I’ve managed to apply the custom plugin to a test data set. All those command lines worked in Git Bash for Windows.

I would like to play with the LUT options and I would like to find a way of exporting those coloured surfaces to another program. The 3D viewer can export as stl and wavefront, but not sure if the colour information comes across.

Regardless, this is great, many thanks.

1 Like

Splendid.

Can you be more specific?

We didn’t implement colour in the STL writer code because there isn’t a standard way to encode it. The DXF writer code respects colour, but it’s not clear how multiple meshes in the same view are handled. WaveFront export might handle colours as ‘materials’. As usual, have a go and report back!

Hi Michael, I just thought I would run your orientation analysis on some dummy data. The image just shows some ellipses I drew up in Blender, converted to solid ellipses in Avizo and then binarised in Fiji before running the BoneJ particle analysis. As you can see, the output shows ellipses with the same orientation as different colours. Can you clarify what might be happening here?

Some ellipsoids (they’re not ellipses, those are 2D shapes) seem to generate out of range values for the sum of diagonals of the rotation matrix. I’m not sure why that is, and so far have dealt with it by clipping to the min and max allowable values, with the effect that ellipsoids clipped this way appear bright red. This is a point to debug. It should be possible to do something to the rotation matrix so that the `trace()` function falls within the expected range (like rotating it by 180°), or to handle the out of range `trace()` by wrapping it around before putting it into `acos()`.

The hue represents rotation of the short (a) and middle (b) axes around the long axis (c), while brightness and saturation vary as a function of long axis deviation from vertical (z axis of the image’s coordinate frame). Your ellipsoids have ab which means that random-ish factors like jaggies in your surface mesh will make the rotation unstable, and the colours seem a bit random.

Could you please make a new test image, with ellipsoids more in the aspect ratio of osteocyte lacunae (c. 1:2:5), and with a steady increase in axis and angle throughout the volume? A bit like the image in your earlier post.

I tried this and it seems to work.

Would you mind updating your git repository (`git pull`) and building again (the `IJinstall_naughty.sh` line) to see if it works for you?

Hi Michael,

Happy New Year! I am revisiting the lacunae orientation problem, but hope to bring this to the attention of our data analysis and visualisation specialist in due course, who has a far better handle on what is being done here.

In the meantime, I have pulled your changes and updated Fiji to try your modifications. I created a new test image comprised of ellipsoids of the same shape 1:2:5 aspect ratio and at angles of 10 deg increments. I copied an additional set at 90 degrees to the others and scaled them down a bit.

As you can see, the result is a little confusing. There does not appear to be any logic to the color vs orientation. I also ran the updated Fiji version on the previous test data and I get the same result as before.

It may well be something I’m doing, and it might be best to wait until my colleague gets a chance to look at it.

I am certain your modifications have taken effect as I also ran it on an actual dataset and compared the result to that obtained using your previous version, it was certainly different.