Skip to content

Commit eb6cf9e

Browse files
committed
Set HDF5 chuck cache size dependent on the number of recorded channels
1 parent 99cd169 commit eb6cf9e

5 files changed

Lines changed: 38 additions & 14 deletions

File tree

Builds/VisualStudio2013/open-ephys.vcxproj.filters

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464
<Filter Include="open-ephys\Source\Processors\EventDetector">
6565
<UniqueIdentifier>{FDD5B79A-1AA4-7745-BB6E-E09A6DFC328E}</UniqueIdentifier>
6666
</Filter>
67-
<Filter Include="open-ephys\Source\Processors\EventNode">
68-
<UniqueIdentifier>{3BDCC6CD-7B1F-ED1C-7442-F2B0CD1A86C8}</UniqueIdentifier>
69-
</Filter>
7067
<Filter Include="open-ephys\Source\Processors\FileReader">
7168
<UniqueIdentifier>{59F490B2-F5D9-601B-01AE-368632E3C9D7}</UniqueIdentifier>
7269
</Filter>
@@ -439,6 +436,9 @@
439436
<Filter Include="Juce Library Code">
440437
<UniqueIdentifier>{8B4D1BAA-6DB4-CAEC-A0FA-271F354D5C61}</UniqueIdentifier>
441438
</Filter>
439+
<Filter Include="open-ephys\Source\Processors\EventDetector\EventNode">
440+
<UniqueIdentifier>{3BDCC6CD-7B1F-ED1C-7442-F2B0CD1A86C8}</UniqueIdentifier>
441+
</Filter>
442442
</ItemGroup>
443443
<ItemGroup>
444444
<ClCompile Include="..\..\Source\CoreServices.cpp">
@@ -583,10 +583,10 @@
583583
<Filter>open-ephys\Source\Processors\EventDetector</Filter>
584584
</ClCompile>
585585
<ClCompile Include="..\..\Source\Processors\EventNode\EventNode.cpp">
586-
<Filter>open-ephys\Source\Processors\EventNode</Filter>
586+
<Filter>open-ephys\Source\Processors\EventDetector\EventNode</Filter>
587587
</ClCompile>
588588
<ClCompile Include="..\..\Source\Processors\EventNode\EventNodeEditor.cpp">
589-
<Filter>open-ephys\Source\Processors\EventNode</Filter>
589+
<Filter>open-ephys\Source\Processors\EventDetector\EventNode</Filter>
590590
</ClCompile>
591591
<ClCompile Include="..\..\Source\Processors\FileReader\KwikFileSource.cpp">
592592
<Filter>open-ephys\Source\Processors\FileReader</Filter>
@@ -2124,10 +2124,10 @@
21242124
<Filter>open-ephys\Source\Processors\EventDetector</Filter>
21252125
</ClInclude>
21262126
<ClInclude Include="..\..\Source\Processors\EventNode\EventNode.h">
2127-
<Filter>open-ephys\Source\Processors\EventNode</Filter>
2127+
<Filter>open-ephys\Source\Processors\EventDetector\EventNode</Filter>
21282128
</ClInclude>
21292129
<ClInclude Include="..\..\Source\Processors\EventNode\EventNodeEditor.h">
2130-
<Filter>open-ephys\Source\Processors\EventNode</Filter>
2130+
<Filter>open-ephys\Source\Processors\EventDetector\EventNode</Filter>
21312131
</ClInclude>
21322132
<ClInclude Include="..\..\Source\Processors\FileReader\KwikFileSource.h">
21332133
<Filter>open-ephys\Source\Processors\FileReader</Filter>

Source/Processors/RecordNode/HDF5FileFormat.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,27 @@ bool HDF5FileBase::isOpen() const
6666
return opened;
6767
}
6868

69+
bool HDF5FileBase::isReadyToOpen() const
70+
{
71+
return readyToOpen;
72+
}
73+
6974
int HDF5FileBase::open()
75+
{
76+
return open(-1);
77+
}
78+
79+
int HDF5FileBase::open(int nChans)
7080
{
7181
if (!readyToOpen) return -1;
7282
if (File(getFileName()).existsAsFile())
73-
return open(false);
83+
return open(false, nChans);
7484
else
75-
return open(true);
85+
return open(true, nChans);
7686

7787
}
7888

79-
int HDF5FileBase::open(bool newfile)
89+
int HDF5FileBase::open(bool newfile, int nChans)
8090
{
8191
int accFlags,ret=0;
8292

@@ -85,7 +95,11 @@ int HDF5FileBase::open(bool newfile)
8595
try
8696
{
8797
FileAccPropList props = FileAccPropList::DEFAULT;
88-
props.setCache(0, 401, 4 * 2 * 35 * 16 * 320, 1);
98+
if (nChans > 0)
99+
{
100+
props.setCache(0, 809, 8 * 2 * 640 * nChans, 1);
101+
std::cout << "opening HDF5 " << getFileName() << " with nchans: " << nChans << std::endl;
102+
}
89103

90104
if (newfile) accFlags = H5F_ACC_TRUNC;
91105
else accFlags = H5F_ACC_RDWR;

Source/Processors/RecordNode/HDF5FileFormat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ class HDF5FileBase
5353
virtual ~HDF5FileBase();
5454

5555
int open();
56+
int open(int nChans);
5657
void close();
5758
virtual String getFileName() = 0;
5859
bool isOpen() const;
60+
bool isReadyToOpen() const;
5961
typedef enum DataTypes { U8, U16, U32, U64, I8, I16, I32, I64, F32, STR} DataTypes;
6062

6163
static H5::DataType getNativeType(DataTypes type);
@@ -83,7 +85,7 @@ class HDF5FileBase
8385
private:
8486
//create an extendable dataset
8587
HDF5RecordingData* createDataSet(DataTypes type, int dimension, int* size, int* chunking, String path);
86-
int open(bool newfile);
88+
int open(bool newfile, int nChans);
8789
ScopedPointer<H5::H5File> file;
8890
bool opened;
8991

Source/Processors/RecordNode/HDF5Recording.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ void HDF5Recording::registerProcessor(GenericProcessor* proc)
5757
fileArray.add(new KWDFile());
5858
bitVoltsArray.add(new Array<float>);
5959
sampleRatesArray.add(new Array<float>);
60+
channelsPerProcessor.add(0);
6061
processorIndex++;
6162
}
6263

6364
void HDF5Recording::resetChannels()
6465
{
6566
processorIndex = -1;
6667
fileArray.clear();
68+
channelsPerProcessor.clear();
6769
bitVoltsArray.clear();
6870
sampleRatesArray.clear();
6971
processorMap.clear();
@@ -106,15 +108,15 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordi
106108
int index = processorMap[i];
107109
if (getChannel(i)->getRecordState())
108110
{
109-
if (!fileArray[index]->isOpen())
111+
if (!fileArray[index]->isOpen())
110112
{
111113
fileArray[index]->initFile(getChannel(i)->nodeId,basepath);
112-
fileArray[index]->open();
113114
if (hasAcquired)
114115
infoArray[index]->start_time = (*timestamps)[getChannel(i)->sourceNodeId]; //the timestamps of the first channel
115116
else
116117
infoArray[index]->start_time = 0;
117118
}
119+
channelsPerProcessor.set(index, channelsPerProcessor[index] + 1);
118120
bitVoltsArray[index]->add(getChannel(i)->bitVolts);
119121
sampleRatesArray[index]->add(getChannel(i)->sampleRate);
120122
if (getChannel(i)->sampleRate != infoArray[index]->sample_rate)
@@ -125,6 +127,10 @@ void HDF5Recording::openFiles(File rootFolder, int experimentNumber, int recordi
125127
}
126128
for (int i = 0; i < fileArray.size(); i++)
127129
{
130+
if ((!fileArray[i]->isOpen()) && (fileArray[i]->isReadyToOpen()))
131+
{
132+
fileArray[i]->open(channelsPerProcessor[i]);
133+
}
128134
if (fileArray[i]->isOpen())
129135
{
130136
File f(fileArray[i]->getFileName());
@@ -158,6 +164,7 @@ void HDF5Recording::closeFiles()
158164
fileArray[i]->close();
159165
bitVoltsArray[i]->clear();
160166
}
167+
channelsPerProcessor.set(i, 0);
161168
}
162169
}
163170

Source/Processors/RecordNode/HDF5Recording.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class HDF5Recording : public RecordEngine
5151
int processorIndex;
5252

5353
Array<int> processorMap;
54+
Array<int> channelsPerProcessor;
5455
OwnedArray<Array<float>> bitVoltsArray;
5556
OwnedArray<Array<float>> sampleRatesArray;
5657
OwnedArray<KWDFile> fileArray;

0 commit comments

Comments
 (0)