Skip to content
Snippets Groups Projects
Commit 76951723 authored by jsiegle's avatar jsiegle
Browse files

Fix bug in HDF5 timestamps when acquiring for the first time

parent 0ddd8035
Branches
Tags
No related merge requests found
......@@ -649,7 +649,7 @@ void KWDFile::startNewRecording(int recordingNumber, int nChannels, HDF5Recordin
CHECK_ERROR(createGroup(recordPath));
CHECK_ERROR(setAttributeStr(info->name,recordPath,String("name")));
CHECK_ERROR(setAttribute(U64,&(info->start_time),recordPath,String("start_time")));
// CHECK_ERROR(setAttribute(U32,&(info->start_sample),recordPath,String("start_sample")));
CHECK_ERROR(setAttribute(U32,&(info->start_sample),recordPath,String("start_sample")));
CHECK_ERROR(setAttribute(F32,&(info->sample_rate),recordPath,String("sample_rate")));
CHECK_ERROR(setAttribute(U32,&(info->bit_depth),recordPath,String("bit_depth")));
CHECK_ERROR(createGroup(recordPath+"/application_data"));
......
......@@ -24,7 +24,7 @@
#include "HDF5Recording.h"
#define MAX_BUFFER_SIZE 10000
HDF5Recording::HDF5Recording() : processorIndex(-1)
HDF5Recording::HDF5Recording() : processorIndex(-1), hasAcquired(false)
{
//timestamp = 0;
scaledBuffer = new float[MAX_BUFFER_SIZE];
......@@ -77,7 +77,7 @@ void HDF5Recording::addChannel(int index, Channel* chan)
processorMap.add(processorIndex);
}
void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordingNumber)
void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordingNumber)
{
String basepath = rootFolder.getFullPathName() + rootFolder.separatorString + "experiment" + String(experimentNumber);
//KWIK file
......@@ -90,8 +90,13 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int record
spikesFile->startNewRecording(recordingNumber);
//Let's just put the first processor (usually the source node) on the KWIK for now
infoArray[0]->name = String("Open-Ephys Recording #") + String(recordingNumber);
infoArray[0]->start_time = (*timestamps).begin()->second;
infoArray[0]->name = String("Open Ephys Recording #") + String(recordingNumber);
if (hasAcquired)
infoArray[0]->start_time = (*timestamps)[getChannel(0)->sourceNodeId]; //(*timestamps).begin()->first;
else
infoArray[0]->start_time = 0;
infoArray[0]->start_sample = 0;
mainFile->startNewRecording(recordingNumber,infoArray[0]);
......@@ -105,7 +110,10 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int record
{
fileArray[index]->initFile(getChannel(i)->nodeId,basepath);
fileArray[index]->open();
infoArray[index]->start_time = (*timestamps)[getChannel(i)->sourceNodeId]; //the timestamps of the first channel
if (hasAcquired)
infoArray[index]->start_time = (*timestamps)[getChannel(i)->sourceNodeId]; //the timestamps of the first channel
else
infoArray[index]->start_time = 0;
}
bitVoltsArray[index]->add(getChannel(i)->bitVolts);
sampleRatesArray[index]->add(getChannel(i)->sampleRate);
......@@ -122,7 +130,7 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int record
File f(fileArray[i]->getFileName());
mainFile->addKwdFile(f.getFileName());
infoArray[i]->name = String("Open-Ephys Recording #") + String(recordingNumber);
infoArray[i]->name = String("Open Ephys Recording #") + String(recordingNumber);
// infoArray[i]->start_time = timestamp;
infoArray[i]->start_sample = 0;
infoArray[i]->bitVolts.clear();
......@@ -132,6 +140,8 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int record
fileArray[i]->startNewRecording(recordingNumber,bitVoltsArray[i]->size(),infoArray[i]);
}
}
hasAcquired = true;
}
void HDF5Recording::closeFiles()
......
......@@ -59,6 +59,8 @@ private:
ScopedPointer<KWXFile> spikesFile;
float* scaledBuffer;
int16* intBuffer;
bool hasAcquired;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(HDF5Recording);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment