How to set the settings ======================= A lot of features in efel can have their behaviour changed with settings, in order to be more customisable, depending on the traces and the need of the user. Here, we are going to see how to change the settings with an exmaple, and where to find the list of all the settings in efel with their default values. For this example, we are going to use a trace of a cell model with a bAP (backpropagating action potential) stimulus, recorded in the dendrite. .. code:: ipython3 import efel import numpy import json %matplotlib notebook %matplotlib inline from matplotlib import pyplot as plt plt.rcParams['figure.figsize'] = 10, 10 test_url = '../../tests/testdata/allfeatures/testbap2data.txt' test_data = numpy.loadtxt(test_url) time = test_data[:,0] voltage = test_data[:, 1] We can now plot this data .. code:: ipython3 plt.rcParams['figure.figsize'] = 10, 10 fig1, ax1 = plt.subplots(1) ax1.plot(time, voltage) ax1.set_xlabel('Time (ms)') ax1.set_ylabel('Membrane voltage (mV)'); .. image:: settings_notebook_files/settings_notebook_4_0.png Now, let us extract the peak time. We expect one value shortly after 300 ms. .. code:: ipython3 stim_start = 295 stim_end = 500 trace = {'T': time, 'V': voltage, 'stim_start': [stim_start], 'stim_end': [stim_end]} feature_values = efel.get_feature_values([trace], ['peak_time'])[0] print(f'Spike detection threshold is {efel.get_settings().Threshold} mV.') print(feature_values) .. parsed-literal:: Spike detection threshold is -20.0 mV. {'peak_time': None} .. parsed-literal:: /path/to/efel/pyfeatures/cppfeature_access.py:14: RuntimeWarning: Error while calculating peak_time, An error occurred while computing the feature, feature is not found. Voltage never goes below or above threshold in spike detection. warnings.warn( We can see that we don’t have any value returned. The reason is that, by default, eFEL looks for spikes that go above -20 mV. This is fine for most cells when recorded in the soma, but here, we are recording a spike in the dendrite after a soma stimulus. This spike has a smaller amplitude than the one in the soma, and is thus below the spike-detecting threshold. This can be solved by modifying the settings, using the easy to use set_setting function! By simply modifying the default threshold value of -20 to a lower value, e.g. -30, the spike gets detected! .. code:: ipython3 efel.api.set_setting('Threshold', -30.) feature_values = efel.get_feature_values([trace], ['peak_time'])[0] print(feature_values) .. parsed-literal:: {'peak_time': array([304.])} If you want to see the current settings, you can do so by using the get_settings function: .. code:: ipython3 print(efel.get_settings()) .. parsed-literal:: Threshold: -30.0 DerivativeThreshold: 10.0 DownDerivativeThreshold: -12.0 dependencyfile_path: /path/to/efel/DependencyV5.txt spike_skipf: 0.1 max_spike_skip: 2 interp_step: 0.1 burst_factor: 1.5 strict_burst_factor: 2.0 voltage_base_start_perc: 0.9 voltage_base_end_perc: 1.0 current_base_start_perc: 0.9 current_base_end_perc: 1.0 rise_start_perc: 0.0 rise_end_perc: 1.0 initial_perc: 0.1 min_spike_height: 20.0 strict_stiminterval: False initburst_freq_threshold: 50 initburst_sahp_start: 5 initburst_sahp_end: 100 DerivativeWindow: 3 voltage_base_mode: mean current_base_mode: mean precision_threshold: 1e-10 sahp_start: 5.0 ignore_first_ISI: True impedance_max_freq: 50.0 AP_phaseslope_range: 2 inactivation_tc_end_skip: 10 You can reset the settings to their default value at any time using the reset() function. It is good practice to use it whenever you want to change the settings, in order to be sure that previously set settings are not interfering with your new settings. .. code:: ipython3 efel.reset() The settings can also be passed down to efel by passing them through the trace dictionary, inside a list: .. code:: ipython3 trace['Threshold'] = [-30.] feature_values = efel.get_feature_values([trace], ['peak_time'])[0] print(feature_values) .. parsed-literal:: {'peak_time': array([304.])} The complete list of settings and their default value can be found in the documentation of `the Settings class here `__