Пример #1
0
    def get_morphology_exemplars(blue_config, random_selection=False):
        """Returns a list of exemplars where each one represent a category of the different
        morphologies. If the random selection flag is set, then they will be picked up randomly,
        otherwise, the first one of each selected type will be picked.

        :param blue_config:
            A circuit configuration file.
        :param random_selection:
            Randomly selected cells.
        :return:
            A list of exemplars to all the mtypes that exist in the circuit.
        """

        # Import bbp
        try:
            import bbp
        except ImportError:
            print('ERROR: Cannot import brain')
            return None

        # Create an experiment
        bbp_experiment = bbp.Experiment()

        # Open the blue config
        bbp_experiment.open(blue_config)

        # Load the entire mc2_Column in the micro-circuit
        bbp_microcircuit = bbp_experiment.microcircuit()
        bbp_cell_target = bbp_experiment.cell_target('mc2_Column')
        bbp_microcircuit.load(bbp_cell_target, bbp.Loading_Flags.NEURONS)

        # retrieve a list of all the neurons in the circuit
        bbp_neurons = bbp_microcircuit.neurons()

        # create a list of selected exemplars
        exemplars_list = []
        for m_type in nmv.consts.MTYPES:

            # All the cells with that specific m-type
            m_type_cells = []

            # Get all the cells with that specific m-type
            for neuron in bbp_neurons:

                # Get BBP neuron data from the BBP-SDK
                neuron_gid = neuron.gid()
                neuron_m_type = neuron.morphology_type().name()
                if neuron_m_type == m_type:
                    m_type_cells.append([neuron_gid, neuron_m_type])

            # Select a random cell and add it to the exemplars list, otherwise, use the first m-type
            if random_selection:
                exemplars_list.append(random.choice(m_type_cells))
            else:
                exemplars_list.append(m_type_cells[0])

        # Return the exemplars list
        return exemplars_list
Пример #2
0
    def get_neuron_from_gid(blue_config, gid):
        """Return a BBP neuron structure from its input GID.

        :param blue_config:
            Input circuit configuration file.
        :param gid:
            Input neuron GID.
        :return:
            A reference to the BBP neuron
        """

        # Import BBP-SDK module inside the function to avoid the BBP tree complexity for non-BBP
        # morphologies.
        import bbp

        # Create a new experiment
        bbp_experiment = bbp.Experiment()

        # Open the blue-config file
        bbp_experiment.open(blue_config)

        # Create a micro-circuit
        bbp_microcircuit = bbp_experiment.microcircuit()

        # Set the cell target to the given gid
        bbp_cell_target = bbp.Cell_Target()
        bbp_cell_target.insert(int(gid))

        # Load the circuit
        bbp_microcircuit.load(bbp_cell_target, bbp.Loading_Flags.NEURONS)

        # Get the neuron from the microcircuit
        bbp_neuron = bbp_microcircuit.neurons()

        # Return a reference to the BBP neuron
        return bbp_neuron