Skip to content

Commit 315c75b

Browse files
author
Carlos Eckert
committed
reverted to Unity 2019. Doing so prevented ISynapse errors. Program runs but voltage is locked at 50m/V. Will look into this later.
1 parent a48d2d6 commit 315c75b

File tree

192 files changed

+26023
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+26023
-175
lines changed

Assets/Save.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/C2M2/GameManager.cs

+30
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class GameManager : MonoBehaviour
3232
public double[] Npre;
3333
public double[] Hpre;
3434

35+
// Dictionary to store saved states
36+
private Dictionary<string, double[]> savedStates = new Dictionary<string, double[]>();
37+
3538
// for loading a file
3639
private bool loading = false;
3740
public bool Loading
@@ -204,5 +207,32 @@ private void OnApplicationPause(bool pause)
204207
{
205208
isRunning = !pause;
206209
}
210+
/// <summary>
211+
/// Saves the state data to the dictionary for later retrieval.
212+
/// </summary>
213+
/// <param name="variableName">The name of the variable being saved.</param>
214+
/// <param name="data">The data to be saved.</param>
215+
public void SaveState(string variableName, double[] data)
216+
{
217+
savedStates[variableName] = data;
218+
}
219+
220+
/// <summary>
221+
/// Retrieves the saved state data for a specific variable.
222+
/// </summary>
223+
/// <param name="variableName">The name of the variable to retrieve.</param>
224+
/// <returns>The saved state data, or an empty array if the state does not exist.</returns>
225+
public double[] GetSavedState(string variableName)
226+
{
227+
if (savedStates.ContainsKey(variableName))
228+
{
229+
return savedStates[variableName];
230+
}
231+
else
232+
{
233+
Debug.LogError($"No saved state found for {variableName}");
234+
return new double[0];
235+
}
236+
}
207237
}
208238
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Vector = MathNet.Numerics.LinearAlgebra.Vector<double>;
4+
namespace C2M2.NeuronalDynamics.Simulation
5+
{
6+
7+
public class GatingVariable
8+
{
9+
// Name of the gating variable (i.e: n, m, h)
10+
public string Name { get; }
11+
12+
// Alpha and Beta functions for the gating variable
13+
public Func<Vector, Vector> Alpha { get; }
14+
public Func<Vector, Vector> Beta { get; }
15+
16+
public double Exponent { get; }
17+
18+
// Probability is the initial state probability for the gating variable
19+
public double Probability { get; set; }
20+
public Vector CurrentState { get; set; }
21+
public Vector PreviousState { get; set; }
22+
23+
public GatingVariable(string name, Func<Vector, Vector> alpha, Func<Vector, Vector> beta, double exponent, double probability, int nodeCount)
24+
{
25+
Name = name;
26+
Alpha = alpha;
27+
Beta = beta;
28+
Exponent = exponent;
29+
Probability = probability;
30+
CurrentState = Vector.Build.Dense(nodeCount, probability);
31+
PreviousState = CurrentState.Clone();
32+
}
33+
34+
}
35+
36+
public class IonChannel
37+
{
38+
public string Name { get; set; } // Name of the ion channel (e.g., K+ channel)
39+
public double Conductance { get; set; } // g (conductance)
40+
public double ReversalPotential { get; set; } // E (reversal potential)
41+
public List<GatingVariable> GatingVariables { get; set; } // List of gating variables (can be dynamic)
42+
43+
public IonChannel(string name, double conductance, double reversalPotential)
44+
{
45+
Name = name;
46+
Conductance = conductance;
47+
ReversalPotential = reversalPotential;
48+
GatingVariables = new List<GatingVariable>();
49+
}
50+
public void AddGatingVariable(GatingVariable gatingVariable)
51+
{
52+
GatingVariables.Add(gatingVariable);
53+
}
54+
55+
public void RemoveGatingVariable(string name)
56+
{
57+
GatingVariables.RemoveAll(gv => gv.Name == name);
58+
}
59+
}
60+
}

Assets/Scripts/C2M2/NeuronalDynamics/Simulation/IonChannel.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)