TileImageFilter and Direction/Orientation

Hello,

(Apologies, I feel like I asked this question a long time ago and maybe I forgot the answer).

I am combing several 3D volumes into a 4D series with TileImageFilter. TileImageFilter does not take account of the direction/orientations of the input images, and has an identity matrix for the output direction. There does not appear to be an equivalent to the SetDirectionCollapseToSubmatrix() member function of ExtractImageFilter e.g. SetDirectionExpandFromSubmatrix().

I have resorted to manually copying the relevant part of the direction matrix from one of the volumes (tiler is a TileImageFilter instance, vdir is the direction matrix of the first volume):

tiler->Update();
auto const &series = tiler->GetOutput();
Series::DirectionType sdir = series->GetDirection();
for (int ii =0; ii < 3; ii++) {
    for (int jj =0; jj < 3; jj++) {
        sdir[ii][jj] = vdir[ii][jj];
    }
}
series->SetDirection(sdir);

In this particular case, I have sagittal volumes that I was combining, so after tiling they had an incorrect orientation.

Is there a better way to do this? Is there a particular reason TileImageFilter has no mechanism to preserve the direction as best as possible?

Have you looked at the JoinSeriesImageFilter? This filter was writing to handle the N->N+1 dimension change, and handles the direction cosine matrix appropriately by copying the valid parts, and setting the new parts to the identity.

2 Likes

I had completely missed that filter. Thanks!