odlgroup / odl

Operator Discretization Library https://odlgroup.github.io/odl/
Mozilla Public License 2.0
363 stars 105 forks source link

3D visualization #855

Open kohr-h opened 7 years ago

kohr-h commented 7 years ago

I played around a little bit with mayavi. It's a pythonic wrapper around VTK, together with a pylab-like interface for quick visualization and a (for us not so interesting) stand-alone GUI application. It can be installed from conda using the conda-forge channel: conda install -c conda-forge mayavi.

I think it's a very nice package, and with the following code:

import odl
from mayavi import mlab

space = odl.uniform_discr([0] * 3, [1] * 3, [200] * 3)
phantom = odl.phantom.shepp_logan(space, modified=True)

data_src = mlab.pipeline.scalar_field(phantom.asarray())
mlab.pipeline.image_plane_widget(
    data_src,
    plane_orientation='x_axes',
    slice_index=100,
    colormap='bone')
mlab.pipeline.image_plane_widget(
    data_src,
    plane_orientation='y_axes',
    slice_index=100,
    colormap='bone')
mlab.pipeline.image_plane_widget(
    data_src,
    plane_orientation='z_axes',
    slice_index=100,
    colormap='bone')
mlab.outline()
mlab.show()

you get an image like this: snapshot

It's highly responsive and real fun to play with. You can click on a symbol in the task bar to manipulate the pipeline, e.g., switch planes on and off, change lighting etc. Other things like volume rendering, surface rendering etc. are not much harder to achieve.

The real question is what interface we should have for this functionality.

The most interesting types of visualizations are probably

ozanoktem commented 7 years ago

This is all nice and good and good as a first 3D visualization functionality. For volume rendering, the functionality I think we would like to have is a way to set the contrast transfer function. On the other hand, I think a higher priority is to have a DICOM export of reconstructions. In medical imaging our results will be viewed using externel DICOM viewing software. For ET I suggest we have an MRC export functionality since results will be viewed using external software.

kohr-h commented 7 years ago

This is all nice and good and good as a first 3D visualization functionality.

Not only that. ODL is a prototyping tool, and to have decent visual feedback (during iteration etc.) is important. And to produce images for presentation slides, of course.

On the other hand, I think a higher priority is to have a DICOM export of reconstructions. In medical imaging our results will be viewed using externel DICOM viewing software.

That's true as soon as you intend to give the data to somebody else who wants to work with DICOM. For day-to-day work you don't want to go through DICOM every time.

For ET I suggest we have an MRC export functionality since results will be viewed using external software.

That already exists, the only thing that is missing is the export of the FEI extended header.

adler-j commented 7 years ago

I had a look at Mayavi myself as well and I was positively surprised. What I did was look at a volume slicer which gives plots like this:

With that said, there are so many possibilities here that I feel that adding all of them to the already cramped show method would be hard (at least to start with). Hence I'd go for a free function for now, we could easily wrap it in the long.

Edit: Regarding what to add, I'd start with a slice viewer (as shown here) and then add more as they are needed by users.

adler-j commented 7 years ago

Regarding DICOM @ozanoktem, if that is to be useful we need to have a good DICOM viewer accessible, I've personally yet to find one openly available for medicine (but I haven't looked to much).

An example somewhere in the doc on how to do an DICOM export and then viewing it in a DICOM viewer would greatly help.

ozanoktem commented 7 years ago

Regarding DICOM @ozanoktem, if that is to be useful we need to have a good DICOM viewer accessible, I've personally yet to find one openly available for medicine (but I haven't looked to much).

Well, for MacOS X there is Osirix, which is free and really good, in fact better than most commercial viewers.

An example somewhere in the doc on how to do an DICOM export and then viewing it in a DICOM viewer would greatly help.

Agree fully.

adler-j commented 7 years ago

Another comment: A very nice functionality would be a simple 3d data viewer that has a slider and displays a single slice so that you can slide through the data.

Finally, these functions should, if possible, work with both ndarrays and DiscreteLpElements, where it should infer the grids if given an array. That way they would be useful for other things as well.