Skip to content

Commit

Permalink
Add Cerebus cluster provider
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFranzen committed Nov 13, 2015
1 parent ffb622e commit 30a3c9c
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 66 deletions.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ endif()
if(WITH_CEREBUS)
# Add network specific source files
list(APPEND SOURCE_FILES
cerebustraceprovider.cpp)
cerebustraceprovider.cpp
cerebusclustersprovider.cpp)
endif()

# Combine it all
Expand Down
56 changes: 56 additions & 0 deletions src/cerebusclustersprovider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***************************************************************************
cerebusclustersprovider.cpp - description
-------------------
copyright : (C) 2015 by Florian Franzen
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "cerebusclustersprovider.h"

#include <QDebug>

// 0 = unclassified, 1 - cbMAXUNITS = actual units, 254 = artifact (unit + noise), 255 = background (noise)
const int CerebusClustersProvider::CLUSTER_COUNT = cbMAXUNITS + 3;

CerebusClustersProvider::CerebusClustersProvider(CerebusTracesProvider* source, unsigned int channel, int samplingRate) :
ClustersProvider(QString("cerebus.%1.clu").arg(channel + 1), samplingRate, cbSdk_TICKS_PER_SECOND, 0),
mDataProvider(source),
mChannel(channel) {

// Name referes to the group, which can not be zero, because zero is trash group.
this->name = QString::number(mChannel + 1);
this->clusterIds << 0 << 1 << 2 << 3 << 4 << 5 << 254 << 255;
}

CerebusClustersProvider::~CerebusClustersProvider() {
// Nothing to do here
}

int CerebusClustersProvider::loadData() {
if (mDataProvider->isInitialized())
return OPEN_ERROR;
else
return OK;
}

void CerebusClustersProvider::requestData(long start, long end, QObject* initiator, long /*startTimeInRecordingUnits*/) {
Array<dataType>* data = mDataProvider->getClusterData(mChannel, start, end);
emit dataReady(*data, initiator, this->name);
delete data;
}

void CerebusClustersProvider::requestNextClusterData(long startTime, long timeFrame, const QList<int> &selectedIds, QObject* initiator, long startTimeInRecordingUnits) {
qDebug() << "requestNextClusterData(...) not supported yet.";
}

void CerebusClustersProvider::requestPreviousClusterData(long startTime, long timeFrame, QList<int> selectedIds, QObject* initiator, long startTimeInRecordingUnits) {
qDebug() << "requestPreviousClusterData(...) not supported yet.";
}
80 changes: 80 additions & 0 deletions src/cerebusclustersprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/***************************************************************************
cerebusclustersprovider.h - description
-------------------
copyright : (C) 2015 by Florian Franzen
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef _NEVCLUSTERSPROVIDER_H_
#define _NEVCLUSTERSPROVIDER_H_

#include "clustersprovider.h"
#include "cerebustraceprovider.h"

class CerebusClustersProvider : public ClustersProvider {
Q_OBJECT

public:
static const int CLUSTER_COUNT;

CerebusClustersProvider(CerebusTracesProvider* source, unsigned int channel, int samplingRate);
~CerebusClustersProvider();

/** Loads the event ids and the corresponding spike time.
* @return an loadReturnMessage enum giving the load status
*
* Since data is supplied by CerebusTraceProvider, this is
* just a wrapper around isInitialized()
*/
virtual int loadData();


/**Triggers the retrieve of the cluster information included in the time interval given by @p startTime and @p endTime.
* @param startTime begining of the time interval from which to retrieve the data in miliseconds.
* @param endTime end of the time interval from which to retrieve the data.
* @param initiator instance requesting the data.
* @param startTimeInRecordingUnits begining of the time interval from which to retrieve the data in recording units.
*/
virtual void requestData(long startTime, long endTime, QObject* initiator, long startTimeInRecordingUnits);


/**Looks up for the first of the clusters included in the list @p selectedIds existing after the time @p startTime.
* All the clusters included in the time interval given by @p timeFrame are retrieved. The time interval start time is
* computed in order to have the first cluster found located at @p clusterPosition percentage of the time interval.
* @param startTime starting time, in miliseconds, for the look up.
* @param timeFrame time interval for which to retrieve the data.
* @param selectedIds list of cluster ids to look up for.
* @param initiator instance requesting the data.
* @param startTimeInRecordingUnits starting time, in recording units, for the look up.
*/
virtual void requestNextClusterData(long startTime, long timeFrame, const QList<int> &selectedIds, QObject* initiator, long startTimeInRecordingUnits);


/**Looks up for the first of the clusters included in the list @p selectedIds existing before the time @p endTime.
* All the clusters included in the time interval given by @p timeFrame are retrieved. The time interval start time is
* computed in order to have the first cluster found located at @p clusterPosition percentage of the time interval.
* @param startTime starting time, in miliseconds, for the look up.
* @param timeFrame time interval for which to retrieve the data.
* @param selectedIds list of cluster ids to look up for.
* @param initiator instance requesting the data.
* @param startTimeInRecordingUnits starting time, in recording units, for the look up.
*/
virtual void requestPreviousClusterData(long startTime, long timeFrame, QList<int> selectedIds, QObject* initiator, long startTimeInRecordingUnits);

private:
// The actual data source of the cluster data.
CerebusTracesProvider* mDataProvider;

// Channel this provider is responsible for
unsigned int mChannel;
};

#endif
Loading

0 comments on commit 30a3c9c

Please sign in to comment.