src/clustersprovider.h

00001 /***************************************************************************
00002                           clustersprovider.h  -  description
00003                              -------------------
00004     begin                : Wed Apr 14 2004
00005     copyright            : (C) 2004 by Lynn Hazan
00006     email                : lynn.hazan.myrealbox.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef CLUSTERSPROVIDER_H
00019 #define CLUSTERSPROVIDER_H
00020 
00021 //include files for the application
00022 #include <dataprovider.h>
00023 #include <array.h>
00024 #include <types.h>
00025 
00026 // include files for QT
00027 #include <qptrlist.h>
00028 #include <qobject.h>
00029 
00030 //include files for c/c++ libraries
00031 #include <math.h>
00032 
00037 class ClustersProvider : public DataProvider  {
00038    Q_OBJECT
00039 public:
00040 
00042   enum loadReturnMessage {OK=0,OPEN_ERROR=1,MISSING_FILE=3,COUNT_ERROR=4,INCORRECT_CONTENT=5};
00043 
00051   ClustersProvider(KURL fileUrl,double samplingRate,double currentSamplingRate,dataType fileMaxTime,int position = 25);
00052      ~ClustersProvider();
00053 
00060   void requestData(long startTime,long endTime,QObject* initiator,long startTimeInRecordingUnits);
00061 
00062 
00072   void requestNextClusterData(long startTime,long timeFrame,QValueList<int> selectedIds,QObject* initiator,long startTimeInRecordingUnits);
00073 
00074 
00084   void requestPreviousClusterData(long startTime,long timeFrame,QValueList<int> selectedIds,QObject* initiator,long startTimeInRecordingUnits);
00085     
00089   int loadData();
00090 
00093   inline QValueList<int> clusterIdList() const{return clusterIds;};
00094   
00098   inline QString getName() const {return name;}
00099 
00103   inline void setClusterPosition(int position){clusterPosition = static_cast<float>(position) / 100.0;};  
00104 
00108   inline void updateSamplingRate(double rate){
00109     dataCurrentRatio = static_cast<float>(samplingRate / rate);
00110 
00111     //Initialize the variables
00112     previousStartTime = 0;
00113     previousStartIndex = 1;
00114     previousEndIndex = nbSpikes;
00115     double maxTime =  static_cast<double>(static_cast<double>(clusters(2,nbSpikes)) * static_cast<double>(1000) / static_cast<double>(samplingRate));
00116     previousEndTime = static_cast<dataType>(floor(0.5 + maxTime));
00117     fileMaxTime = previousEndTime;
00118   };
00119 
00124   inline void updateAcquisitionSystemSamplingRate(double rate,double currentSamplingRate){
00125     samplingRate = rate;
00126     dataCurrentRatio = static_cast<float>(samplingRate / currentSamplingRate);
00127 
00128     //Initialize the variables
00129     previousStartTime = 0;
00130     previousStartIndex = 1;
00131     previousEndIndex = nbSpikes;
00132     double maxTime =  static_cast<double>(static_cast<double>(clusters(2,nbSpikes)) * static_cast<double>(1000) / static_cast<double>(samplingRate));
00133     previousEndTime = static_cast<dataType>(floor(0.5 + maxTime));
00134     fileMaxTime = previousEndTime;        
00135   };
00136     
00137 signals:
00144   void dataReady(Array<dataType>& data,QObject* initiator,QString providerName);
00145 
00154   void nextClusterDataReady(Array<dataType>& data,QObject* initiator,QString providerName,long startingTime,long startingTimeInRecordingUnits);
00155 
00164   void previousClusterDataReady(Array<dataType>& data,QObject* initiator,QString providerName,long startingTime,long startingTimeInRecordingUnits);
00165  
00166 private:
00167 
00169   QString name;
00170 
00172   KURL timeFileUrl;
00173   
00175   double samplingRate;
00176 
00178   Array<dataType> clusters;
00179 
00181   long previousStartTime;
00182 
00184   long previousEndTime;
00185   
00187   long previousStartIndex;
00188 
00190   long previousEndIndex;
00191 
00193   long nbSpikes;
00194 
00196   int nbClusters;
00197 
00199   float dataCurrentRatio;
00200 
00202   QValueList<int> clusterIds;
00203 
00205   long fileMaxTime;
00206 
00208   float clusterPosition;
00209   
00211   dataType dataFileMaxTime;
00212   
00213   //Functions
00214 
00221   void retrieveData(long startTime,long endTime,QObject* initiator,long startTimeInRecordingUnits);
00222 
00223 };
00224 
00225 
00226 #endif

Generated on Mon Sep 17 20:47:30 2007 for NeuroScope by  doxygen 1.5.1