Mrview- defining an oblique plane

Hi all. Is it possible to export/save the current view on an image to define an (oblique) plane? The purpose of obtaining the plane coordinates is to split a segmentation masks into two parts.

There’s no explicit functionality for this currently, but it should relatively straightforward to have the information you need printed onto the terminal. If I understand what you’re after, it should be sufficient to export the current view matrix (which maps from scanner coordinates to eye coordinates). It should be sufficient to add something like this line:


At line 120 in the src/gui/mrview/mode/slice.cpp.

Happy to help if any of this is unclear… :+1:

Thank you, this worked well for drag-and-drop actions. However, if one scrolls through slices for example by using the mouse wheel, the view matrix is not printed to the terminal and the camera position won’t correspond to the last view matrix. Could you please advise where one would have to modify the code to achieve printing after scrolling through slices?

I realised that the view matrix is not supposed to change when scrolling through the slices, but I think that it does not contain enough information to define the current view plane. I think that at least the current cross hair position is required in addition to the view matrix. How does one print the current cross hair position to the terminal?

OK, that makes sense. You could try adding:


at line 67 in src/gui/mrview/mode/base.cpp. You could also add this line:

VAR (projection.modelview());

at the same time (and get rid of my previous suggestion). That way you’d get both pieces of information printed out every frame update, I think.

Perfect, thank you. Your suggestions work well and it should be sufficient for our use case. To correct what I said before, the view matrix does update itself when scrolling, but only in the “single slice” view mode. In “ortho view” mode it does not update with the


command, and defaults to an Identity matrix with the

VAR (projection.modelview());


Good to hear. Yes, orthoview is handled slightly differently, this is not surprising… If this is a problem, I’m sure there will be ways around it, but you’d have to figure out which projection matrix you’re after from the 3 that are available (one for each pane)…

1 Like

After all, it would be useful to obtain the projection matrix in orthoview mode. In our case, the sagittal view is the one of interest. If possible, could you please advise how to do this?

You could try adding this line:

std::cerr << "projection: " << (axis == 0 ? "sagittal" : ((axis == 1) ? "coronal" : "axial")) << "\n" << with_projection.modelview() << "\n";             

at line 130 in src/gui/mrview/mode/slice.cpp (between the setup_projection() and draw_plane_primitive() calls). That’ll work for the single-slice and orthoview modes, but not for the volume render or lightbox modes.

Awesome, this is exactly what we needed. Thank you very much for your help!