Exemple #1
0
Eigen::VectorXd operator()(Eigen::VectorXd v){

_joint_vel=v/20;
_joint+=_joint_vel;
_pos=forward_model(_joint);

return _joint;
}
    /**
     *  Here we test the scale factors methiods for the mahajan model.
     *  The idea is to set the scale factors for the 3 different cell types (epi, mid and endo)
     *  and check that the rsulting APD makes sense if compared to experiemntal results
     */
    void TestScaleFactorsForMahajanModel(void) throw(Exception)
    {
        double end_time=300;
        double time_step=0.01;
        double sampling_time=time_step;

        // Set stimulus
        double magnitude_stimulus = -70.0;   // pA/pF
        double duration_stimulus = 1.0;  // ms
        double start_stimulus = 10.0;   // ms
        double period=1000;//here, this is ms
        boost::shared_ptr<RegularStimulus> p_stimulus(new RegularStimulus(magnitude_stimulus,
                                                                          duration_stimulus,
                                                                          period,
                                                                          start_stimulus));

        boost::shared_ptr<EulerIvpOdeSolver> p_forward_solver(new EulerIvpOdeSolver); //define the solver

        CellMahajan2008FromCellML forward_model(p_forward_solver, p_stimulus);
        boost::shared_ptr<BackwardEulerIvpOdeSolver> p_backward_solver(new BackwardEulerIvpOdeSolver(
                                    forward_model.GetNumberOfStateVariables()));

        CellMahajan2008FromCellML epicardial_model(p_backward_solver, p_stimulus);
        CellMahajan2008FromCellML endocardial_model(p_backward_solver, p_stimulus);
        CellMahajan2008FromCellML midmyocardial_model(p_backward_solver, p_stimulus);

        epicardial_model.SetParameter("ScaleFactorGks",1.0);
        epicardial_model.SetParameter("ScaleFactorIto",1.0);
        epicardial_model.SetParameter("ScaleFactorGkr",1.0);

        midmyocardial_model.SetParameter("ScaleFactorGks",0.09);
        midmyocardial_model.SetParameter("ScaleFactorIto",1.0);
        midmyocardial_model.SetParameter("ScaleFactorGkr",1.0);

        endocardial_model.SetParameter("ScaleFactorGks",0.86);
        endocardial_model.SetParameter("ScaleFactorIto",0.2);
        endocardial_model.SetParameter("ScaleFactorGkr",1.0);

        std::vector<double> state_variables_epi = epicardial_model.GetInitialConditions();
        std::vector<double> state_variables_endo = endocardial_model.GetInitialConditions();
        std::vector<double> state_variables_mid = midmyocardial_model.GetInitialConditions();

        const std::string mahajan_epi_file = "Mahajan_epi";
        const std::string mahajan_mid_file = "Mahajan_mid";
        const std::string mahajan_endo_file = "Mahajan_endo";

        // Solve and write to file

        OdeSolution epi_solution;
        epi_solution = p_backward_solver->Solve(&epicardial_model, state_variables_epi, 0, end_time, time_step, sampling_time);

        epi_solution.WriteToFile("TestIonicModels",
                                 mahajan_epi_file,
                                 "ms",//time units
                                 100,//steps per row
                                 false);/*true cleans the directory*/

        OdeSolution mid_solution;
        mid_solution = p_backward_solver->Solve(&midmyocardial_model, state_variables_mid, 0, end_time, time_step, sampling_time);

        mid_solution.WriteToFile("TestIonicModels",
                                 mahajan_mid_file,
                                 "ms",//time units
                                 100,//steps per row
                                 false);/*true cleans the directory*/

        OdeSolution endo_solution;
        endo_solution = p_backward_solver->Solve(&endocardial_model, state_variables_endo, 0, end_time, time_step, sampling_time);

        endo_solution.WriteToFile("TestIonicModels",
                                  mahajan_endo_file,
                                  "ms",//time units
                                  100,//steps per row
                                  false);/*true cleans the directory*/


        ColumnDataReader data_reader_epi("TestIonicModels", mahajan_epi_file);
        ColumnDataReader data_reader_mid("TestIonicModels", mahajan_mid_file);
        ColumnDataReader data_reader_endo("TestIonicModels", mahajan_endo_file);

        std::vector<double> times = data_reader_epi.GetValues("Time");
        std::vector<double> v_endo = data_reader_endo.GetValues("membrane_voltage");
        std::vector<double> v_epi = data_reader_epi.GetValues("membrane_voltage");
        std::vector<double> v_mid = data_reader_mid.GetValues("membrane_voltage");

        CellProperties  cell_properties_endo(v_endo, times);
        CellProperties  cell_properties_epi(v_epi, times);
        CellProperties  cell_properties_mid(v_mid, times);

        double epi_APD = cell_properties_epi.GetLastActionPotentialDuration(90);
        double endo_APD = cell_properties_endo.GetLastActionPotentialDuration(90);
        double mid_APD = cell_properties_mid.GetLastActionPotentialDuration(90);

        // Check that percentage increase from epi to mid and endo (roughly*) matches results
        // from McIntosh et al. Card Res, 45:397-409. 200 (Figure 1 and 2)
        // *this is cardiac modelling after all...
        TS_ASSERT_DELTA((mid_APD-epi_APD)*100/epi_APD, 48.6, 2); // new values because gtos and gtof were the wrong way round (in Mahajan paper - they copied and pasted from Shannon wrong!)
        TS_ASSERT_DELTA((endo_APD-epi_APD)*100/epi_APD, 15.7, 2); // ""
    }
Exemple #3
0
Arm():_state(Eigen::VectorXd::Zero((NB_JOINT+1)*3)),
      _joint(Eigen::VectorXd::Zero(NB_JOINT)),
      _joint_vel(Eigen::VectorXd::Zero(NB_JOINT))
{
_pos=forward_model(_joint);
}