diff --git a/efel/DependencyV5.txt b/efel/DependencyV5.txt index 40df55ef..607c391e 100644 --- a/efel/DependencyV5.txt +++ b/efel/DependencyV5.txt @@ -150,7 +150,7 @@ LibV5:current #LibV1:interpolate LibV5:time #LibV1:interpolate LibV5:steady_state_voltage_stimend #LibV1:interpolate LibV5:voltage_base #LibV1:interpolate -LibV5:current_base +LibV5:current_base #LibV1:interpolate LibV5:decay_time_constant_after_stim #LibV1:interpolate LibV5:sag_time_constant #LibV1:minimum_voltage #LibV5:steady_state_voltage_stimend #LibV5:sag_amplitude #LibV1:interpolate LibV5:multiple_decay_time_constant_after_stim #LibV5:decay_time_constant_after_stim #LibV1:interpolate @@ -172,7 +172,7 @@ LibV5:ADP_peak_indices #LibV5:min_AHP_indices #LibV5:min_between_peaks_indice LibV5:ADP_peak_values #LibV5:ADP_peak_indices #LibV1:interpolate LibV5:ADP_peak_amplitude #LibV5:ADP_peak_values #LibV5:min_AHP_values #LibV1:interpolate LibV5:interburst_min_indices #LibV5:peak_indices #LibV5:burst_end_indices #LibV1:interpolate -LibV5:interburst_min_values #LibV5:interburst_min_indices #LibV1: interpolate +LibV5:interburst_min_values #LibV5:interburst_min_indices #LibV1:interpolate LibV5:postburst_min_indices #LibV5:peak_indices #LibV5:burst_end_indices #LibV1:interpolate -LibV5:postburst_min_values #LibV5:postburst_min_indices #LibV1: interpolate +LibV5:postburst_min_values #LibV5:postburst_min_indices #LibV1:interpolate LibV5:time_to_interburst_min #LibV5:interburst_min_indices #LibV1:peak_time #LibV5:burst_end_indices #LibV1:interpolate diff --git a/efel/cppcore/LibV1.cpp b/efel/cppcore/LibV1.cpp index a45fddcb..a3952534 100644 --- a/efel/cppcore/LibV1.cpp +++ b/efel/cppcore/LibV1.cpp @@ -73,6 +73,15 @@ int LibV1::interpolate(mapStr2intVec& IntFeatureData, setVec(DoubleFeatureData, StringData, "V", VIntrpol); setVec(DoubleFeatureData, StringData, "T", TIntrpol); setVec(IntFeatureData, StringData, "interpolate", intrpolte); + + // also interpolate current if present + vector I, IIntrpol, TIntrpolI; + int retValI; + retValI = getVec(DoubleFeatureData, StringData, "I", I); + if (retValI > 0){ + LinearInterpolation(InterpStep, T, I, TIntrpolI, IIntrpol); + setVec(DoubleFeatureData, StringData, "I", IIntrpol); + } return retVal; } diff --git a/tests/test_pyfeatures.py b/tests/test_pyfeatures.py index 18e2e3b1..4fba7643 100644 --- a/tests/test_pyfeatures.py +++ b/tests/test_pyfeatures.py @@ -152,6 +152,9 @@ def _load_trace(trace_name): 'stim_end': [trace_data['stim_end']], } + if trace_name == "current": + trace['T'] = trace['T'] * 1000.0 # s -> ms + if 'i_col' in trace_data: trace['I'] = efel.io.load_fragment('%s#col=%d' % (url, trace_data['i_col'])) @@ -331,18 +334,6 @@ def test_pydistance_featurefail(): trace_check=True), 250.0) -def test_current(): - """pyfeatures: Test current feature""" - - feature_name = 'current' - data = numpy.loadtxt(os.path.join(os.path.abspath(testdata_dir), - 'basic', - 'current.txt')) - current = data[:, 1] - expected_values = {'current': current} - _test_expected_value(feature_name, expected_values) - - def test_interpolate_current(): """pyfeatures: Test interpolation of current""" @@ -357,16 +348,21 @@ def interpolate(time, voltage, new_dt): data = numpy.loadtxt(os.path.join(os.path.abspath(testdata_dir), 'basic', 'current.txt')) - time = data[:, 0] + time = data[:, 0] * 1000.0 # -> ms current = data[:, 1] voltage = data[:, 2] feature_name = ['time', 'current', 'voltage'] trace = _load_trace('current') - feature_values = efel.getFeatureValues([trace], ['current']) - interp_time, interp_current = interpolate(time, current, new_dt=0.00025) - - assert len(interp_time) == len(time) - assert len(interp_current) == len(current) - assert len(voltage) == len(current) - assert numpy.allclose(interp_current, current) + feature_values = efel.getFeatureValues([trace], feature_name) + feature_time = feature_values[0]["time"] + feature_current = feature_values[0]["current"] + feature_voltage = feature_values[0]["voltage"] + interp_time, interp_current = interpolate(time, current, new_dt=0.1) + _, interp_voltage = interpolate(time, voltage, new_dt=0.1) + + assert len(interp_time) == len(feature_time) + assert len(interp_current) == len(feature_current) + assert len(interp_voltage) == len(feature_voltage) + assert len(feature_voltage) == len(feature_current) + assert numpy.allclose(interp_current, feature_current, atol=1e-6)