.. 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_bvProcessSocket.py: Using PyAnatomist in BrainVisa ------------------------------ This example shows how to use Anatomist from a BrainVisa process, and get events from Anatomist even when it is run through a socket connection. .. code-block:: default from __future__ import print_function from __future__ import absolute_import from neuroProcesses import * from brainvisa.tools import aimsGlobals import string name = 'Test anatomist API socket implementation' userLevel = 0 # by default, socket implementation is loaded in brainvisa from brainvisa import anatomist as pyanatomist import anatomist.api signature = Signature( 'object_to_load', ReadDiskItem( "3D Volume", aimsGlobals.anatomistVolumeFormats), ) def initialization(self): pass def execution(self, context): # with attribute create is False, the constructor returns the existing # instance of anatomist or None if there isn't one. a = pyanatomist.Anatomist(create=False) print("anatomist instance:", a) a = pyanatomist.Anatomist(create=True) print("anatomist instance:", a) # register a function to be called when an object is loaded in anatomist a.onLoadNotifier.add(display) # a.onLoadNotifier.remove(display) # a.onCreateWindowNotifier.add(display) # a.onDeleteNotifier.add(display) # a.onFusionNotifier.add(display) # a.onCloseWindowNotifier.add(display) # a.onAddObjectNotifier.add(display) # a.onRemoveObjectNotifier.add(display) # a.onCursorNotifier.add(display) obj = a.loadObject(self.object_to_load) w = a.createWindow('Axial') a.addObjects([obj], [w]) ref = obj.referential context.write("referential of object :", ref.refUuid) return [obj, w, ref] def display(event, params): print("** Event ** ", event, params) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_bvProcessSocket.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: bvProcessSocket.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: bvProcessSocket.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_