.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/aimsvolumetest.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_aimsvolumetest.py: AIMS / Anatomist volume manipulation ==================================== Loading, handling and viewing a Volume with aims and anatomist .. GENERATED FROM PYTHON SOURCE LINES 39-109 .. image-sg:: /auto_examples/images/sphx_glr_aimsvolumetest_001.png :alt: aimsvolumetest :srcset: /auto_examples/images/sphx_glr_aimsvolumetest_001.png :class: sphx-glr-single-img .. code-block:: default from __future__ import absolute_import import anatomist.direct.api as anatomist from soma import aims from soma.qt_gui.qt_backend import Qt import sys # load any volume as a aims.Volume_* object vol = aims.read('irm.ima') runloop = False if Qt.QApplication.instance() is None: runloop = True # initialize Anatomist a = anatomist.Anatomist() # convert the carto volume to Anatomist API avol = a.toAObject(vol) avol.releaseAppRef() win = a.createWindow('Axial') # put volume in window win.addObjects(avol) # volume change and update test # using Numeric API arr = vol.arraydata() # we're just printing a white square in the middle of the volume arr[0, 50:70, 100:130, 100:130] = 255 # update Anatomist object and its views avol.setChanged() avol.notifyObservers() # fusion test # have a second volume. We could have loaded another one # (and it would have been nicer on screen). This example also # shows the ability to share the volume data with multiple anatomist/aims # objects avol2 = a.toAObject(vol) avol2.releaseAppRef() # set a different palette on the second object so we can see something a.setObjectPalette(avol2, 'Blue-Red-fusion') # another view win2 = a.createWindow('Axial') a.addObjects(avol2, win2) # create the fusion object fus = a.fusionObjects([avol, avol2], 'Fusion2DMethod') # show it win3 = a.createWindow('Sagittal') a.addObjects(fus, win3) # display in matplotlib for sphinx_gallery win3.sphinx_gallery_snapshot() if runloop and 'sphinx_gallery' not in sys.modules: Qt.QApplication.instance().exec_() if runloop or 'sphinx_gallery' in sys.modules: del win, win2, win3, fus, avol, arr, avol2 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.996 seconds) .. _sphx_glr_download_auto_examples_aimsvolumetest.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: aimsvolumetest.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: aimsvolumetest.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_