def __init__(self, model, target_image=None, tau=None):
        """
        Target gray matter segmentation constructor

        :param model: Model used to compute the segmentation, type: Model

        :param target_image: Target image to segment gray matter on, type: Image

        :param tau: Weighting parameter associated with the geodesic distances in the model dictionary, type: float
        """
        self.model = model

        # Get the target image
        self.target = target_image
        '''
        save_image(self.target.data, 'target_image')
        print '---TARGET IMAGE IN CLASS TargetSegmentation : ', self.target.data
        save_image(self.target.data[0],'target_slice0_targetSeg_'+self.model.param.todo_model)
        '''
        self.epsilon = round(1.0/self.model.dictionary.J, 5) - 0.0001  # /2

        if tau is None:
            self.tau = self.compute_tau()
        else:
            self.tau = tau

        self.target_M, self.R_target_to_M = self.target_groupwise_registration()
        self.target_M.file_name = 'target_model_space'
        self.target_M.ext = '.nii.gz'
        # self.target_M.data = self.target_M.data.astype('float32')
        self.target_M.save()

        '''
        print '----- registered target ---- ', self.target_M.data
        save_image(self.target_M.data, 'target_image_model_space')
        save_image(self.target_M.data[0],'target_registered_slice0_rigidreg_'+self.model.param.todo_model)
        '''

        # coord_projected_target is a list of all the coord of the target's projected slices
        sct.printv('\nProjecting the target image in the reduced common space ...', model.param.verbose, 'normal')
        self.coord_projected_target = model.pca.project(self.target_M) if self.target_M is not None else None

        '''
        print '----SHAPE COORD PROJECTED TARGET -----', self.coord_projected_target.shape
        print '----COORD PROJECTED TARGET -----', self.coord_projected_target
        '''

        self.beta = self.compute_beta(self.coord_projected_target, tau=self.tau)
        '''
        print '----------- BETAS :', self.beta
        self.beta = self.compute_beta(self.coord_projected_target, tau=0.00114)
        '''
        sct.printv('\nSelecting the dictionary slices most similar to the target ...', model.param.verbose, 'normal')

        self.selected_k_slices = self.select_k_slices(self.beta)
        '''
        print '----SELECTED K -----', self.selected_k_slices
        print '----SHAPE SELECTED K -----', self.selected_k_slices.shape
        '''
        sct.printv('\nComputing the result gray matter segmentation ...', model.param.verbose, 'normal')
        self.target_GM_seg_M = self.label_fusion(self.selected_k_slices)
        self.target_GM_seg_M.file_name = 'res_gmseg_model_space'
        self.target_GM_seg_M.ext = '.nii.gz'
        # self.target_M.data = self.target_M.data.astype('float32')
        self.target_GM_seg_M.save()
        sct.printv('\nRegistering the result gray matter segmentation back into the target original space...',
                   model.param.verbose, 'normal')
        self.target_GM_seg = self.target_groupwise_registration(inverse=True)

    # ------------------------------------------------------------------------------------------------------------------
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/dev/sct_segment_gray_matter_asman/sct_asman_old.py/TargetSegmentationGroupwise.__init__/original