Selecting, labelling, compositing Axes.CHANNEL

Hi to all,

I have a multiD image, which has Axes.X,Y,Z and 3xchannel. I am using the AXES.Channel to keep the x,y and z components of a vector quantity (magnetization).

I am defining the dataset with:

D = datasetService.create(new FloatType(), dims, info[0], axis);
final LinearAxis xAxes = new DefaultLinearAxis(Axes.X, info[1], steps[0]);
final LinearAxis yAxes = new DefaultLinearAxis(Axes.Y, info[1], steps[1]);
final LinearAxis zAxes = new DefaultLinearAxis(Axes.Z, info[1], steps[2]);
final LinearAxis cAxes = new DefaultLinearAxis(Axes.CHANNEL, "vector", 3.0);
final CalibratedAxis[] caxis = { xAxes, yAxes, zAxes, cAxes};

Channel related questions:

  • How can I label each channel, i.e. the CHANNEL 0 should be labelled “Mag X”, and so on.
  • I need to pass a subset of the dataset to another routine, say Axes.CHANNEL=0. How can I select a subset? Or should I send the full dataset anyway and select by axes?
  • I would like to make a composite view, like using the “Image->Color->Make Composite” using imglib2. But I cannot understand the CompositeXYProyector class. Can anyone give me a snippet code for this?
1 Like

Hello Juan,

I don’t think a Dataset supports this kind of metadata. Maybe create a little helper method to your code that returns the appropriate label when displaying results etc., something like public static String getMyChannelLabel(final long channel);

Use the handy methods in the Views class, in your case:

final dimension = 3; // index of your channel dimension
final position = 0; // channel 0
final RandomAccessibleInterval slice = Views.hyperSlice(dataset, dimension, position);
// I don't remember if you can cast the return type to a Dataset or not

If you’re having trouble displaying your composite image, try changing the axis order before showing the image to X,Y,C,Z. This is a known issue with the legacy UI. You can achieve this, for example, with Views.permute

Best regards,

1 Like