# -*- coding: utf-8 -*- # This software and supporting documentation are distributed by # Institut Federatif de Recherche 49 # CEA/NeuroSpin, Batiment 145, # 91191 Gif-sur-Yvette cedex # France # # This software is governed by the CeCILL license version 2 under # French law and abiding by the rules of distribution of free software. # You can use, modify and/or redistribute the software under the # terms of the CeCILL license version 2 as circulated by CEA, CNRS # and INRIA at the following URL "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license version 2 and that you accept its terms. from brainvisa.processes import * from brainvisa import anatomist name = 'Anatomist Show Bundles' roles = ( 'viewer', ) userLevel = 0 signature = Signature( 'bundles', ReadDiskItem( 'Bundles', 'Aims Bundles' ), 'rgb_eigenvector', ReadDiskItem( 'RGB Eigenvector', 'Aims readable volume formats'), 'width', Float(), 'minimum_length', Float(), 'save_result', Boolean(), 'bundles_graph', WriteDiskItem( 'Curves graph', 'Graph and data' ), ) def validation(): anatomist.validation() def stringParameters( **kwargs ): return str( kwargs ) def initialization( self ): self.width = 0 self.minimum_length = 0 self.save_result = 0 self.linkParameters( 'bundles_graph', 'bundles' ) self.linkParameters('rgb_eigenvector', 'bundles' ) self.setOptional( 'bundles_graph' ) self.setOptional("rgb_eigenvector") def execution( self, context ): if self.save_result: bundles_graph = self.bundles_graph if bundles_graph is None: raise RuntimeError( _t_( 'No value for %s') % ('bundles_graph') ) else: bundles_graph = context.temporary( 'Graph and data' ) command = [ 'comistBundleAnalysis_old', '-i', self.bundles, '-g', bundles_graph.fullPath() + stringParameters( width = self.width, minimum_length = self.minimum_length ) ] context.system( *command ) a = anatomist.Anatomist() bundles_object = a.loadObject( bundles_graph.fullPath() ) # Set 50% transparency on the bundles without lighting bundles_object.setMaterial( a.Material( diffuse=[0, 0, 0.8, 0.5], lighting=0 ) ) window = a.createWindow( '3D' ) browser = a.createWindow( 'Browser' ) rgb_object=None if self.rgb_eigenvector: rgb_object=a.loadObject( self.rgb_eigenvector) ref=rgb_object.referential if ref != a.centralRef: bundles_object.assignReferential(ref) window.assignReferential(ref) window.addObjects(rgb_object) a.addObjects( windows=( window, browser ), objects=( bundles_object, ) ) # Select all nodes of bundles_object to make fibers visible objects_to_select=bundles_object.children window.group.addToSelection( objects_to_select ) # Unselect objects to give them their real color window.group.unSelect( objects_to_select ) return ( bundles_object, bundles_graph, window, browser, rgb_object )