void EEGPlot::drawSample(const CentData::AnalogData& data)
{
	if(m_numChannels == 0 || (data.num_channel < static_cast<int>(m_numChannels)) )
	{
		return;
	}
	qreal realSecond = 0.0;
	if(m_firstPacket)
	{
		m_firstPacket = false;
		m_redrawTimer.start();
	}
	else if(m_arraySeriesData->size() > 0)
	{
		realSecond = m_arraySeriesData->sample(m_arraySeriesData->size() -1).x() + SAMPLE_DELTA_REAL;
	}

	QPointF dataPoint(0,0);

	int idxBase = m_channelId * (data.num_channel/m_numChannels);
	for (int i=0; i < (data.num_channel/static_cast<int>(m_numChannels)) - 1; i++)
	{
		dataPoint.setX(realSecond);
		dataPoint.setY(data.channel[idxBase + i]);
		m_arraySeriesData->appendData(dataPoint);
		realSecond += SAMPLE_DELTA_REAL;
	}
}
Exemple #2
0
void shakeData::loadSMC(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	sampFreq=200.;
	bool tagOpen=false;
	int pipeCount=0;
	vector<double> val;
	getline(input, buffer);
	while(buffer.length()&&(buffer[0]=='|'||pipeCount<4)){
		if(buffer.length()&&buffer[0]=='|') pipeCount++;
		getline(input, buffer);
	}
	while (input.peek()!=EOF) {
		getline(input, buffer);
		if(buffer.length()%10==0){
			for(int i=0; i<buffer.length()/10; i++){
				string num(buffer.begin()+10*i,buffer.begin()+10*i+10);
				//uData.push_back(dataPoint(ofToFloat(num),1/sampFreq));
				val.push_back(ofToFloat(num));
			}
		}
	}
	input.close();
	for(unsigned int i=0; i<val.size(); i++){
		uData.push_back(dataPoint(val[i],1/sampFreq));
	}
	processData();
}
Exemple #3
0
void shakeData::loadCOSMOS(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	vector<double> val;
	int burn=45;
	while(burn--){
		getline(input, buffer);
	}
	getline(input, buffer);
	int numPoints=ofToInt(buffer.substr(0,buffer.find_first_of(' ',4)));
	sampFreq=1/ofToFloat(buffer.substr(47,4));
	string format=buffer.substr(buffer.find_last_of("(")+1,buffer.find_last_of(")")-(buffer.find_last_of("(")+1));
	cout <<numPoints << " of data, at " << sampFreq << " intervals in " << format << endl;
	vector<string> spl=ofSplitString(format,"f.");
	int pointsPerLine=ofToInt(spl[0]);
	int space=ofToInt(spl[1]);
	while(val.size()<numPoints){
		getline(input, buffer);
		for(unsigned int i=0; i<pointsPerLine&&val.size()<numPoints; i++){
			val.push_back(ofToFloat(buffer.substr(i*space,space)));
		}
	}
	for(unsigned int i=0; i<val.size(); i++){
		uData.push_back(dataPoint(val[i],1/sampFreq));
	}
	input.close();
	processData();
	
}
bool Profile::loadProfile(QString fileName, bool loadDefault) {

  QFile file(fileName);

  // Check if file exists, if not create default profile
  if(!file.exists()) {

    if(loadDefault) {
      loadDefaultProfile();
      return true;
    }
    else
      return false;
  }

  // Read profile data from file

  dataPoints.clear();

  QJsonDocument json;

  if(file.open(QFile::ReadOnly)) {
    qDebug() << "Loading profile data from " << fileName;

    QJsonParseError error;

    json = QJsonDocument().fromJson(file.readAll(), &error);

    // Check if JSON was correctly parsed
    if (error.error != QJsonParseError::NoError) {

      qDebug() << error.errorString();
      return false;
    }

    // Read JSON values
    QJsonObject object     = json.object();
    QJsonArray profileData = object.value("profileData").toArray();

    profileName = object.value("profileName").toString();

    // Convert the JSON array to a Trade List
    for(int i = 0; i < profileData.size(); i++) {

      // Convert the JSON values
      QJsonObject dataPointObject = profileData[i].toObject();

      float time = dataPointObject.value("time").toDouble();
      float temp = dataPointObject.value("temp").toDouble();

      // Create a trade object from the converted values
      DataPoint dataPoint(time, temp);

      // Append the new trade object to the trade list
      dataPoints.append(dataPoint);
    }
  }

  return true;
}
Exemple #5
0
void shakeData::loadKNET(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	int lineCount=0;
	double scale;
	double averg=0;
	vector<double> val;
	while(lineCount<18){
		getline(input, buffer);
		string result;
		KNETresults rslt=getVal(buffer,result);
		switch(rslt){
			case FREQ:
				sampFreq=ofToInt(result);
				break;
			case SCALE_AMOUNT:
				scale=ofToInt(result.substr(0,result.find_first_of("(")));
				scale/=ofToInt(result.substr(result.find_last_of("/")+1));
				break;
			case MAX_ACCEL:
				break;
			default:
				break;
		}
		lineCount++;
	}
	while(!input.eof()){
		getline(input, buffer);
		for(int i=0; i<8; i++){
			if(buffer.length()>(i+1)*9){
				val.push_back(ofToInt(buffer.substr(i*9,9)));
			}
		}
	}
	input.close();
	double a1,a0;
	linearRegression(val,a1,a0);
	for(unsigned int i=0; i<val.size(); i++){
		val[i]-=a0+a1*i;
		val[i]*=scale;
	}
	bandpassFilter(val,sampFreq,3);
	for(unsigned int i=0; i<val.size(); i++){
		uData.push_back(dataPoint(val[i],1/sampFreq));
	}
	processData();
}
Exemple #6
0
void shakeData::loadDAT(string filename)
{
	file=filename;
	ifstream input(ofToDataPath(file).c_str());
	string buffer;
	int lineCount=0;
	getline(input,buffer);
	double lastTime=0;
	while(!input.eof()){
		getline(input, buffer);
		vector<string> spl=ofSplitString(buffer," \t");
		if(spl.size()){
			float time=ofToFloat(spl[0]);
			uData.push_back(dataPoint(ofToFloat(spl[1]),time-lastTime));
			sampFreq=1/(time-lastTime);
			lastTime=time;
		}
	}
	input.close();
	processData();
}
Exemple #7
0
std::vector<dataPoint> JakeReader::getDataPoints() {
	std::vector<dataPoint> vecPoint;
	for(int i=0; i<fEvents.size(); i++)
		vecPoint.push_back(dataPoint(fEvents.at(i)));
	return vecPoint;
}
Exemple #8
0
void shakeData::getPoint(double acc, double deltat)
{
	uData.push_back(dataPoint(acc,deltat));
}