# 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 * name = 'Diffusion model' userLevel = 0 signature=Signature( 't2_diffusion', ReadDiskItem( 'T2 Diffusion MR', 'Aims readable volume formats' ), 'dw_diffusion', ReadDiskItem( 'DW Diffusion MR', 'Aims readable volume formats' ), 'mask', ReadDiskItem( 'Diffusion mask', 'Aims readable volume formats' ), 'model_type', Choice( "DTI", "QBall" ), 'diffusion_model', WriteDiskItem( 'Diffusion Model', 'Bucket'), ) def modelTypeChange(self, model_type): if self.model_type == "DTI": self._executionNode.DiffusionDTIModel.setSelected( True ) self._executionNode.DiffusionQBallModel.setSelected( False ) else: self._executionNode.DiffusionDTIModel.setSelected( True ) self._executionNode.DiffusionQBallModel.setSelected( True ) def modelSelected(self, model): if model == self._executionNode.DiffusionDTIModel: # DTI process selection changed #the dti model is the output model if only dti process is selected #so when selecting dti process, links to diffusion_model parameter are added only if qball process is not selected if model._selected and not self._executionNode.DiffusionQBallModel._selected: self._executionNode.addLink('diffusion_model', 'DiffusionDTIModel.diffusion_model' ) self._executionNode.addLink('DiffusionDTIModel.diffusion_model', 'diffusion_model' ) self.diffusion_model=model.diffusion_model self.model_type="DTI" else: # QBall process selection changed if model._selected: # if qball process is selected, qball model is the output model self._executionNode.addLink('diffusion_model', 'DiffusionQBallModel.diffusion_model' ) self._executionNode.addLink('DiffusionQBallModel.diffusion_model', 'diffusion_model' ) self._executionNode.removeLink('diffusion_model', 'DiffusionDTIModel.diffusion_model' ) self._executionNode.removeLink('DiffusionDTIModel.diffusion_model', 'diffusion_model' ) self.diffusion_model=model.diffusion_model self.model_type="QBall" else: self._executionNode.removeLink('diffusion_model', 'DiffusionQBallModel.diffusion_model' ) self._executionNode.removeLink('DiffusionQBallModel.diffusion_model', 'diffusion_model' ) # when deselecting qball process, dti model becomes the output model if the dti process is selected if self._executionNode.DiffusionDTIModel._selected: self._executionNode.addLink('diffusion_model', 'DiffusionDTIModel.diffusion_model' ) self._executionNode.addLink('DiffusionDTIModel.diffusion_model', 'diffusion_model' ) self.diffusion_model=self._executionNode.DiffusionDTIModel.diffusion_model self.model_type="DTI" def initialization( self ): self.setOptional( 'mask') # Create execution tree eNode = SerialExecutionNode( self.name, parameterized=self ) eNode.addChild( 'DiffusionDTIModel', ProcessExecutionNode( 'DiffusionDTIModel', optional=True, selected=True ) ) eNode.addChild( 'DiffusionQBallModel', ProcessExecutionNode( 'DiffusionQBallModel', optional=True, selected=False ) ) eNode.addLink(None, "model_type", self.modelTypeChange ) # Link 'DTI' parameters eNode.addLink( 't2_diffusion', 'DiffusionDTIModel.t2_diffusion' ) eNode.addLink( 'DiffusionDTIModel.t2_diffusion', 't2_diffusion' ) eNode.addLink( 'dw_diffusion', 'DiffusionDTIModel.dw_diffusion' ) eNode.addLink( 'DiffusionDTIModel.dw_diffusion', 'dw_diffusion' ) eNode.addLink( 'mask', 'DiffusionDTIModel.mask' ) eNode.addLink( 'DiffusionDTIModel.mask', 'mask' ) # default model type is DTI so links are initialized with dti model eNode.addLink( 'diffusion_model', 'DiffusionDTIModel.diffusion_model' ) eNode.addLink( 'DiffusionDTIModel.diffusion_model', 'diffusion_model' ) # Link 'QBall' parameters eNode.addLink( 't2_diffusion', 'DiffusionQBallModel.t2_diffusion' ) eNode.addLink( 'DiffusionQBallModel.t2_diffusion', 't2_diffusion' ) eNode.addLink( 'dw_diffusion', 'DiffusionQBallModel.dw_diffusion' ) eNode.addLink( 'DiffusionQBallModel.dw_diffusion', 'dw_diffusion' ) eNode.addLink( 'mask', 'DiffusionQBallModel.mask' ) eNode.addLink( 'DiffusionQBallModel.mask', 'mask' ) #eNode.addLink( 'diffusion_model', 'DiffusionQBallModel.diffusion_model' ) #eNode.addLink( 'DiffusionQBallModel.diffusion_model', 'diffusion_model' ) eNode.DiffusionDTIModel._selectionChange.add( self.modelSelected ) eNode.DiffusionQBallModel._selectionChange.add( self.modelSelected ) self.setExecutionNode( eNode )