Stimfit  0.13.15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
stfio.h
Go to the documentation of this file.
00001 // This program is free software; you can redistribute it and/or
00002 // modify it under the terms of the GNU General Public License
00003 // as published by the Free Software Foundation; either version 2
00004 // of the License, or (at your option) any later version.
00005 
00006 // This program is distributed in the hope that it will be useful,
00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009 // GNU General Public License for more details.
00010 
00011 // You should have received a copy of the GNU General Public License
00012 // along with this program; if not, write to the Free Software
00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00014 
00024 #ifndef _STFIO_H_
00025 #define _STFIO_H_
00026 
00027 #include <iostream>
00028 #include <boost/function.hpp>
00029 #include <vector>
00030 #include <deque>
00031 #include <map>
00032 #include <string>
00033 #include <cmath>
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning( disable : 4251 )  // Disable warning messages
00037 #pragma warning( disable : 4996 )  // Disable warning messages
00038 #endif
00039 
00041 #if defined(_WINDOWS) && !defined(__MINGW32__)
00042     #ifdef STFIODLL
00043         #define StfioDll __declspec( dllexport )
00044     #else
00045         #define StfioDll __declspec( dllimport )
00046     #endif
00047 #else
00048     #define StfioDll
00049 #endif
00050 
00051 typedef std::vector<double > Vector_double;
00052 typedef std::vector<float > Vector_float;
00053 
00054 #ifdef _MSC_VER
00055     #ifndef NAN
00056         static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
00057         #define NAN (*(const float *) __nan)
00058     #endif
00059     #ifndef INFINITY
00060         #define INFINITY (DBL_MAX+DBL_MAX)
00061     #endif
00062     StfioDll long int lround(double x);
00063     #define snprintf _snprintf
00064 #endif
00065 
00066 #include "./recording.h"
00067 #include "./channel.h"
00068 #include "./section.h"
00069 
00070 /* class Recording; */
00071 /* class Channel; */
00072 /* class Section; */
00073 
00075 
00078 namespace stfio {
00079 
00084     StfioDll Vector_double vec_scal_plus(const Vector_double& vec, double scalar);
00085 
00086     StfioDll Vector_double vec_scal_minus(const Vector_double& vec, double scalar);
00087 
00088     StfioDll Vector_double vec_scal_mul(const Vector_double& vec, double scalar);
00089 
00090     StfioDll Vector_double vec_scal_div(const Vector_double& vec, double scalar);
00091 
00092     StfioDll Vector_double vec_vec_plus(const Vector_double& vec1, const Vector_double& vec2);
00093 
00094     StfioDll Vector_double vec_vec_minus(const Vector_double& vec1, const Vector_double& vec2);
00095 
00096     StfioDll Vector_double vec_vec_mul(const Vector_double& vec1, const Vector_double& vec2);
00097 
00098     StfioDll Vector_double vec_vec_div(const Vector_double& vec1, const Vector_double& vec2);
00099 
00101 
00104  class StfioDll ProgressInfo {
00105  public:
00107 
00112      ProgressInfo(const std::string& title, const std::string& message, int maximum, bool verbose) {};
00113 
00115 
00120      virtual bool Update(int value, const std::string& newmsg="", bool* skip=NULL) = 0;
00121  };
00122 
00123  
00125 
00127 class StfioDll StdoutProgressInfo : public stfio::ProgressInfo {
00128  public:
00129     StdoutProgressInfo(const std::string& title, const std::string& message, int maximum, bool verbose);
00130     bool Update(int value, const std::string& newmsg="", bool* skip=NULL);
00131  private:
00132     bool verbosity;
00133 };
00134 
00136 struct txtImportSettings {
00137   txtImportSettings() : hLines(1),toSection(true),firstIsTime(true),ncolumns(2),
00138         sr(20),yUnits("mV"),yUnitsCh2("pA"),xUnits("ms") {}
00139 
00140     int hLines;            
00141     bool toSection;        
00142     bool firstIsTime;      
00143     int ncolumns;          
00144     double sr;             
00145     std::string yUnits;    
00146     std::string yUnitsCh2; 
00147     std::string xUnits;    
00148 };
00149 
00151 enum filetype {
00152     atf,    
00153     abf,    
00154     axg,    
00155     ascii,  
00156     cfs,    
00157     igor,   
00158     son,    
00159     hdf5,   
00160     heka,   
00161     biosig, 
00162     none    
00163 };
00164 
00165   
00167 
00170 StfioDll stfio::filetype
00171 findType(const std::string& ext);
00172 
00174 
00181 StfioDll bool 
00182 importFile(
00183         const std::string& fName,
00184         stfio::filetype type,
00185         Recording& ReturnData,
00186         const stfio::txtImportSettings& txtImport,
00187         stfio::ProgressInfo& progDlg
00188 );
00189 
00191 
00197 StfioDll bool
00198 exportFile(const std::string& fName, stfio::filetype type, const Recording& Data,
00199            ProgressInfo& progDlg);
00200 
00202 
00207 StfioDll Recording
00208 concatenate(const Recording& src, const std::vector<std::size_t>& sections,
00209             ProgressInfo& progDlg);
00210 
00212 
00218 StfioDll Recording
00219 multiply(const Recording& src, const std::vector<std::size_t>& sections,
00220          std::size_t channel, double factor);
00223 } // end of namespace
00224 
00225 typedef std::vector< std::string        >::iterator       sst_it;      
00226 typedef std::vector< std::string        >::const_iterator c_sst_it;    
00227 typedef std::vector< std::size_t     >::const_iterator c_st_it;     
00228 typedef std::vector< int             >::iterator       int_it;      
00229 typedef std::vector< int             >::const_iterator c_int_it;    
00230 typedef std::vector< Channel         >::iterator       ch_it;       
00231 typedef std::vector< Channel         >::const_iterator c_ch_it;     
00232 typedef std::vector< Section         >::iterator       sec_it;      
00233 typedef std::vector< Section         >::const_iterator c_sec_it;    
00235 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines