Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yehaojie
plugin-GUI
Commits
0aea578c
Commit
0aea578c
authored
7 years ago
by
Aaron Cuevas Lopez
Browse files
Options
Downloads
Patches
Plain Diff
Fix indexing issue in Open Ephys format
parent
7289059d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Processors/RecordNode/OriginalRecording.cpp
+26
-39
26 additions, 39 deletions
Source/Processors/RecordNode/OriginalRecording.cpp
Source/Processors/RecordNode/OriginalRecording.h
+0
-1
0 additions, 1 deletion
Source/Processors/RecordNode/OriginalRecording.h
with
26 additions
and
40 deletions
Source/Processors/RecordNode/OriginalRecording.cpp
+
26
−
39
View file @
0aea578c
...
...
@@ -67,14 +67,6 @@ String OriginalRecording::getEngineID() const
return
"OPENEPHYS"
;
}
void
OriginalRecording
::
addChannel
(
int
index
,
const
Channel
*
chan
)
{
//Just populate the file array with null so we can address it by index afterwards
fileArray
.
add
(
nullptr
);
blockIndex
.
add
(
0
);
samplesSinceLastTimestamp
.
add
(
0
);
}
void
OriginalRecording
::
addSpikeElectrode
(
int
index
,
const
SpikeRecordInfo
*
elec
)
{
spikeFileArray
.
add
(
nullptr
);
...
...
@@ -100,16 +92,15 @@ void OriginalRecording::openFiles(File rootFolder, int experimentNumber, int rec
openFile
(
rootFolder
,
nullptr
);
openMessageFile
(
rootFolder
);
for
(
int
i
=
0
;
i
<
fileArray
.
size
();
i
++
)
{
if
(
getChannel
(
i
)
->
getRecordState
())
{
openFile
(
rootFolder
,
getChannel
(
i
));
blockIndex
.
set
(
i
,
0
);
samplesSinceLastTimestamp
.
set
(
i
,
0
);
}
int
nChannels
=
getNumRecordedChannels
();
}
for
(
int
i
=
0
;
i
<
nChannels
;
i
++
)
{
Channel
*
ch
=
getChannel
(
getRealChannel
(
i
));
openFile
(
rootFolder
,
ch
);
blockIndex
.
add
(
0
);
samplesSinceLastTimestamp
.
add
(
0
);
}
for
(
int
i
=
0
;
i
<
spikeFileArray
.
size
();
i
++
)
{
openSpikeFile
(
rootFolder
,
getSpikeElectrode
(
i
));
...
...
@@ -175,7 +166,7 @@ void OriginalRecording::openFile(File rootFolder, Channel* ch)
eventFile
=
chFile
;
else
{
fileArray
.
set
(
ch
->
recordIndex
,
chFile
);
fileArray
.
add
(
chFile
);
if
(
ch
->
nodeId
!=
lastProcId
)
{
lastProcId
=
ch
->
nodeId
;
...
...
@@ -450,10 +441,7 @@ void OriginalRecording::writeData(int writeChannel, int realChannel, const float
{
int
samplesWritten
=
0
;
//int sourceNodeId = getChannel(realChannel)->sourceNodeId;
//TODO: optimize. Now we use realchannel, we should optimize the whole thing to only use recorded channels
samplesSinceLastTimestamp
.
set
(
realChannel
,
0
);
samplesSinceLastTimestamp
.
set
(
writeChannel
,
0
);
int
nSamples
=
size
;
...
...
@@ -461,7 +449,7 @@ void OriginalRecording::writeData(int writeChannel, int realChannel, const float
{
int
numSamplesToWrite
=
nSamples
-
samplesWritten
;
if
(
blockIndex
[
real
Channel
]
+
numSamplesToWrite
<
BLOCK_LENGTH
)
// we still have space in this block
if
(
blockIndex
[
write
Channel
]
+
numSamplesToWrite
<
BLOCK_LENGTH
)
// we still have space in this block
{
// write buffer to disk!
...
...
@@ -470,15 +458,15 @@ void OriginalRecording::writeData(int writeChannel, int realChannel, const float
writeChannel
);
//timestamp += numSamplesToWrite;
samplesSinceLastTimestamp
.
set
(
real
Channel
,
samplesSinceLastTimestamp
[
real
Channel
]
+
numSamplesToWrite
);
blockIndex
.
set
(
real
Channel
,
blockIndex
[
real
Channel
]
+
numSamplesToWrite
);
samplesSinceLastTimestamp
.
set
(
write
Channel
,
samplesSinceLastTimestamp
[
write
Channel
]
+
numSamplesToWrite
);
blockIndex
.
set
(
write
Channel
,
blockIndex
[
write
Channel
]
+
numSamplesToWrite
);
samplesWritten
+=
numSamplesToWrite
;
}
else
// there's not enough space left in this block for all remaining samples
{
numSamplesToWrite
=
BLOCK_LENGTH
-
blockIndex
[
real
Channel
];
numSamplesToWrite
=
BLOCK_LENGTH
-
blockIndex
[
write
Channel
];
// write buffer to disk!
writeContinuousBuffer
(
buffer
+
samplesWritten
,
...
...
@@ -488,8 +476,8 @@ void OriginalRecording::writeData(int writeChannel, int realChannel, const float
// update our variables
samplesWritten
+=
numSamplesToWrite
;
//timestamp += numSamplesToWrite;
samplesSinceLastTimestamp
.
set
(
real
Channel
,
samplesSinceLastTimestamp
[
real
Channel
]
+
numSamplesToWrite
);
blockIndex
.
set
(
real
Channel
,
0
);
// back to the beginning of the block
samplesSinceLastTimestamp
.
set
(
write
Channel
,
samplesSinceLastTimestamp
[
write
Channel
]
+
numSamplesToWrite
);
blockIndex
.
set
(
write
Channel
,
0
);
// back to the beginning of the block
}
}
...
...
@@ -498,13 +486,12 @@ void OriginalRecording::writeData(int writeChannel, int realChannel, const float
void
OriginalRecording
::
writeContinuousBuffer
(
const
float
*
data
,
int
nSamples
,
int
writeChannel
)
{
int
channel
=
getRealChannel
(
writeChannel
);
// check to see if the file exists
if
(
fileArray
[
c
hannel
]
==
nullptr
)
if
(
fileArray
[
writeC
hannel
]
==
nullptr
)
return
;
// scale the data back into the range of int16
float
scaleFactor
=
float
(
0x7fff
)
*
getChannel
(
c
hannel
)
->
bitVolts
;
float
scaleFactor
=
float
(
0x7fff
)
*
getChannel
(
getRealChannel
(
writeC
hannel
)
)
->
bitVolts
;
for
(
int
n
=
0
;
n
<
nSamples
;
n
++
)
{
...
...
@@ -512,9 +499,9 @@ void OriginalRecording::writeContinuousBuffer(const float* data, int nSamples, i
}
AudioDataConverters
::
convertFloatToInt16BE
(
continuousDataFloatBuffer
,
continuousDataIntegerBuffer
,
nSamples
);
if
(
blockIndex
[
c
hannel
]
==
0
)
if
(
blockIndex
[
writeC
hannel
]
==
0
)
{
writeTimestampAndSampleCount
(
fileArray
[
c
hannel
],
writeChannel
);
writeTimestampAndSampleCount
(
fileArray
[
writeC
hannel
],
writeChannel
);
}
diskWriteLock
.
enter
();
...
...
@@ -522,7 +509,7 @@ void OriginalRecording::writeContinuousBuffer(const float* data, int nSamples, i
size_t
count
=
fwrite
(
continuousDataIntegerBuffer
,
// ptr
2
,
// size of each element
nSamples
,
// count
fileArray
[
c
hannel
]);
// ptr to FILE object
fileArray
[
writeC
hannel
]);
// ptr to FILE object
//std::cout << channel << " : " << nSamples << " : " << count << std::endl;
...
...
@@ -531,9 +518,9 @@ void OriginalRecording::writeContinuousBuffer(const float* data, int nSamples, i
diskWriteLock
.
exit
();
if
(
blockIndex
[
c
hannel
]
+
nSamples
==
BLOCK_LENGTH
)
if
(
blockIndex
[
writeC
hannel
]
+
nSamples
==
BLOCK_LENGTH
)
{
writeRecordMarker
(
fileArray
[
c
hannel
]);
writeRecordMarker
(
fileArray
[
writeC
hannel
]);
}
}
...
...
@@ -590,13 +577,13 @@ void OriginalRecording::closeFiles()
writeContinuousBuffer
(
zeroBuffer
.
getReadPointer
(
0
),
BLOCK_LENGTH
-
blockIndex
[
i
],
i
);
diskWriteLock
.
enter
();
fclose
(
fileArray
[
i
]);
fileArray
.
set
(
i
,
nullptr
);
diskWriteLock
.
exit
();
}
}
blockIndex
.
set
(
i
,
0
);
}
fileArray
.
clear
();
blockIndex
.
clear
();
samplesSinceLastTimestamp
.
clear
();
for
(
int
i
=
0
;
i
<
spikeFileArray
.
size
();
i
++
)
{
if
(
spikeFileArray
[
i
]
!=
nullptr
)
...
...
This diff is collapsed.
Click to expand it.
Source/Processors/RecordNode/OriginalRecording.h
+
0
−
1
View file @
0aea578c
...
...
@@ -50,7 +50,6 @@ public:
void
closeFiles
()
override
;
void
writeData
(
int
writeChannel
,
int
realChannel
,
const
float
*
buffer
,
int
size
)
override
;
void
writeEvent
(
int
eventType
,
const
MidiMessage
&
event
,
int64
timestamp
)
override
;
void
addChannel
(
int
index
,
const
Channel
*
chan
)
override
;
void
resetChannels
()
override
;
void
addSpikeElectrode
(
int
index
,
const
SpikeRecordInfo
*
elec
)
override
;
void
writeSpike
(
int
electrodeIndex
,
const
SpikeObject
&
spike
,
int64
timestamp
)
override
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment