123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- #ifndef _HPP_INPUT
- #define _HPP_INPUT
- #include "libcsim.hpp"
- #include "layer.hpp"
- #include "objmovie.hpp"
- #include "stimulussequence.hpp"
- #include "tinyxml.h"
- enum InputMode {
- csimInputDefault,
- csimInputTest,
- csimInputRemote,
- csimInputRandom,
- csimInputRandomSequence,
- csimInputDirect,
- csimInputSaccades,
- csimInputSaccTest,
- csimInputSlideWinPic,
- csimInputPlayMovie,
- csimInputSequence
- };
- InputMode InputModeFromString(std::string modeString);
- class InputSynchronizer; // forward declaration
- /*! \brief input is a base class for input objects
- *
- *
- *
- */
- class input : public SimElement {
- protected:
- layer *Target;
- string FileName;
- int *RecordBuffer;
- csimInputChannel InputNumber;
- StimulusSequence* StimSeq;
- float *InputPointer;
- float Strength;
- int Size, Start, Stop;
- int CurStimNr; // is used for indexing stimulus arrays, starts with 0
- bool ResetToBeDone;
- InputMode mode;
- InputSynchronizer* inpsync;
- bool mSilent;
- public:
- input(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, float strength=1.0, int size=100, int start=0);
- ~input();
- virtual int proceede(int TotalTime=0);
- virtual int prepare(int StepNum=0);
- virtual int GetCurStimNr();
- virtual int GetLastStim(); // returns CurStimNr+1 or 0 for isi
- virtual int GetNStimuli();
- virtual int SetInputSync(InputSynchronizer* _inpsync);
- virtual void SetMode(InputMode _mode);
- virtual int WriteSimInfo(fstream &fw);
- virtual int WriteSimInfo(fstream &fw, const string &ChildInfo);
- virtual void SetInputStrength(float _Strength) {Strength=_Strength;};
- virtual void setSilent(bool Silent) {mSilent=Silent;}
- bool isi;
- };
- typedef map<int,int> ResponseMap;
- class InputSynchronizer {
- input* Master;
- ResponseMap* rmap;
- public:
- InputSynchronizer(input* _Master, ResponseMap* _rmap=0);
- int GetRemoteStimNr();
- };
- // for linear input sequences that can run in two directions (forward and backward)
- class BidirSequenceInput {
- protected:
- int Direction;
- public:
- BidirSequenceInput();
- void RandomDir();
- void ChangeDir();
- };
- class SequenceInput: public input, public BidirSequenceInput {
- float Overlap;
- int Duration;
- int NumPatterns;
- int PtPointer, Hold, PtShift;
- public:
- SequenceInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, float strength=1, int size=10, int numpt=10, float ov=0.5, int dur=100);
- ~SequenceInput();
- virtual int proceede(int TotalTime=0);
- };
- class PatternSequenceInput: public input, public BidirSequenceInput {
- float Overlap;
- int Duration;
- int NumPatterns;
- int PatternSize;
- int PtPointer, Hold, PtShift;
- int **PatternArray;
- public:
- PatternSequenceInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, float strength=1, int size=10, int _PtStart=0, int numpt=10, float ov=0.5, int dur=100);
- ~PatternSequenceInput();
- virtual int proceede(int TotalTime=0);
- virtual void Jump();
- };
- class PictureSequenceInput: public input, public BidirSequenceInput {
- private:
- int Npictures;
- float **PictureArray;
- int StimDuration, Isi1Duration, Isi2Duration;;
- int StimHold, IsiHold;
- int NoJumpHold, NoJumpDuration;
- bool TestMode;
- float mBackgroundStrength;
- public:
- PictureSequenceInput(layer* tg,
- csimInputChannel InputNumber=csimInputChannel_AMPA,
- float strength=1,
- float _StimDur=10,
- float _Isi1Dur=10,
- float _NoJumpDur=5,
- float _Isi2Dur=0,
- float _BackgroundStrength=0.);
- ~PictureSequenceInput();
- virtual int proceede(int TotalTime=0);
- void SetGaussPictureArray(const vector<vector2d> &mpList, float Sigma, float Cut=2);
- void SetCirclePictureArray(const vector<vector2d> &mpList, float Radius, float Background=0);
- void SetPictureArray(int _Npic, float _mpy=0.5, float Sigma=0.5);
- void SetPictureArray(vector<vector<float> > &paVec);
- void SetPictureArray(ObjMovie *Movie);
- void SetCirclePictureArray(int _Npic, float _mpy=0.5, float Radius=0.2, float Background=0);
- void SetLinearPictureArray(int _Npic, int _mpy, int _NumSeq, float Sigma=0.25);
- void SetTwoPointArray(float distance=0.2, float Radius=0.2);
- void SetTestMode(float _StimDuration=20, float _IsiDuration=1000);
- void ClearPictureArray();
- void SetBackgroundStrength(float BgStrength) {mBackgroundStrength=BgStrength;};
- virtual int Show(int TotalTime=0);
- virtual void Jump();
- };
- class SpikeTrainInput: public input {
- private:
- float *Picture;
- int SpikeHold, InterSpikeHold, SpikeDuration, InterSpikeDuration;
- float SpikeFrequency, SpikeWidth;
- int DelayDuration;
- int *SyncStimNr;
- public:
- SpikeTrainInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, float strength=1, float _SpikeFreq=10, float SpikeDuration=1.);
- ~SpikeTrainInput();
- void SetPictureCircle();
- void SetPictureAll(); // all neurons are activated equally
- void SetSpikeFrequency(float _SpikeFreq);
- virtual int proceede(int TotalTime=0);
- virtual int prepare(int=0);
- virtual int SetInputSync(InputSynchronizer* _inpsync, float _delay=0);
- };
- class MultiSequenceInput: public input {
- private:
- vector<PatternSequenceInput*> SequenceList;
- int NumSeq;
- int CurInputNr;
- int SwitchTime;
- int SwitchHold;
- int MinStimTime;
- int AddStimTime;
- int StimHold;
- public:
- MultiSequenceInput(layer* tg, int Nseq, csimInputChannel InputNumber=csimInputChannel_AMPA, float strength=1, int size=10, int _PtStart=0, int numpt=10, float ov=0.5, int dur=100);
- virtual int proceede(int TotalTime=0);
- };
- class MultiPictureSequenceInput: public input {
- private:
- vector<PictureSequenceInput*> SequenceList;
- vector<int> StimNumStart;
- int NumSeq;
- int CurInputNr;
- int SwitchTime;
- int SwitchHold;
- int MinStimTime;
- int AddStimTime;
- int StimHold;
- int StimTime;
- int SeqTime;
- int SeqHold;
- int IsiDuration, IsiHold;
- public:
- MultiPictureSequenceInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, int Nseq=3, float strength=1, float _StimTime=50, float _IsiTime=20);
- virtual int proceede(int TotalTime=0);
- int SetupGaussPictureArrays(
- vector<vector<vector2d> > mpList,
- float _StimDur=10, float Sigma=0.2, float Cut=2);
- int SetupCirclePictureArrays(
- vector<vector<vector2d> > mpList,
- float _StimDur=10, float Radius=0.2);
- int SetupPictureArrays(float _StimDur=10);
- int SetupLinearPictureArrays(float _StimDur=10, float Sigma=0.1);
- void SetTestMode(float _StimDuration=20, float _IsiDuration=1000);
- void Jump();
- };
- class LearnTestInput: public input {
- int delay;
- int hold, isi;
- int phase;
- public:
- LearnTestInput(layer*, csimInputChannel , float, float =10, float=20);
- ~LearnTestInput();
- int proceede(int TotalTime=0);
- };
- ////////////////////////////////////////
- /*! \brief ObjMovieInput
- *
- */
- class ObjMovieInput: public input {
- protected:
- ObjMovie* MovieFile;
- int FilterNr;
- int StimDuration, TestStimDuration, IsiDuration;
- int TestIsiDuration;
- int StimHold, IsiHold;
- int FrameSize;
- float *Data;
- bool SwitchMaster;
- bool RandomNext;
- bool TestMode;
- bool PositiveInput;
- input* SwitchMasterObj;
- public:
- ObjMovieInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, ObjMovie* _Movie=0, int FilterNr=0, float strength=1, float _StimDur=20, float _IsiDur=5);
- virtual int proceede(int TotalTime=0);
- void SetRandomNext(bool);
- void SetStimDuration(int _stimdur);
- void SetTestMode(bool tm);
- void InitializeTestMode(float _StimDuration, float _IsiDuration);
- virtual int GetNStimuli();
- int GetNFrames();
- void SetMovieFile(ObjMovie* _Movie, int FilterNr);
- };
- struct XYpair {
- XYpair(int _x, int _y): x(_x), y(_y) {};
- int x, y;
- };
- typedef vector<XYpair> XYpairList;
- /*! \brief ScanObjMovieInput is used in som01 and som02.
- ScanObjMovieInput interprets the idlmov format as a container for a set of pictures
- which are used as inputs in a certain order and with certain rules.
- The rules can be changed by setting a different input mode.
- New behaviour can be implemented
- First it was used for movies with scanned objects, generated with Crystal Space.
- In Crystal Space for every viewing angle of the object a picture was taken.
- The same was done for every object.
- \author fm
- */
- class ScanObjMovieInput: public ObjMovieInput {
- protected:
- int Xpara, Ypara, NXpara, NYpara;
- bool XContinous, XCircle, YCircle, XRandomChange ;
- int direction;
- int Isi2Duration;
- int NextX();
- int NextY();
- int NextRandom();
- int NextY_RandomDir();
- int NextRandomX();
- int NextObjpos();
- int NextRandomObjpos();
- int NextJitterX();
- int testiffirstrunever;
- int Xparacounter;
- int dirchangecounter;
- int testiffirsttestrunever;
- int NoJumpHold, NoJumpDuration, NoJumpDurationTest;
- XYpairList *TestStimList;
- vector<XYpair>::iterator TestIt;
- StimulusSequence mStimSequence;
- public:
- ScanObjMovieInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, ObjMovie* _Movie=0, int FilterNr=0, float strength=1, float _StimDur=20, int _NXpara=30, int _NYpara=30, bool _XContinous=true, int _NoJumpHold=20, float _IsiDur=20, float _Isi2Dur=0,int _NoJumpDurationTest=15);
- virtual int proceede(int TotalTime=0);
- void InitializeTestMode(
- XYpairList* StimList, float _StimDuration=20, float _IsiDuration=1000);
- ResponseMap* GetTestStimMap();
- void SetXCircle(bool);
- void SetXRandomChange(bool);
- void SetYCircle(bool);
- void loadStimulusSequence(const char* FileName);
- virtual void SetMode(InputMode _mode);
- virtual int WriteSimInfo(fstream &fw);
- };
- ///////
- class SequenceObjMovieInput: public ObjMovieInput {
- protected:
- int direction;
- // StimulusSequence* StimSeq;
- int NoJumpHold, NoJumpDuration;
- public:
- SequenceObjMovieInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, ObjMovie* _Movie=0, StimulusSequence* seq=0, int FilterNr=0, float strength=1, float _StimDur=20, int _NoJumpHold=20);
- virtual int proceede(int TotalTime=0);
- };
- ////////
- class VarSequenceInput: public input {
- private:
- vector<vector<float> >* Pictures;
- vector<int*> Sequence; //[SequenceDuration,PictureNumber]
- int steps;
- vector<int*>::const_iterator SequenceIterator;
- public:
- VarSequenceInput(layer* tg,csimInputChannel InputNumber=csimInputChannel_AMPA);
- ~VarSequenceInput();
- virtual int proceede(int TotalTime=0);
- void addPicture(vector<float>& );
- void changePicture(int ,vector<float>& );
- void addSequence(int ,int );
- void setSequenceIterator();
- bool changeSequence(int ,int ,int );
- void printSequences();
- };
- class ShiftObjMovieInput: public ObjMovieInput {
- public:
- ShiftObjMovieInput(layer* tg, csimInputChannel InputNumber=csimInputChannel_AMPA, ObjMovie* _Movie=0, int FilterNr=0, float strength=1, float _StimDur=20, float _IsiDur=5);
- virtual int proceede(int TotalTime=0);
- };
- //////////////////////////////////
- vector<float> CirclePicture(
- int SizeX,
- int SizeY,
- float MpX,
- float MpY,
- float Radius,
- float Amplitude,
- float Background,
- bool NormPos=false);
- #endif /*_HPP_INPUT */
|