Exemple #1
0
    def generate_kernels(self, regenerate=False, lmax=12, ndirs=32761):
        """Generate the high-resolution response functions for each compartment.
        Dispatch to the proper function, depending on the model.

        Parameters
        ----------
        regenerate : boolean
            Regenerate kernels if they already exist (default : False)
        lmax : int
            Maximum SH order to use for the rotation procedure (default : 12)
        ndirs : int
            Number of directions on the half of the sphere representing the possible orientations of the response functions (default : 32761)
         """
        if self.scheme is None:
            ERROR('Scheme not loaded; call "load_data()" first')
        if self.model is None:
            ERROR('Model not set; call "set_model()" method first')
        if not is_valid(ndirs):
            ERROR(
                'Unsupported value for ndirs.\nNote: Supported values for ndirs are [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 32761 (default)]'
            )

        # store some values for later use
        self.set_config('lmax', lmax)
        self.set_config('ndirs', ndirs)
        self.model.scheme = self.scheme
        LOG('\n-> Creating LUT for "%s" model:' % self.model.name)

        # check if kernels were already generated
        tmp = glob.glob(pjoin(self.get_config('ATOMS_path'), 'A_*.npy'))
        if len(tmp) > 0 and not regenerate:
            LOG('   [ LUT already computed. USe option "regenerate=True" to force regeneration ]'
                )
            return

        # create folder or delete existing files (if any)
        if not exists(self.get_config('ATOMS_path')):
            makedirs(self.get_config('ATOMS_path'))
        else:
            for f in glob.glob(pjoin(self.get_config('ATOMS_path'), '*')):
                remove(f)

        # auxiliary data structures
        aux = amico.lut.load_precomputed_rotation_matrices(lmax, ndirs)
        idx_IN, idx_OUT = amico.lut.aux_structures_generate(self.scheme, lmax)

        # Dispatch to the right handler for each model
        tic = time.time()
        self.model.generate(self.get_config('ATOMS_path'), aux, idx_IN,
                            idx_OUT, ndirs)
        LOG('   [ %.1f seconds ]' % (time.time() - tic))
Exemple #2
0
def setup( lmax = 12, ndirs = 32761 ) :
    """General setup/initialization of the AMICO framework.
    
    Parameters
    ----------
    lmax : int
        Maximum SH order to use for the rotation phase (default : 12)
    ndirs : int
        Number of directions on the half of the sphere representing the possible orientations of the response functions (default : 32761)
    """
    if not is_valid(ndirs):
        ERROR( 'Unsupported value for ndirs.\nNote: supported values for ndirs are [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 32761 (default)]' )
    
    amico.lut.precompute_rotation_matrices( lmax, ndirs )