Exemplo n.º 1
0
def ads_with_equal_stimulus_type(dsv, allow_None=False):
    """
    This functions tests whether DSV contains only ADS associated
    with the same stimulus type.
    
    Parameters
    ----------
    not_None : bool
             If true it will not allow ADS that are not associated with stimulus
    """
    if allow_None:
        return matching_parametrized_object_params([
            MozaikParametrized.idd(ads.stimulus_id)
            for ads in dsv.analysis_results if ads.stimulus_id != None
        ],
                                                   params=['name'])
    else:
        if len([0 for ads in dsv.analysis_results if ads.stimulus_id == None
                ]) > 0:
            return False
        return matching_parametrized_object_params([
            MozaikParametrized.idd(ads.stimulus_id)
            for ads in dsv.analysis_results
        ],
                                                   params=['name'])
Exemplo n.º 2
0
def equal_ads_except(dsv,except_params):
    """
    This functions returns true if DSV contains only ADS of the same kind
    and parametrization with the exception of parameters listed in
    except_params. Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,except_params=except_params)
Exemplo n.º 3
0
 def __init__(self, datastore, parameters, plot_file_name=None,fig_param=None):
     Plotting.__init__(self, datastore, parameters, plot_file_name, fig_param)
     
     self.st = []
     self.tc_dict = []
     self.pnvs = []
     self.max_mean_response_indexes = []
     assert queries.ads_with_equal_stimulus_type(datastore)
     assert len(self.parameters.neurons) > 0 , "ERROR, empty list of neurons specified"
     dsvs = queries.partition_analysis_results_by_parameters_query(self.datastore,parameter_list=['value_name'],excpt=True)
     for dsv in dsvs:
         dsv = queries.param_filter_query(dsv,identifier='PerNeuronValue',sheet_name=self.parameters.sheet_name)
         assert matching_parametrized_object_params(dsv.get_analysis_result(), params=['value_name'])
         self.pnvs.append(dsv.get_analysis_result())
         # get stimuli
         st = [MozaikParametrized.idd(s.stimulus_id) for s in self.pnvs[-1]]
         self.st.append(st)
         # transform the pnvs into a dictionary of tuning curves along the parameter_name
         # also make sure the values are ordered according to ids in the first pnv
         dic = colapse_to_dictionary([z.get_value_by_id(self.parameters.neurons) for z in self.pnvs[-1]],st,self.parameters.parameter_name)
         #sort the entries in dict according to the parameter parameter_name values 
         for k in  dic:
             (b, a) = dic[k]
             par, val = zip(
                          *sorted(
                             zip(b,
                                 numpy.array(a))))
             dic[k] = (par,numpy.array(val))
         self.tc_dict.append(dic)
         if self.parameters.centered:
            self.max_mean_response_indexes.append(numpy.argmax(sum([a[1] for a in dic.values()]),axis=0))
Exemplo n.º 4
0
def ads_with_equal_stimulus_type(dsv, allow_None=False):
    """
    This functions tests whether DSV contains only ADS associated
    with the same stimulus type.
    
    Parameters
    ----------
    not_None : bool
             If true it will not allow ADS that are not associated with stimulus
    """
    if allow_None:
        return matching_parametrized_object_params([MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results if ads.stimulus_id != None],params=['name'])
    else:
        if len([0 for ads in dsv.analysis_results if ads.stimulus_id == None]) > 0:
           return False
        return matching_parametrized_object_params([MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results],params=['name'])    
Exemplo n.º 5
0
def equal_ads(dsv,params=None,except_params=None):
    """
    This functions returns true if DSV contains only ADS of the same kind
    and with the same values for parameters supplied in *params* or 
    with the exception of parameters listed in *except_params*. 
    Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,params=params,except_params=except_params)
Exemplo n.º 6
0
def ads_with_equal_stimuli(dsv,params=None,except_params=None):
    """
    This functions returns true if DSV contains only ADS associated with stimuli 
    of the same kind and with the same values for parameters supplied in *params* or 
    with the exception of parameters listed in *except_params*. 
    Otherwise False.
    """
    return matching_parametrized_object_params([MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results],params=params,except_params=except_params)
Exemplo n.º 7
0
def equal_ads(dsv,params=None,except_params=None):
    """
    This functions returns true if DSV contains only ADS of the same kind
    and with the same values for parameters supplied in *params* or 
    with the exception of parameters listed in *except_params*. 
    Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,params=params,except_params=except_params)
Exemplo n.º 8
0
def equal_ads_except(dsv, except_params):
    """
    This functions returns true if DSV contains only ADS of the same kind
    and parametrization with the exception of parameters listed in
    except_params. Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,
                                               except_params=except_params)
Exemplo n.º 9
0
def equal_stimulus_type(dsv):
    """
    This functions returns True if DSV contains only recordings associated
    with the same stimulus type. Otherwise False.
    """
    return matching_parametrized_object_params(
        [MozaikParametrized.idd(s) for s in dsv.get_stimuli()],
        params=['name'])
Exemplo n.º 10
0
def equal_stimulus(dsv, except_params):
    """
    This functions returns True if DSV contains only recordings associated
    with stimuli of identical parameter values, with the exception of parameters in *except_params*
    """
    return matching_parametrized_object_params(
        [MozaikParametrized.idd(s) for s in dsv.get_stimuli()],
        except_params=['name'])
Exemplo n.º 11
0
def ads_with_equal_stimuli(dsv,params=None,except_params=None):
    """
    This functions returns true if DSV contains only ADS associated with stimuli 
    of the same kind and with the same values for parameters supplied in *params* or 
    with the exception of parameters listed in *except_params*. 
    Otherwise False.
    """
    return matching_parametrized_object_params([MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results],params=params,except_params=except_params)
Exemplo n.º 12
0
def partition_analysis_results_by_stimulus_parameters_query(
        dsv, parameter_list=None, excpt=False):
    """
        This query will take all analysis results and return list of DataStoreViews
        each holding analysis results that have the same values of
        of stimulus parameters in parameter_list.

        Note that in most cases one wants to do this only against datastore holding
        only analysis results  measured to the same stimulus type! In that case the datastore is partitioned into
        subsets each holding recordings to the same stimulus with the same paramter
        values, with the exception to the parameters in parameter_list.
    
        Parameters
        ----------
        
        dsv : DataStoreView
            The input DSV.
        
        parameter_list : list(string)
               The list of stimulus parameters that will vary between the ASDs in the returned DSVs, all other parameters will have the same value within each of the 
               returned DSVs.

        except : bool
               If excpt is True the query is allowed only on DSVs holding the same AnalysisDataStructures type.
        """
    if dsv.analysis_results == []: return []

    for ads in dsv.analysis_results:
        assert ads.stimulus_id != None, "partition_analysis_results_by_stimulus_parameters_query accepts only DSV with ADS that all have defined stimulus id"

    st = [
        MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results
    ]
    assert parameter_list != None, "parameter_list has to be given"
    assert type(parameter_list) == list, "parameter_list has to be list"

    if excpt:
        assert matching_parametrized_object_params(
            st, params=['name']
        ), "If excpt==True you have to provide a dsv containing the same ADS type"
        parameter_list = set(
            st[0].getParams().keys()) - (set(parameter_list) | set(['name']))

    values, st = colapse(dsv.analysis_results,
                         st,
                         parameter_list=parameter_list,
                         allow_non_identical_objects=True)
    dsvs = []

    for vals in values:
        new_dsv = dsv.fromDataStoreView()
        new_dsv.block.segments = dsv.recordings_copy()
        new_dsv.sensory_stimulus = dsv.sensory_stimulus_copy()
        new_dsv.analysis_results.extend(vals)
        dsvs.append(new_dsv)
    return dsvs
Exemplo n.º 13
0
def partition_analysis_results_by_stimulus_parameters_query(dsv,parameter_list=None,excpt=False):
        """
        This query will take all analysis results and return list of DataStoreViews
        each holding analysis results that have the same values of
        of stimulus parameters in parameter_list.

        Note that in most cases one wants to do this only against datastore holding
        only analysis results  measured to the same stimulus type! In that case the datastore is partitioned into
        subsets each holding recordings to the same stimulus with the same paramter
        values, with the exception to the parameters in parameter_list.
    
        Parameters
        ----------
        
        dsv : DataStoreView
            The input DSV.
        
        parameter_list : list(string)
               The list of stimulus parameters that will vary between the ASDs in the returned DSVs, all other parameters will have the same value within each of the 
               returned DSVs.

        except : bool
               If excpt is True the query is allowed only on DSVs holding the same AnalysisDataStructures type.
        """
        if dsv.analysis_results == []: return []
            
        for ads in dsv.analysis_results:
            assert ads.stimulus_id != None , "partition_analysis_results_by_stimulus_parameters_query accepts only DSV with ADS that all have defined stimulus id"
            
        st = [MozaikParametrized.idd(ads.stimulus_id) for ads in dsv.analysis_results]
        assert parameter_list != None , "parameter_list has to be given"
        assert type(parameter_list) == list , "parameter_list has to be list"
        
        if excpt:
            assert matching_parametrized_object_params(st,params=['name']), "If excpt==True you have to provide a dsv containing the same ADS type"
            parameter_list = set(st[0].params().keys()) - (set(parameter_list) | set(['name']))
        
        
        
        values, st = colapse(dsv.analysis_results,st,parameter_list=parameter_list,allow_non_identical_objects=True)
        dsvs = []

        for vals in values:
            new_dsv = dsv.fromDataStoreView()
            new_dsv.block.segments = dsv.recordings_copy()
            new_dsv.sensory_stimulus = dsv.sensory_stimulus_copy()
            new_dsv.analysis_results.extend(vals)
            dsvs.append(new_dsv)
        return dsvs
Exemplo n.º 14
0
def equal_stimulus(dsv,except_params):
    """
    This functions returns True if DSV contains only recordings associated
    with stimuli of identical parameter values, with the exception of parameters in *except_params*
    """
    return matching_parametrized_object_params([MozaikParametrized.idd(s) for s in dsv.get_stimuli()],except_params=['name'])
Exemplo n.º 15
0
def equal_ads_type(dsv):
    """
    Returns True if the dsv contains ADS of the same type. Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,
                                               params=['name'])
Exemplo n.º 16
0
def equal_ads_type(dsv):
    """
    Returns True if the dsv contains ADS of the same type. Otherwise False.
    """
    return matching_parametrized_object_params(dsv.analysis_results,params=['name'])
Exemplo n.º 17
0
def equal_stimulus_type(dsv):
    """
    This functions returns True if DSV contains only recordings associated
    with the same stimulus type. Otherwise False.
    """
    return matching_parametrized_object_params([MozaikParametrized.idd(s) for s in dsv.get_stimuli()],params=['name'])