This repository was archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathA2SCoderSignalStrength.cs
55 lines (49 loc) · 1.6 KB
/
A2SCoderSignalStrength.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using RCNet.Extensions;
using System;
namespace RCNet.Neural.Data.Coders.AnalogToSpiking
{
/// <summary>
/// Implements the signal strength coder.
/// </summary>
/// <remarks>
/// Uses a novel coding algorithm meeting together two important spike-train conditions where stronger
/// stimulation leads to earlier first spike and higher spiking frequency.
/// </remarks>
[Serializable]
public class A2SCoderSignalStrength : A2SCoderBase
{
//Attributes
//Constructor
/// <summary>
/// Creates an initialized instance.
/// </summary>
/// <param name="coderCfg">The coder configuration.</param>
public A2SCoderSignalStrength(A2SCoderSignalStrengthSettings coderCfg)
: base(coderCfg.NumOfTimePoints, 2)
{
return;
}
//Methods
/// <inheritdoc/>
public override void Reset()
{
return;
}
/// <inheritdoc/>
public override byte[][] GetCode(double normalizedValue)
{
//Allocate
byte[][] buffer = new byte[NumOfComponents][];
for (int i = 0; i < NumOfComponents; i++)
{
buffer[i] = new byte[BaseCodeLength];
buffer[i].Populate((byte)0);
}
//Code
int componentIdx = normalizedValue < 0 ? 0 : 1;
double x = (Math.Abs(normalizedValue) + 1d) / 2d;
GetStrengthCode(x, BaseCodeLength).CopyTo(buffer[componentIdx], 0);
return buffer;
}
}//A2SCoderSignalStrength
}//Namespace