OpenChemistry / tomviz

Cross platform, open source application for the processing, visualization, and analysis of 3D tomography data
https://tomviz.org/
BSD 3-Clause "New" or "Revised" License
320 stars 84 forks source link

linear algebra library #688

Closed yijiang1 closed 6 years ago

yijiang1 commented 7 years ago

Is there a c++ linear algebra library included in tomviz? Some advanced tomography reconstruction requires operations such as matrix vector multiplication.

cryos commented 7 years ago

We could add in Eigen, I know it well, and it would be easy to add. It is header only, expands out to very efficient code and the API is nice and friendly.

cjh1 commented 7 years ago

pybind11 also has support for wrapping it, which is a bonus if that become necessary.

yijiang1 commented 7 years ago

Eigen seems a good choice.

Hovden commented 7 years ago

We're looking to speed up the reconstruction algorithms. Some are slow (~day).

We could either parallelize Python (threading library needed) or implement them in C++ (requiring linear algebra library). Which would be easier?

cryos commented 7 years ago

Adding Eigen is pretty simple, we will just add it to the superbuild. If you want me to put up an example branch to use it I can do that, but you will need to install it locally. I will see if I can put a quick example up tomorrow, this library is great as it is header only, and so there are no additional libraries to take care of. This is probably the easiest path too, I am not that familiar with multithreading in Python.

ercius commented 7 years ago

Maybe we can integrate tomopy and/or the Astra toolbox? Their algorithms are well tested and fast. I've been using them a lot recently. I'm not sure if they have builds for all platforms though. Windows and Linux only?

On Fri, Nov 4, 2016, 6:16 PM Marcus D. Hanwell notifications@github.com wrote:

Adding Eigen is pretty simple, we will just add it to the superbuild. If you want me to put up an example branch to use it I can do that, but you will need to install it locally. I will see if I can put a quick example up tomorrow, this library is great as it is header only, and so there are no additional libraries to take care of. This is probably the easiest path too, I am not that familiar with multithreading in Python.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenChemistry/tomviz/issues/688#issuecomment-258581696, or mute the thread https://github.com/notifications/unsubscribe-auth/AO7olGkHhlY_jJIY57ie5F0RwcXXkEHEks5q69jngaJpZM4KcT2P .

cryos commented 7 years ago

I have been looking at tomopy, and it looks nice. You have been able to use these in your work with STEM tomography reconstructions? I have not come across Astra.

ercius commented 7 years ago

Tomopy is pretty good, but the Astra-toolbox is very fast and flexible. Both can be installed in Anaconda pretty easily to try them out.

You can also call the Astra-toolbox recon algorithms from tomopy which makes setup a little easier in some cases.

Both are parallelized and Astra is GPU capable. Astra seems to be faster in my experience. I have been doing alignment in tomviz, exporting to HDF5, and reconstructing using ASTRA lately. I can send an example python script if you want to try it out.

ercius commented 7 years ago

.I forgot to mention that the weighted back projection code in tomopy does not work properly. I think it does not apply any weighting, making the low frequencies overpower the reconstruction. If you are testing out tomopy then try the GRIDREC method. Its quite fast and produces nice results.

cryos commented 7 years ago

I would really appreciate that, thanks for providing the links. We can certainly offer Eigen for fast C++ linear algebra, but these look like great additions if they aren't too difficult to package.

ercius commented 7 years ago

@Hovden @cryos I sent you an email with a demonstration script and test data for tomopy and ASTRA. If anyone else watching this thread is interested in these files let me know.

Hovden commented 7 years ago

@cryos and I discussed this a little over the phone. Most immediately, the focus is on getting a new stable release out. Next week I'll look at tomopy and ASTA with @yijiang1 and get back to you to discuss it further. It sounds like a good idea.

ercius commented 7 years ago

This is definitely a more long term part of the project.

I did more testing and ASTRA is not parallelized for CPU (non-GPU) reconstruction (so called 2D CPU algorithm by ASTRA). tomopy implemented parallel versions of the non-GPU ASTRA algorithms. So, this might be more difficult in practice than I previously thought because you need both tomopy and ASTRA to get the full benefit which is only possible on linux right now.

cryos commented 6 years ago

Eigen is in VTK now, and so can be used as other third-party modules are.

Hovden commented 6 years ago

@yijiang1