コード例 #1
0
ファイル: api.py プロジェクト: orena1/eFEL
def _initialise():
    """Set cppcore initial values"""
    cppcore.Initialize(_settings.dependencyfile_path, "log")

    # First set some settings that are used by the feature extraction

    for setting_name, int_setting in list(_int_settings.items()):
        cppcore.setFeatureInt(setting_name, [int_setting])

    for setting_name, double_setting in list(_double_settings.items()):
        cppcore.setFeatureDouble(setting_name, [double_setting])
コード例 #2
0
ファイル: api.py プロジェクト: tmchartrand/eFEL
def _initialise():
    """Set cppcore initial values"""
    cppcore.Initialize(_settings.dependencyfile_path, "log")

    # First set some settings that are used by the feature extraction

    for setting_name, int_setting in list(_int_settings.items()):
        cppcore.setFeatureInt(setting_name, [int_setting])

    for setting_name, double_setting in list(_double_settings.items()):
        cppcore.setFeatureDouble(setting_name, [double_setting])
コード例 #3
0
ファイル: api.py プロジェクト: wvangeit/eFEL
def _initialise():
    """Set cppcore initial values"""
    cppcore.Initialize(_settings.dependencyfile_path, "log")

    # First set some settings that are used by the feature extraction
    cppcore.setFeatureDouble('spike_skipf', [0.1])
    cppcore.setFeatureInt('max_spike_skip', [2])
    cppcore.setFeatureDouble('Threshold', [_settings.threshold])
    cppcore.setFeatureDouble('DerivativeThreshold',
                             [_settings.derivative_threshold])
    cppcore.setFeatureDouble('interp_step', [0.1])
    cppcore.setFeatureDouble('burst_factor', [1.5])
    cppcore.setFeatureDouble("initial_perc", [0.1])
コード例 #4
0
ファイル: api.py プロジェクト: luis-rr/eFEL
def _initialise():
    """Set cppcore initial values"""
    cppcore.Initialize(_settings.dependencyfile_path, "log")

    # First set some settings that are used by the feature extraction
    cppcore.setFeatureDouble('spike_skipf', [0.1])
    cppcore.setFeatureInt('max_spike_skip', [2])
    cppcore.setFeatureDouble('Threshold',
                             [_settings.threshold])
    cppcore.setFeatureDouble('DerivativeThreshold',
                             [_settings.derivative_threshold])
    cppcore.setFeatureDouble('interp_step', [0.1])
    cppcore.setFeatureDouble('burst_factor', [1.5])
    cppcore.setFeatureDouble("initial_perc", [0.1])
コード例 #5
0
ファイル: api.py プロジェクト: gitter-badger/eFEL
def getFeatureValues(traces, featureNames):
    """Calculate feature values for a list of traces.

    This function is the core of the eFEL API. A list of traces (in the form
    of dictionaries) is passed as argument, together with a list of feature
    names. 

    The return value consists of a list of dictionaries, one for each input
    trace. The keys in the dictionaries are the names of the calculated 
    features, the corresponding values are lists with the feature values.
    Beware that every feature returns an array of values. E.g. AP_amplitude
    will return a list with the amplitude of every action potential.

    Parameters
    ==========
    traces : list of trace dicts
             Every trace dict represent one trace. The dict should have the
             following keys: 'T', 'V', 'stim_start', 'stim_end'
    feature_names : list of string
                  List with the names of the features to be calculated on all
                  the traces.
    Returns
    =======
    feature_values : list of dicts
                     For every input trace a feature value dict is return (in
                     the same order). The dict contains the keys of
                     'feature_names', every key contains a numpy array with
                     the feature values returned by the C++ efel code.
                     The value is None if an error occured during the 
                     calculation of the feature.
    """
    featureDicts = []

    for trace in traces:
        featureDict = {}

        if 'stim_start' in trace and 'stim_end' in trace:
            if len(trace['stim_start']) == 1 and len(trace['stim_end']) == 1:
                if trace['stim_end'][0] <= trace['stim_start'][0]:
                    raise Exception(
                        'stim_end needs to be larger than '
                        'stim_start:\nstim_start=%f stim_end=%f' %
                        (trace['stim_start'][0], trace['stim_end'][0]))
            else:
                raise Exception('stim_start and stim_end in the trace '
                                'dictionary need to be lists of 1 element')

        else:
            raise Exception('stim_start or stim_end missing from trace')

        cppcore.Initialize(_settings.dependencyfile_path, "log")

        # First set some settings that are used by the feature extraction
        cppcore.setFeatureDouble('spike_skipf', [0.1])
        cppcore.setFeatureInt('max_spike_skip', [2])
        cppcore.setFeatureDouble('Threshold',
                                 [_settings.threshold])
        cppcore.setFeatureDouble('DerivativeThreshold',
                                 [_settings.derivative_threshold])
        cppcore.setFeatureDouble('interp_step', [0.1])
        cppcore.setFeatureDouble('burst_factor', [1.5])
        cppcore.setFeatureDouble("initial_perc", [0.1])

        # Next set time, voltage and the stimulus start and end
        for item in trace.keys():
            cppcore.setFeatureDouble(item, [x for x in trace[item]])

        for featureName in featureNames:
            featureType = cppcore.featuretype(featureName)
            if featureType == "double":
                cppcoreFeatureValues = list()
                try:
                    exitCode = cppcore.getFeatureDouble(
                        featureName,
                        cppcoreFeatureValues)
                except:
                    exitCode = -1
            elif featureType == "int":
                cppcoreFeatureValues = list()
                exitCode = cppcore.getFeatureInt(
                    featureName,
                    cppcoreFeatureValues)
            else:
                print "Feature %s has an unknown type: %s" % \
                    (featureName, featureType)
                exit(1)
            if exitCode < 0:
                import warnings
                warnings.warn(
                    "Error while calculating feature %s: %s" %
                    (featureName, cppcore.getgError()),
                    RuntimeWarning)
                featureDict[featureName] = None
            else:
                featureDict[featureName] = numpy.array(cppcoreFeatureValues)

        featureDicts.append(featureDict)
    return featureDicts