indii/fmri/data/TextFileSeedReader.hpp

00001 #ifndef INDII_FMRI_DATA_TEXTFILESEEDREADER_HPP
00002 #define INDII_FMRI_DATA_TEXTFILESEEDREADER_HPP
00003 
00004 #include "SeedReader.hpp"
00005 
00006 #include "indii/ml/aux/vector.hpp"
00007 #include "indii/ml/aux/matrix.hpp"
00008 
00009 #include <sstream>
00010 
00011 namespace indii {
00012   namespace fmri {
00013     namespace data {
00014 
00015 /**
00016  * Reader for white-space delimited seed %data files. The ordered rows
00017  * of the file represent time steps, while each column represents a
00018  * particular seed.
00019  *
00020  * @author Lawrence Murray <lawrence@indii.org>
00021  * @version $Rev: 307 $
00022  * @date $Date: 2007-09-27 21:21:20 +0100 (Thu, 27 Sep 2007) $
00023  */
00024 class TextFileSeedReader : public SeedReader {
00025 public:
00026   /**
00027    * Construct new seed reader from input stream, where all seeds are
00028    * of interest.
00029    *
00030    * @param in Stream from which to read.
00031    */
00032   TextFileSeedReader(std::istream* in);
00033 
00034   /**
00035    * Construct new seed reader from file, where all seeds are of
00036    * interest.
00037    *
00038    * @param file Name of file from which to read.
00039    */
00040   TextFileSeedReader(const std::string file);
00041 
00042   /**
00043    * Construct new seed reader from input stream, where only a single
00044    * seed is of interest.
00045    *
00046    * @param in Stream from which to read.
00047    * @param seed Index of seed of interest.
00048    */
00049   TextFileSeedReader(std::istream* in, unsigned int seed);
00050 
00051   /**
00052    * Construct new seed reader from file, where only a single seed is
00053    * of interest.
00054    *
00055    * @param file Name of file from which to read.
00056    * @param seed Index of seed of interest.
00057    */
00058   TextFileSeedReader(const std::string file, unsigned int seed);
00059 
00060   /**
00061    * Construct new seed reader from input stream, where only a subset
00062    * of seeds are of interest.
00063    *
00064    * @param in Stream from which to read.
00065    * @param seeds Set of indices giving seeds of interest.
00066    */
00067   TextFileSeedReader(std::istream* in, const std::vector<unsigned int> seeds);
00068 
00069   /**
00070    * Construct new seed reader from file, where only a subset of seeds
00071    * are of interest.
00072    *
00073    * @param file Name of file from which to read.
00074    * @param seeds Set of indices giving seeds of interest.
00075    */
00076   TextFileSeedReader(const std::string file,
00077       const std::vector<unsigned int> seeds);
00078 
00079   /**
00080    * Destructor.
00081    */
00082   ~TextFileSeedReader();
00083 
00084   virtual unsigned int read(double* into);
00085 
00086   virtual unsigned int read(indii::ml::aux::vector* into);
00087 
00088   virtual unsigned int read(indii::ml::aux::matrix* into);
00089 
00090   virtual unsigned int read(indii::ml::aux::symmetric_matrix* into);
00091 
00092 private:
00093   /**
00094    * Values on the current line.
00095    */
00096   std::vector<double> values;
00097 
00098   /**
00099    * Current index in the seeds of interest vector.
00100    */
00101   unsigned int nextIndex;
00102 
00103   /** 
00104    * Move to next line in the stream.
00105    */
00106   void nextLine();
00107 
00108 };
00109 
00110     }
00111   }
00112 }
00113 
00114 #endif

Generated on Tue Oct 9 22:02:07 2007 for fmrii fMRI Modelling Library by  doxygen 1.5.2