[docs]defcall_method(self,results:sim_results,**kwargs)->float:""" Returns the spike number from a simulation result """if"V_mem_raster_position"notinresults:results.rasterize("V_mem")pos=results["V_mem_raster_position"]M=len(results["x_rec"])-1# pos starts at 0i_first_pos=np.where(pos==0)i_last_pos=np.where(pos==M)cost=(len(i_first_pos[0])+len(i_last_pos[0]))/2returncost
[docs]classrecrutement_count_CE(cost_evaluation):r""" Callable object which returns the number of triggered fibre in the results Parameters ---------- reverse : bool if True, the final cost is the difference between the number total of fibre and the number of activate fibre Note ---- if reverse is false: .. math:: cost = N_{recruited} else: .. math:: cost = N_{total} - N_{recruited} """
[docs]defcall_method(self,results:sim_results,**kwargs)->float:""" Returns the spike number from a simulation result Parameters ---------- results : dict output of an axon simulation using Markov model for at least a node Returns ------- cost :int number of spike in the v_mem part """cost=0ifisinstance(results,axon_results):cost=self.count_axon_activation(results)else:cost=results.get_recruited_axons(ax_type="all",normalize=False)ifself.reverse:cost=results.n_ax-costreturncost
[docs]classcharge_quantity_CE(cost_evaluation):r""" Create a callable object which return a value proportionnal to the charge quantity injected by stimulus. .. math:: cost = \sum_{e}\sum_{t_k}{i_{e,stim}(t_k)} with :math:`t_k` is the discrete time step of the simulation """
[docs]classstim_energy_CE(cost_evaluation):r""" Create a callable object which return a value proportionnal to the stimulus energy, assuming the electrode impedance is a constant. .. math:: cost = \sum_{e}\sum_{t_k}{i_{e,stim}^2(t_k)} with :math:`t_k` is the discrete time step of the simulation Parameters ---------- id_elec : None | int | list[int] id or list id of the electrode of the to from which the energy should be computed. If None, dt_res : float resolotion time step use to compute the cost value """