3D visualization of scientific data in Python

Related tags

Sciencemayavi
Overview

Mayavi: 3D visualization of scientific data in Python

Mayavi docs: http://docs.enthought.com/mayavi/mayavi/ TVTK docs: http://docs.enthought.com/mayavi/tvtk

Package on PyPI Build status Appveyor build status Code coverage status BSD 3 Clause

Vision

Mayavi seeks to provide easy and interactive visualization of 3D data. It does this by the following:

  • an (optional) rich user interface with dialogs to interact with all data and objects in the visualization.
  • a simple and clean scripting interface in Python, including one-liners, a-la mlab, or object-oriented programming interface.
  • harnesses the power of the VTK toolkit without forcing you to learn it.

Additionally Mayavi strives to be a reusable tool that can be embedded in your applications in different ways or combined with the envisage application-building framework to assemble domain-specific tools.

Mayavi is part of the Enthought Tool Suite (ETS).

Features

Mayavi is a general purpose, cross-platform tool for 2-D and 3-D scientific data visualization. Its features include:

  • Visualization of scalar, vector and tensor data in 2 and 3 dimensions
  • Easy scriptability using Python
  • Easy extendability via custom sources, modules, and data filters
  • Reading several file formats: VTK (legacy and XML), PLOT3D, etc.
  • Saving of visualizations
  • Saving rendered visualization in a variety of image formats
  • Convenient functionality for rapid scientific plotting via mlab (see mlab documentation)
  • See the Mayavi Users Guide for more information.

Unlike its predecessor MayaVi1, Mayavi has been designed with scriptability and extensibility in mind from the ground up. While the mayavi2 application is usable by itself, it may be used as an Envisage plugin which allows it to be embedded in user applications natively. Alternatively, it may be used as a visualization engine for any application.

Quick start

If you are new to Mayavi it is a good idea to read the online user manual which should introduce you to how to install and use it.

If you have installed Mayavi as described in the next section, you should be able to launch the mayavi2 application and also run any of the examples in the examples directory.

Installation

By itself Mayavi is not a difficult package to install but its dependencies are unfortunately rather heavy. However, many of these dependencies are now available as wheels on PyPI. The two critical dependencies are,

  1. VTK
  2. A GUI toolkit, either PyQt4, PySide, PySide2, PyQt5 or wxPython.

The latest VTK wheels are available on all the major platforms (Windows, MacOS, and Linux), but only for 64 bit machines. Python 3.x is fully supported on all these operating systems and Python 2.7.x on MacOS and Linux. If you are out of luck, and your platform is not supported then you will need to install VTK yourself using your particular distribution as discussed in the General Build and Installation instructions

On Python 3.x you will need to install PyQt5 and wheels are available for this. On 2.7.x you have more options, and can use PySide, PyQt4, and wxPython. These can be installed from pip or from your package manager.

Currently, Mayavi itself should work with the new wxPython 4.x. However, traitsui, pyface, and other ETS packages do not yet support it so the UI will not work correctly. Older versions should work. PyQt/PySide/PySide2 should work largely out of the box.

Latest stable release

As of the latest release, i.e. 4.6.0 and above, if you are using Python 3.x and are on a 64 bit machine, installation via pip is the easiest and is as follows:

$ pip install mayavi

$ pip install PyQt5

Thats it!

If you are unable to do this, read the documentation above and find a way to install VTK and a suitable UI toolkit and then repeat the above.

If you are interested in the jupyter notebook support as well, do the following (after ensuring that you have jupyter installed of course):

$ jupyter nbextension install --py mayavi --user
$ jupyter nbextension enable --py mayavi --user

You will also need to have ipywidgets and ipyevents installed. These can be installed via pip or your favorite package manager.

Bleeding edge

If you want to install the latest version of Mayavi from github, you can simply do the following:

$ git clone https://github.com/enthought/mayavi.git
$ cd mayavi
$ pip install -r requirements.txt
$ pip install PyQt5  # replace this with any supported toolkit
$ python setup.py install  # or develop

Add the jupyter nbextensions using the instructions in the section above and you should be good to go.

Documentation

More documentation is available in the online user manual or in docs directory of the sources. This includes a man page for the mayavi2 application, a users guide in HTML and PDF format and documentation for mlab.

More documentation in the form of workshop/tutorial material is available here:

Tutorial Videos

Here are some tutorial videos that you can watch to learn Mayavi:

Examples

Examples are all in the examples directory of the source or the git clone. The docs and examples do not ship with the binary eggs. The examples directory also contains some sample data.

Test suite

The basic test suites for tvtk and mayavi can be run using nose:

nosetests -v tvtk/tests
nosetests -v mayavi

The integration tests:

cd integrationtests/mayavi
python run.py

Bug tracker, mailing list etc.

The bug tracker is available in github Please provide info and details on platform, python, vtk and gui backends and their versions. If possible, a small example replicating the the problem.

If you have questions you could ask on the Mayavi-users mailing list. This is used by some folks and is not too active. Another mailing list that may be of use is the ETS Users mailing list. This is a more general list where a lot of folks experienced with the Enthought Tool Suite are available.

Authors and Contributors

  • Core contributors:

    Prabhu Ramachandran: primary author.

  • Previous contributors:

    Gaël Varoquaux: mlab, icons, many general improvements and maintenance.

    Deepak Surti: Upgrade to VTK 5.10.1, VTK 6.x with new pipeline.

  • Support and code contributions from Enthought Inc.

  • Patches from many people (see the release notes), including K K Rai and R A Ambareesha for tensor support, parametric source and image data.

    Many thanks to all those who have submitted bug reports and suggestions for further enhancements.

Comments
  • Python 3 support

    Python 3 support

    Any plan to support Python 3 for mayavi ?

    Python going to release Python 3.4 soon. I think Python 3 is now very mature and main third party library (numpy, scipy, pandas, matplotlib, etc) support it now.

    I am also slowly moving all my project to Python 3. It's pretty simple task with 2to3 app for "small" project. You can sometime get some conflict with old std libs or issues with unicode/string stream but nothing bad...

    I guess it will be a bit more complicated to move mayavi and others related projects but it shouldn't be something too hard to do in a mid term time.

    I don't want to talk for others but I think many people are waiting mayavi to move their projects to Python 3.

    "Don't wait until Python 4 is released please..."

    :-)

    Cheers

    opened by hadim 72
  • Upgrading to new pipeline

    Upgrading to new pipeline

    Step 1: Changing the pipeline topology. [IN PROGRESS]

    Step 2: Changing the pipeline metadata

    Step 3: Update only the algorithms, and not a combination of data objects/algorithms.

    Step 4: (VTK 6 only): Subclass only from vtkAlgorithm and use the RequestXXXX api

    opened by dmsurti 70
  • 3D Visualizer / TVTK Window (Not Responding) on Windows 7 64-Bit

    3D Visualizer / TVTK Window (Not Responding) on Windows 7 64-Bit

    I am working to install Mayavi2 on my Windows 7 (64 Bit), but am not able to fully interact with the visualizer or TVTK window. They freeze immediately upon first opening. I have tried to install Mayavi2 using both the Enthought (64 Bit & 32 Bit) and Python(x,y) distributions with full system cleans before the installation to ensure that all Python materials are removed. Each installation allows me to interact with Python with no noticeable trouble and I am able to "import mayavi" to my shell. The problem comes when calling a mayavi function (e.g., mlab.plot3d) or simply running the Mayavi2 GUI. Immediately the window freezes and shows a (Not Responding) message. I have tried to install the package on another Windows 7 (64 Bit) machine with no problem. Thanks for the help. I am very interested to see if there is a machine-specific solution to my problem or what I might try to get around this window crash.

    opened by brymz 29
  • Stuck at `Building wheel for mayavi (setup.py)`

    Stuck at `Building wheel for mayavi (setup.py)`

    Here is my installation environment: Ubuntu 20.04 LTS on a ThinkPad P15 laptop image And when I do pip install mayavi, I get stuck during the Building wheel process: image

    Python version is 3.8.10.

    opened by woochangchung 24
  • Test suite hangs on macOS

    Test suite hangs on macOS

    I'm unable to run the test suite (under nose) on macOS, with the latest master of Mayavi in a venv: the test suite hangs with no output.

    Steps to reproduce: here are the commands I'm issuing, in a zsh shell on macOS 10.15.7 (Intel MacBook Pro). Here python3.9 is Python 3.9.7, installed via MacPorts.

    python3.9 -m venv --clear ~/.venvs/mayavi
    source ~/.venvs/mayavi/bin/activate
    python -m pip install -e .
    python -m pip install nose
    python -m nose.core -v mayavi
    

    Note: the python -m pip install -e . instruction also hangs intermittently (perhaps 1 run out of every 3), but succeeds often enough to allow me to get to the next step.

    When the installation succeeds, the test run using nose hangs with no output other than a RuntimeWarning about nose.core being found in sys.modules prior to execution of nose.core. The hang can't be interrupted with a Ctrl-C, and top shows no CPU usage or memory growth in the associated process - IOW the hang resembles a deadlock of some kind. The Python process shows 7 OS-level threads; I'm not sure what's causing the extra threads in something that I'd expect to be single-threaded.

    There's at least one obvious problem with my setup, which is that I know that the test suite expects some other packages to be present, and will fail without them. However, this still shouldn't be responsible for hanging the test run - we should have a better failure mode here.

    I consider this sort of issue to be high priority to diagnose and fix: it makes development work much harder than it needs to be.

    bug 
    opened by mdickinson 23
  • text3d and fullscreen

    text3d and fullscreen

    On my system mayavi 4.4.0 (and the previous version) will make the text3d disappear when the window is made fullscreen.

    Procedure:

    from mayavi import mlab
    mlab.points3d(0, 0, 0, opacity=0.5)
    mlab.text3d(0, 0, 0, 'A')
    mlab.show()
    

    After these commands a sphere and an A is displayed. Pressing the fullscreen button makes the text3d disappear from the scene. The Text3D object is still visible in the 'Mayavi pipline' window.

    needs investigation bug 
    opened by fnielsen 22
  • Does Mayavi support PyQt5?

    Does Mayavi support PyQt5?

    Hi all!

    I want to embed a mayavi surface plot into a PyQt5 widget, like I did with matplotlib plots. Alas, I didn't find any working examples of such an embedding.

    Is PyQt5 supported now?

    opened by Felix-neko 20
  • Python3 support

    Python3 support

    The aim of this PR is to solicit feedback and merge this early for those who want to cut themselves on the bleeding edge.

    This adds experimental Python3 support for Mayavi. To use it one requires a recent version of apptools and envisage (by recent I mean that these PRs should be merged https://github.com/enthought/apptools/pull/54 and https://github.com/enthought/envisage/pull/61 ).

    It requires the master branch of pyface.

    It will require the latest version of VTK from their git repository (https://gitlab.kitware.com/vtk/vtk) and a fresh build of VTK configured for Python3. I have not bothered with travis CI support at this point due to the complexity of doing that. These changes pass all current 2.7.x tests on travis so should be safe to merge.

    Status and known issues

    • The changes are compatible with Python 2.x and 3.x. I have tested on 2.7.x and 3.4.x.
    • All the tvtk tests pass.
    • There are a couple of random failures in the mayavi tests. These may be version specific issues but need more investigation.
    • The integration tests mostly run fine but blocks on exit (with PyQt) so if you run one of them you need to kill it to run the next. This can be investigated later.
    • mlab works quite well.
    • The mayavi2 application itself has a few issues that seem pyface related and will be investigated later, notably the persistence of the workbench perspectives are not pickled/unpickled properly..
    opened by prabhuramachandran 20
  • Fix

    Fix "_p_void" values in TVTK with VTK 6.x

    I have tested this with VTK 6.2 and 6.3 on Ubuntu 12, and VTK 6.3 on OSX 10.11

    Things seem to work but since this is a fundamental change, I would prefer sitting on it for a bit longer. Review and comments are very much appreciated.

    Most of these changes are tested by the existing TVTK test for initialising all classes, but I think I could also add more tests to make it more robust.

    To compare the bahaviour, try the following with the master branch and with this one:

    from tvtk.api import tvtk
    obj = tvtk.ViewTheme()
    obj.configure_traits()
    
    opened by kitchoi 19
  • MAINT: Update for latest VTK

    MAINT: Update for latest VTK

    Closes #1049

    @opoplawski can you see if this fixes your build hang on Fedora 34? It at least "fixes" the hang for me on Windows. Plotting still doesn't work there (mlab.test_plot3d()) despite pyvistaqt.BackgroundPlotter working okay, so there is more to fix. But this might already be good enough progress in that it will prevent total pip install hangs for people using the VTK pre wheels. (They'll have a problem later when they try to actually plot, but that's at least easier to diagnose than an empty build log that took an hour of CI time).

    opened by larsoner 18
  • ENH: VTK 9 compat

    ENH: VTK 9 compat

    This is a bit nightmarish to figure out, but I'm about halfway through adding exceptions for the objects. There is probably an automated way to do it, might be worth figuring that out...

    Closes #908.

    opened by larsoner 18
  • Recurrence of #281 (keeping a key pressed )

    Recurrence of #281 (keeping a key pressed )

    I already posted a comment in the issue #281 thread, but since it is closed, I am opening a new issue.

    As originally described, and as now occurs again:

    'On a slower system, like a Linux Virtual Machine, I observed an occasional traceback when pressing a key (say, z) and rotating the scene with the mouse: [...] TypeError: SetEventInformationFlipY argument 5: a string of length 1 is required'

    I found that the original fix for #281 needs to be modified slightly in the source code for QVTKRenderWindowInteractor.py:

    if ev.isAutoRepeat():
    # key = key[0]
    key = bytes(key[0])

    (apologies I am not a formatting wiz here)

    opened by cvsindelar 0
  • Opacity not working on volume_slice and image plane widget

    Opacity not working on volume_slice and image plane widget

    Hi, I have a scalar 3D cube where I want to add opacity to some slices but it is not possible with volume_slice and image plane widget. The only current solution was to use scalar cut plane (where opacity works). Is it possible for me to add opacity via pipeline to image plane widget? Thanks in advance!

    opened by ammir1 0
  • Hello! When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you  have a suitable UI toolkit like PyQt/PySide or wxPython  installed.

    Hello! When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed.

    Hello! My environment is ubuntu18.04, python 3.7.When I use mayavi to visualize the point cloud, the following error appears: ImportError: Could not import backend for trainsui Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed. screenshot_69

    But I have installed the required dependencies.

    scre
screenshot_65
enshot_68 screenshot_67

    I also defined the path of environment variables according to your suggestions to others:

    screenshot_70

    But this problem still exists. It's been bothering me for a long time. It's crazy. Could you help me?Thank you very much,sorry for your inconvenience.

    opened by Yuepengxin 8
  • how to install mayavi with ptyhon 3.9 on ubuntu 22.04 by conda?

    how to install mayavi with ptyhon 3.9 on ubuntu 22.04 by conda?

    Environment:

    os:Ubuntu 22.04
    conda: 22.9.0
    python: 3.9.13
    

    when I planned to install mayavi by conda, it was sticked there: image

    What's the problem, and how to resolve it?

    opened by heavenkiller2018 1
  • Error with configobj while installing

    Error with configobj while installing

    Collecting configobj Using cached configobj-5.0.6.tar.gz (33 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

    × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "", line 36, in File "", line 34, in File "C:\temp\pip-install-29s4msxx\configobj_9b92c695733840439ec2e6a1e365cf8d\setup.py", line 17, in from _version import version ModuleNotFoundError: No module named '_version' [end of output]

    opened by yeney 0
Releases(4.7.3)
  • 4.7.3(May 11, 2021)

  • 4.5.0(Aug 3, 2016)

    Enhancements

    • Jupyter notebook support
    • Adds support for recording movies and animating timesteps.
    • Updated LUTs to include new matplotlib colorschemes

    Fixes

    • Fix several bugs where PDF files were not saved properly.
    • Fix issues with tvtk.visual and add many tests for it
    • Refactor the save screenshot dialog popups.
    • Fix problem with the picker point not showing when "p" is pressed on the scene.
    • Python 3 fixes for the jupyter notebook support.
    • Fixes tubes not showing on protein demo.
    • Add additional save options.
    • Fixes the image plane widget and volume modules
    • Debug info on code gen for wrapper generation
    • BUG: Fix slice unstructured grid module.
    • Fix typo in readme.
    • update codecov configuration
    • Documentation for QString API failure.
    • Fixes incorrect signature of EnvisageEngine.new_scene.
    • Fix for unexpected test code.
    • Fix "_p_void" values in TVTK with VTK 6.x
    • Fix failing test for custom import in some circumstances
    • Removes array_ext.so/pyd on clean
    • Check if test successful with the appropriate filename.
    • Unicode trait handling for those vtk methods returning unicode data
    • Nicely load pylab_luts.pkl
    • Document object identity behavior matching VTK
    • Revert "Fix savefig size and black image"
    • Added setup.py documentation for Qt requirements
    • Add VTK 6.3 and VTK 7 to travis ci
    • Fix traitsdoc setup and compliance with py3
    • Import and integer division in python3
    • Fix texture on mlab.surf
    • Fixes Quiver3d Failure with different argument types
    • Fix Text3D in VTK 6.0+
    • Fix savefig size and black image
    • Fix for exception when modifying extents
    • Suppresses test for VTK 6.2 (solves appVeyor random failure)
    • Forces pipeline update when LUT changes
    • Fix for test failure on mayavi -t
    • Enforce ordering of attribute labels in VTKDataSource.
    • Apply has_attribute to the output in VTKFileReader
    • Replacing links to code. and svn.enthought.com
    • Fix Camera off-centered when loading saved visualization
    • Update to use new VTK pipeline where possible. This fixes a number of issues with the pipeline was not updating properly.
    • Fix issue with mlab.move
    • Fix issue with segfault when savefig is called multiple times.
    • Fix get_engine behavior when backend is changed again.

    Contributions from itziakos, stefanoborini and kitchoi are funded and supported by the SimPhoNy project, an EU-project funded by the 7th Framework Programme (Project number 604005) under the call NMP.2013.1.4-1.

    Source code(tar.gz)
    Source code(zip)
  • 4.4.4(Jun 28, 2016)

    Enhancements

    • Add experimental Python3 support

    Fixes

    • Ensure the cut plane is updated when the plane is changed in the GUI
    • Use off screen engine when mlab's offscreen option is enabled
    • Cast the window id to an int in the render window interactor
    • Update installation guide
    • Update docs to use Qt instead of wx
    • Update documentation setup
    • Allow TVTK to be used without UI/X server
    • Update documentation links
    • Make sure the array shape and size match
    • Ensure file attribute points to the correct path when running a script from Mayavi2
    • Avoid multiple identical keys in keyPressEvent. This is observed on slow machines
    • Do not use get-pip or wheel to upgrade pip on appveyor
    • Fix broken link in docs left hand side menu bar
    Source code(tar.gz)
    Source code(zip)
  • 4.4.3(Aug 19, 2015)

    Enhancements

    • Update the readme fixing dead links
    • Use new Travis CI containers for faster builds
    • Add CI tests on Windows using Appveyor

    Fixes

    • Remove reference cycles from various objects to fix memory leaks.
    • Add unittest that provides an API to test garbage collection.
    • Fix the LUT manager to select the correct lut mode for QT backend
    • Use the python-wxtool package to speed up Travis CI build
    • Fix TVTK wrapper to allow look up with long keys for Points
    • Fix glyph to handle the masking of input points
    • Update the docs with known bugs, issues list and describe the PR workflow on github for development and documentation.
    • Fix TVTK wrapper to update number of cells when a cell is inserted in a VTK cell array
    • Fix VKTFileReader to update output when using standalone
    • Fix the sdist command
    Source code(tar.gz)
    Source code(zip)
  • 4.4.2(Jun 18, 2015)

collection of interesting Computer Science resources

collection of interesting Computer Science resources

Kirill Bobyrev 137 Dec 22, 2022
Statsmodels: statistical modeling and econometrics in Python

About statsmodels statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics an

statsmodels 8.1k Dec 30, 2022
A simple computer program made with Python on the brachistochrone curve.

Brachistochrone-curve This is a simple computer program made with Python on the brachistochrone curve. I decided to write it after a physics lesson on

Diego Romeo 1 Dec 16, 2021
Animation engine for explanatory math videos

Manim is an engine for precise programatic animations, designed for creating explanatory math videos. Note, there are two versions of manim. This repo

Grant Sanderson 48.9k Jan 03, 2023
SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications.

Scientific Computational Imaging COde (SCICO) SCICO is a Python package for solving the inverse problems that arise in scientific imaging applications

Los Alamos National Laboratory 37 Dec 21, 2022
AnuGA for the simulation of the shallow water equation

ANUGA Contents ANUGA What is ANUGA? Installation Documentation and Help Mailing Lists Web sites Latest source code Bug reports Developer information L

Geoscience Australia 147 Dec 14, 2022
ReproZip is a tool that simplifies the process of creating reproducible experiments from command-line executions, a frequently-used common denominator in computational science.

ReproZip ReproZip is a tool aimed at simplifying the process of creating reproducible experiments from command-line executions, a frequently-used comm

267 Jan 01, 2023
Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis

Validated, scalable, community developed variant calling, RNA-seq and small RNA analysis. You write a high level configuration file specifying your in

Blue Collar Bioinformatics 915 Dec 29, 2022
OPEM (Open Source PEM Fuel Cell Simulation Tool)

Table of contents What is PEM? Overview Installation Usage Executable Library Telegram Bot Try OPEM in Your Browser! MATLAB Issues & Bug Reports Contr

ECSIM 133 Jan 04, 2023
PennyLane is a cross-platform Python library for differentiable programming of quantum computers.

PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.

PennyLaneAI 1.6k Jan 04, 2023
3D medical imaging reconstruction software

InVesalius InVesalius generates 3D medical imaging reconstructions based on a sequence of 2D DICOM files acquired with CT or MRI equipments. InVesaliu

443 Jan 01, 2023
An open-source application for biological image analysis

CellProfiler is a free open-source software designed to enable biologists without training in computer vision or programming to quantitatively measure

CellProfiler 734 Jan 08, 2023
Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara

PyMC3 is a Python package for Bayesian statistical modeling and Probabilistic Machine Learning focusing on advanced Markov chain Monte Carlo (MCMC) an

PyMC 7.2k Dec 30, 2022
Zipline, a Pythonic Algorithmic Trading Library

Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backte

Quantopian, Inc. 15.7k Jan 07, 2023
Algorithms covered in the Bioinformatics Course part of the Cambridge Computer Science Tripos

Bioinformatics This is a repository of all the algorithms covered in the Bioinformatics Course part of the Cambridge Computer Science Tripos Algorithm

16 Jun 30, 2022
Wikidata scholarly profiles

Scholia is a python package and webapp for interaction with scholarly information in Wikidata. Webapp As a webapp, it currently runs from Wikimedia To

Finn Årup Nielsen 180 Dec 28, 2022
Open Delmic Microscope Software

Odemis Odemis (Open Delmic Microscope Software) is the open-source microscopy software of Delmic B.V. Odemis is used for controlling microscopes of De

Delmic 32 Dec 14, 2022
A mathematica expression evaluator with PokemonTypes

A simple mathematical expression evaluator that uses Pokemon types to replace symbols.

Arnav Jindal 2 Nov 14, 2021
SeqLike - flexible biological sequence objects in Python

SeqLike - flexible biological sequence objects in Python Introduction A single object API that makes working with biological sequences in Python more

186 Dec 23, 2022
CONCEPT (COsmological N-body CodE in PyThon) is a free and open-source simulation code for cosmological structure formation

CONCEPT (COsmological N-body CodE in PyThon) is a free and open-source simulation code for cosmological structure formation. The code should run on any Linux system, from massively parallel computer

Jeppe Dakin 62 Dec 08, 2022