S1S2Stimulus.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #include "S1S2Stimulus.hpp"
00029 
00030 S1S2Stimulus::S1S2Stimulus(double magnitude, double stimulusDuration, double s1Duration, double s1Period, double startTime, std::vector<double> s2Periods)
00031     : MultiStimulus()
00032 {
00033     mNumS2FrequencyValues = s2Periods.size();
00034     for (unsigned i=0; i<mNumS2FrequencyValues; i++)
00035     {
00036         boost::shared_ptr<MultiStimulus> p_experiment_stimulus(new MultiStimulus());
00037 
00038         boost::shared_ptr<RegularStimulus> p_s1(new RegularStimulus(magnitude, stimulusDuration, s1Period, startTime, s1Duration+startTime));
00039         boost::shared_ptr<RegularStimulus> p_s2(new RegularStimulus(magnitude, stimulusDuration, s2Periods[i], s1Duration+startTime, s1Duration + 2*s2Periods[i]+startTime));
00040 
00041         p_experiment_stimulus->AddStimulus(p_s1);
00042         p_experiment_stimulus->AddStimulus(p_s2);
00043 
00044         // We hijack the mStimulus of the MultiStimulus class to
00045         // record different stimuli for each S2 frequency.
00046         this->AddStimulus(p_experiment_stimulus);
00047     }
00048     mS2Index=0u;
00049 }
00050 
00051 double S1S2Stimulus::GetStimulus(double time)
00052 {
00053     return this->mStimuli[mS2Index]->GetStimulus(time);
00054 }
00055 
00056 void S1S2Stimulus::SetS2ExperimentPeriodIndex(unsigned index)
00057 {
00058     if (index < mNumS2FrequencyValues)
00059     {
00060      mS2Index = index;
00061     }
00062     else
00063     {
00064      EXCEPTION("There are fewer S2 frequency values than the one you have requested.");
00065     }
00066 }
00067 
00068 unsigned S1S2Stimulus::GetNumS2FrequencyValues()
00069 {
00070     return mNumS2FrequencyValues;
00071 }
00072 
00073 
00074 #include "SerializationExportWrapperForCpp.hpp"
00075 CHASTE_CLASS_EXPORT(S1S2Stimulus);
00076 
00077 
Generated on Thu Dec 22 13:00:06 2011 for Chaste by  doxygen 1.6.3