예제 #1
0
    def preprocess_node_types(network, node_population):
        NodeAdaptor.preprocess_node_types(network, node_population)

        node_type_ids = np.unique(node_population.type_ids)
        node_types_table = node_population.types_table
        if 'non_dom_params' in node_types_table.columns:
            for nt_id in node_type_ids:
                node_type = node_types_table[nt_id]
                dynamics_params = node_type['non_dom_params']
                if isinstance(dynamics_params, dict):
                    continue

                if dynamics_params is None:
                    continue

                params_dir = network.get_component('filter_models_dir')
                params_path = os.path.join(params_dir, dynamics_params)
                try:
                    params_val = json.load(open(params_path, 'r'))
                    node_type['non_dom_params'] = params_val
                except Exception:
                    # TODO: Check dynamics_params before
                    network.io.log_exception(
                        'Could not find node dynamics_params file {}.'.format(
                            params_path))
예제 #2
0
 def preprocess_node_types(network, node_population):
     NodeAdaptor.preprocess_node_types(network, node_population)
     node_types_table = node_population.types_table
     if 'model_template' in node_types_table.columns and 'dynamics_params' in node_types_table.columns:
         node_type_ids = np.unique(node_population.type_ids)
         for nt_id in node_type_ids:
             node_type_attrs = node_types_table[nt_id]
             mtemplate = node_type_attrs['model_template']
             dyn_params = node_type_attrs['dynamics_params']
             if mtemplate.startswith('nest:glif') and dyn_params.get('type', None) == 'GLIF':
                 node_type_attrs['dynamics_params'] = convert_aibs2nest(mtemplate, dyn_params)
예제 #3
0
    def patch_adaptor(cls, adaptor, node_group, network):
        node_adaptor = NodeAdaptor.patch_adaptor(adaptor, node_group, network)

        if 'non_dom_params' in node_group.all_columns:
            node_adaptor.non_dom_params = types.MethodType(non_dom_params, node_adaptor)
        else:
            node_adaptor.non_dom_params = types.MethodType(return_none, node_adaptor)

        jitter_lower = 'jitter_lower' in node_group.all_columns
        jitter_upper = 'jitter_upper' in node_group.all_columns
        if jitter_lower and jitter_upper:
            node_adaptor.predefined_jitter = True
        elif jitter_upper ^ jitter_lower:
            raise Exception('Need to define both jitter_lower and jitter_upper (or leave both empty)')
        else:
            node_adaptor.predefined_jitter = False

        if 'tuning_angle' in node_group.all_columns:
            node_adaptor.tuning_angle = types.MethodType(tuning_angle_preset, node_adaptor)
        else:
            node_adaptor.tuning_angle = types.MethodType(tuning_angle_rand, node_adaptor)

        find_weight_params(node_group, node_adaptor)
        find_kpeaks_params(node_group, node_adaptor)
        find_delays_params(node_group, node_adaptor)

        find_nondom_weight_params(node_group, node_adaptor)
        find_nondom_kpeaks_params(node_group, node_adaptor)
        find_nondom_delays_params(node_group, node_adaptor)

        return node_adaptor
예제 #4
0
    def patch_adaptor(cls, adaptor, node_group, network):
        node_adaptor = NodeAdaptor.patch_adaptor(adaptor, node_group, network)

        # Position
        if 'positions' in node_group.all_columns:
            node_adaptor.position = types.MethodType(positions, adaptor)
        elif 'position' in node_group.all_columns:
            node_adaptor.position = types.MethodType(position, adaptor)
        else:
            node_adaptor.position = types.MethodType(positions_default,
                                                     adaptor)

        # Rotation angles
        if 'rotation_angle_xaxis' in node_group.all_columns:
            node_adaptor.rotation_angle_xaxis = types.MethodType(
                rotation_angle_x, node_adaptor)
        else:
            node_adaptor.rotation_angle_xaxis = types.MethodType(
                rotation_angle_default, node_adaptor)

        if 'rotation_angle_yaxis' in node_group.all_columns:
            node_adaptor.rotation_angle_yaxis = types.MethodType(
                rotation_angle_y, node_adaptor)
        else:
            node_adaptor.rotation_angle_yaxis = types.MethodType(
                rotation_angle_default, node_adaptor)

        if 'rotation_angle_zaxis' in node_group.all_columns:
            node_adaptor.rotation_angle_zaxis = types.MethodType(
                rotation_angle_z, node_adaptor)
        else:
            node_adaptor.rotation_angle_zaxis = types.MethodType(
                rotation_angle_default, node_adaptor)

        return node_adaptor
예제 #5
0
    def patch_adaptor(adaptor, node_group, network):
        node_adaptor = NodeAdaptor.patch_adaptor(adaptor, node_group, network)

        # If dynamics params is stored in the nodes.h5 then we have to build each node separate
        if node_group.has_dynamics_params:
            node_adaptor.batch_process = False

        # If there is a non-null value in the model_processing column then it potentially means that every cell is
        # uniquly built (currently model_processing is applied to each individ. cell) and nodes can't be batched
        if 'model_processing' in node_group.columns:
            node_adaptor.batch_process = False
        elif 'model_processing' in node_group.all_columns and not all_null(node_group, 'model_processing'):
            node_adaptor.batch_process = False

        if node_adaptor.batch_process:
            io.log_info('Batch processing nodes for {}/{}.'.format(node_group.parent.name, node_group.group_id))

        return node_adaptor