def sed_to_group_current(fine_time, fine_stress, tau1, tau2, k1, mode, groups):
    """
    Convert fine stress to current in all groups of Merkel Cells.

    Parameters
    ----------
    fine_sed : 1d-array
        Interpolated SED.
    groups : 1d-array
        Groups of Merkel cells.
        Example: [8, 5, 3, 1] has 4 groups, 8, 5, 3, and 1 cell in each group.

    Returns
    -------
    group_current : nd-array
        Generator current generated by stress in groups.
        n = the size of groups.
    """
    mc_size = groups.shape[0]
    stress_size = fine_stress.shape[0]
    group_current = np.zeros([stress_size, mc_size])
    for i in range(mc_size):
        group_current[:, i] = stress_to_current(fine_time, fine_stress, tau1,
                                                tau2, k1, mode) * groups[i]
    return group_current
Пример #2
0
 def plot_current_and_spike(key,
                            val,
                            fig,
                            axs,
                            fine_time=fine_time,
                            fine_stress=fine_stress,
                            fitApproach=fitApproach,
                            **plotkws):
     # Initialization
     lmpars = copy.deepcopy(fitApproach.ref_mean_lmpars)
     lmpars[key].value = val
     params_dict_new = lmpars_to_params(lmpars)
     # Formatting data
     if key == 'k2':
         lmpars['k4'].value = k4_list[k2_list.index(val)]
         params_dict_new = lmpars_to_params(lmpars)
         keyname = 'kmc1'
         params_paper = get_params_paper(lmpars)
         intval = int(params_paper[keyname] * 100)
     elif key == 'tau1':
         keyname = 'tau_nr'
         intval = int(val)
     elif key == 'tau2':
         keyname = 'tau_mc'
         intval = int(val)
     # Calculation
     single_current = stress_to_current(fine_time, fine_stress,
                                        **params_dict_new).sum(axis=1)
     spike_time, fr_inst = get_mod_spike(
         lmpars,
         **fitApproach.data_dicts_dicts[animal][stim]['mod_data_dict'])
     # Plotting
     axs[0].plot(fine_time,
                 single_current,
                 '-',
                 label='%s=%d' % (keyname, intval),
                 **plotkws)
     axs[1].plot(spike_time,
                 fr_inst * 1e3,
                 '.',
                 label='%s=%d' % (keyname, intval),
                 **plotkws)
     # Saving data
     np.savetxt('./data/GregCSVs/ParamTuning/current_%s_%d.csv' %
                (keyname, intval),
                single_current,
                delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/time_%s_%d.csv' %
                (keyname, intval),
                fine_time,
                delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/fr_inst_%s_%d.csv' %
                (keyname, intval),
                fr_inst,
                delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/spike_time_%s_%d.csv' %
                (keyname, intval),
                spike_time,
                delimiter=',')
     return fig, axs
Пример #3
0
 def plot_current_and_spike(key, val, fig, axs,
                            fine_time=fine_time, fine_stress=fine_stress,
                            fitApproach=fitApproach,
                            **plotkws):
     # Initialization
     lmpars = copy.deepcopy(fitApproach.ref_mean_lmpars)
     lmpars[key].value = val
     params_dict_new = lmpars_to_params(lmpars)
     # Formatting data
     if key == 'k2':
         lmpars['k4'].value = k4_list[k2_list.index(val)]
         params_dict_new = lmpars_to_params(lmpars)
         keyname = 'kmc1'
         params_paper = get_params_paper(lmpars)
         intval = int(params_paper[keyname] * 100)
     elif key == 'tau1':
         keyname = 'tau_nr'
         intval = int(val)
     elif key == 'tau2':
         keyname = 'tau_mc'
         intval = int(val)
     # Calculation
     single_current = stress_to_current(fine_time, fine_stress,
                                        **params_dict_new).sum(axis=1)
     spike_time, fr_inst = get_mod_spike(
         lmpars,
         **fitApproach.data_dicts_dicts[animal][stim]['mod_data_dict'])
     # Plotting
     axs[0].plot(fine_time, single_current, '-',
                 label='%s=%d' % (keyname, intval),
                 **plotkws)
     axs[1].plot(spike_time, fr_inst * 1e3, '.',
                 label='%s=%d' % (keyname, intval),
                 **plotkws)
     # Saving data
     np.savetxt('./data/GregCSVs/ParamTuning/current_%s_%d.csv' %
                (keyname, intval), single_current, delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/time_%s_%d.csv' %
                (keyname, intval), fine_time, delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/fr_inst_%s_%d.csv' %
                (keyname, intval), fr_inst, delimiter=',')
     np.savetxt('./data/GregCSVs/ParamTuning/spike_time_%s_%d.csv' %
                (keyname, intval), spike_time, delimiter=',')
     return fig, axs
Пример #4
0
def stress_to_group_current(fine_time, fine_stress, groups, **params):
    """
    Convert fine stress to current in all groups of Merkel Cells.

    Parameters
    ----------
    fine_time : 1xM array
        Interpolated time.
    fine_stress : 1xM array
        Interpolated stress.
    groups : 1xN array
        Groups of Merkel cells.
        Example: [8, 5, 3, 1] has 4 groups, 8, 5, 3, and 1 cell in each group.

    Returns
    -------
    group_gen_current : MxN array
        Generator current generated by stress in groups.
    """
    single_gen_current = stress_to_current(
        fine_time, fine_stress, **params).sum(axis=1)
    group_gen_current = np.multiply(single_gen_current[None].T, groups)
    return group_gen_current
Пример #5
0
def stress_to_group_current(fine_time, fine_stress, groups, **params):
    """
    Convert fine stress to current in all groups of Merkel Cells.

    Parameters
    ----------
    fine_time : 1xM array
        Interpolated time.
    fine_stress : 1xM array
        Interpolated stress.
    groups : 1xN array
        Groups of Merkel cells.
        Example: [8, 5, 3, 1] has 4 groups, 8, 5, 3, and 1 cell in each group.

    Returns
    -------
    group_gen_current : MxN array
        Generator current generated by stress in groups.
    """
    single_gen_current = stress_to_current(fine_time, fine_stress,
                                           **params).sum(axis=1)
    group_gen_current = np.multiply(single_gen_current[None].T, groups)
    return group_gen_current
Пример #6
0
def setup_gen_function(data):
    # Generator function decay parameters
    data['current_arr'] = stress_to_current(
        data['fine_time'], data['fine_stress'], **params)
Пример #7
0
def test_stress_to_current(load_data):
    current_arr = stress_to_current(load_data['fine_time'],
                                    load_data['fine_stress'], **params)
    assert np.allclose(current_arr, load_data['current_arr'])
Пример #8
0
 fig, axs = plt.subplots(3, 3, figsize=(7, 6))
 k_scale_dict_dict = {
     'Piezo2CONT': {},
     'Piezo2CKO': {'k4': 0},
     'Atoh1CKO': {'k2': 0, 'k4': 0}}
 for i, animal in enumerate(ANIMAL_LIST):
     lmpars_cko = get_lmpars_cko(fitApproach.ref_mean_lmpars,
                                 k_scale_dict_dict[animal])
     # Plot current
     for stim in REF_STIM_LIST:
         fine_time = fitApproach.data_dicts_dicts[animal][stim][
             'mod_data_dict']['time']
         fine_stress = fitApproach.data_dicts_dicts[animal][stim][
             'mod_data_dict']['stress']
         params_dict = lmpars_to_params(lmpars_cko)
         single_current = stress_to_current(fine_time, fine_stress,
                                            **params_dict).sum(axis=1)
         axs[0, i].plot(fine_time, -single_current, color=COLOR_LIST[stim])
         axs[0, i].set_xlabel('Time (msec)')
         axs[0, i].set_ylabel('Current (pA)')
         axs[0, i].set_ylim(-20, 0)
         # Add the bar on top
         mod_peak_time = fine_time[single_current.argmax()]
         axs[0, i].plot([mod_peak_time, 5000],
                        [2 - stim * .5, 2 - stim * .5], '-',
                        lw=4, c='.5', clip_on=False)
         axs[0, i].plot([0, mod_peak_time],
                        [2 - stim * .5, 2 - stim * .5], '-',
                        lw=4, color='k', clip_on=False)
         axs[0, i].set_xlim(0, 5000)
     # Plot firing rate
     fitApproach.plot_cko_customized(
Пример #9
0
def setup_gen_function(data):
    # Generator function decay parameters
    data['current_arr'] = stress_to_current(data['fine_time'],
                                            data['fine_stress'], **params)
Пример #10
0
     'Atoh1CKO': {
         'k2': 0,
         'k4': 0
     }
 }
 for i, animal in enumerate(ANIMAL_LIST):
     lmpars_cko = get_lmpars_cko(fitApproach.ref_mean_lmpars,
                                 k_scale_dict_dict[animal])
     # Plot current
     for stim in REF_STIM_LIST:
         fine_time = fitApproach.data_dicts_dicts[animal][stim][
             'mod_data_dict']['time']
         fine_stress = fitApproach.data_dicts_dicts[animal][stim][
             'mod_data_dict']['stress']
         params_dict = lmpars_to_params(lmpars_cko)
         single_current = stress_to_current(fine_time, fine_stress,
                                            **params_dict).sum(axis=1)
         axs[0, i].plot(fine_time, -single_current, color=COLOR_LIST[stim])
         axs[0, i].set_xlabel('Time (msec)')
         axs[0, i].set_ylabel('Current (pA)')
         axs[0, i].set_ylim(-20, 0)
         # Add the bar on top
         mod_peak_time = fine_time[single_current.argmax()]
         axs[0, i].plot([mod_peak_time, 5000],
                        [2 - stim * .5, 2 - stim * .5],
                        '-',
                        lw=4,
                        c='.5',
                        clip_on=False)
         axs[0, i].plot([0, mod_peak_time], [2 - stim * .5, 2 - stim * .5],
                        '-',
                        lw=4,
Пример #11
0
def test_stress_to_current(load_data):
    current_arr = stress_to_current(
        load_data['fine_time'], load_data['fine_stress'], **params)
    assert np.allclose(current_arr, load_data['current_arr'])