Skip to content

Commit ec494aa

Browse files
committed
Fixes to Rhd2164 channel map during hardware test
- Previous implementation did not function - Updated Rhd2164DataFrame docs to specify channel ordering
1 parent 34adebc commit ec494aa

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

OpenEphys.Onix1/BufferHelper.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static Mat CopyTranspose<TBuffer>(
5959
{
6060
if (channelMap == null || channelMap.Length != channelCount)
6161
{
62-
throw new ArgumentException($"{nameof(channelMap)} must contain {nameof(channelCount)} entries", nameof(channelMap));
62+
return CopyTranspose(buffer, sampleCount, channelCount, depth);
6363
}
6464

6565
using var bufferHeader = Mat.CreateMatHeader(
@@ -68,12 +68,15 @@ public static Mat CopyTranspose<TBuffer>(
6868
channelCount,
6969
depth,
7070
channels: 1);
71-
var data = new Mat(bufferHeader.Cols, bufferHeader.Rows, depth, 1);
71+
var data = new Mat(bufferHeader.Rows, bufferHeader.Cols, depth, 1);
7272

7373
for (int i = 0; i < bufferHeader.Cols; i++)
74-
CV.Copy(bufferHeader.GetCol(channelMap[i]), data.GetRow(i));
74+
CV.Copy(bufferHeader.GetCol(channelMap[i]), data.GetCol(i));
7575

76-
return data;
76+
var transposeData = new Mat(bufferHeader.Cols, bufferHeader.Rows, depth, 1);
77+
78+
CV.Transpose(data, transposeData);
79+
return transposeData;
7780
}
7881
}
7982
}

OpenEphys.Onix1/Rhd2164DataFrame.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ public Rhd2164DataFrame(ulong[] clock, ulong[] hubClock, Mat amplifierData, Mat
2727
/// </summary>
2828
/// <remarks>
2929
/// Electrophysiology samples are organized in 64xN matrix with rows representing electrophysiology
30-
/// channel number and N columns representing sample index. Each column is a 64-channel vector of ADC
31-
/// samples whose acquisition time is indicated by the corresponding elements in <see
32-
/// cref="DataFrame.Clock"/> and <see cref="DataFrame.HubClock"/>. Each ADC sample is a 16-bit,
33-
/// offset binary value encoded as a <see cref="ushort"/>. The following equation can be used to
34-
/// convert a sample to microvolts:
30+
/// channel number and N columns representing sample index. Channels are ordered in accordance with
31+
/// the Rhd2164 input number specified on its datasheet (channel 0 corresponds to input 0, channel 1
32+
/// corresponds to input 1, and so on). Each column is a 64-channel vector of ADC samples whose
33+
/// acquisition time is indicated by the corresponding elements in <see cref="DataFrame.Clock"/> and
34+
/// <see cref="DataFrame.HubClock"/>. Each ADC sample is a 16-bit, offset binary value encoded as a
35+
/// <see cref="ushort"/>. The following equation can be used to convert a sample to microvolts:
3536
/// <code>
3637
/// Electrode Voltage (µV) = 0.195 × (ADC Sample – 32768)
3738
/// </code>
@@ -42,11 +43,13 @@ public Rhd2164DataFrame(ulong[] clock, ulong[] hubClock, Mat amplifierData, Mat
4243
/// Gets the buffered auxiliary data array.
4344
/// </summary>
4445
/// <remarks>
45-
/// Auxiliary samples are organized in 3xN matrix with rows representing electrophysiology channel
46-
/// number and N columns representing sample index. Each column is a 3-channel vector of ADC samples
47-
/// whose acquisition time is indicated by the corresponding elements in <see cref="DataFrame.Clock"/>
48-
/// and <see cref="DataFrame.HubClock"/>. Each ADC sample is a 16-bit <see cref="ushort"/>. The
49-
/// following equation can be used to convert a sample to volts:
46+
/// Auxiliary samples are organized in 3xN matrix with rows representing auxilary channel number and N
47+
/// columns representing sample index. Channels are ordered in accordance with the Rhd2164 input
48+
/// number specified on its datasheet (channel 0 corresponds to auxiliary input 0, channel 1
49+
/// corresponds to auxiliary input 1, and channel 2 corresponds to auxiliary input 2). Each column is
50+
/// a 3-channel vector of ADC samples whose acquisition time is indicated by the corresponding
51+
/// elements in <see cref="DataFrame.Clock"/> and <see cref="DataFrame.HubClock"/>. Each ADC sample is
52+
/// a 16-bit <see cref="ushort"/>. The following equation can be used to convert a sample to volts:
5053
/// <code>
5154
/// Auxiliary Voltage (V) = 0.0000374 × ADC Sample
5255
/// </code>

0 commit comments

Comments
 (0)