Skip to content

Commit

Permalink
feat: many updates
Browse files Browse the repository at this point in the history
- Added left/right to move neurons
- Fixed hover/select functionality, select persists
- Replaced search with area buttons
- Improved reactive layout
- Update CSV file to latest version
- Added a loading overlay
  • Loading branch information
dbirman committed Feb 6, 2024
1 parent eb4ff64 commit ae544e7
Show file tree
Hide file tree
Showing 17 changed files with 23,623 additions and 29,873 deletions.
6,196 changes: 3,098 additions & 3,098 deletions Unity/Assets/Data/output.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Unity/Assets/Data/output.csv.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Unity/Assets/Plugins/unity_js_link.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ mergeInto(LibraryManager.library, {
window.alert(UTF8ToString(pid));
},

FinishedLoading: function() {
update();
}

});
3 changes: 2 additions & 1 deletion Unity/Assets/Scenes/UnityMouseRenderer.unity
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_meshManager: {fileID: 213271435}
_mainCameraBehav: {fileID: 1793010831}
_dataAsset: {fileID: 4900000, guid: 345dfa950e1fa204d9bc13d07089aae2, type: 3}
_dataAsset: {fileID: 4900000, guid: 294b66c1e8e17e040afe13c21f7247cc, type: 3}
RandScale: 0.1
--- !u!114 &1793010831 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 3393775226113162772, guid: a0c57925ee59dae4ebf1f78ba70837a6, type: 3}
Expand Down
55 changes: 50 additions & 5 deletions Unity/Assets/Scripts/NPUltraRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
using UnityEngine;
using Urchin.Behaviors;
using Urchin.Managers;
#if UNITY_WEBGL && !UNITY_EDITOR
using System.Runtime.InteropServices;
#endif

public class NPUltraRuntime : MonoBehaviour
{
#if UNITY_WEBGL && !UNITY_EDITOR
[DllImport("__Internal")]
private static extern void FinishedLoading();
#endif

[SerializeField] PrimitiveMeshManager _meshManager;

Expand All @@ -15,6 +22,9 @@ public class NPUltraRuntime : MonoBehaviour
private string[] _namesList;
private string[] _areaList;
private bool _loaded;
private string _selected;

public float RandScale = 1f;

private void Start()
{
Expand All @@ -30,7 +40,7 @@ private void Start()
public async void DelayedStart()
{
_mainCameraBehav.SetCameraMode(false);
_mainCameraBehav.SetCameraZoom(-11.5f);
_mainCameraBehav.SetCameraZoom(-15f);

var taskVar = BrainAtlasManager.LoadAtlas("allen_mouse_25um");

Expand All @@ -48,6 +58,10 @@ public async void DelayedStart()
node.ResetColor();
node.SetShaderProperty("_Alpha", 0.15f, OntologyNode.OntologyNodeSide.Full);
}

#if UNITY_WEBGL && !UNITY_EDITOR
FinishedLoading();
#endif
}

public void Search(string searchStr)
Expand All @@ -67,6 +81,21 @@ public void Search(string searchStr)
_meshManager.SetScale(_namesList, scales);
}

public void Select(string selectedName)
{
// un-select the previous selection
if (_selected != null)
{
MeshBehavior unMesh = _meshManager.GetMesh(_selected);
unMesh.Select(false);
}

_selected = selectedName;

MeshBehavior meshBehavior = _meshManager.GetMesh(_selected);
meshBehavior.Select(true);
}

private void LoadData()
{
if (_dataAsset != null)
Expand All @@ -89,19 +118,22 @@ private void LoadData()
float ml = int.Parse(columns[2], System.Globalization.NumberStyles.Any);

// ap/ml/dv are in index coordinates, convert to um here
coords[i-1] = new Vector3(ap / 1000f,
ml / 1000f,
dv / 1000f);
coords[i-1] = new Vector3(ap / 1000f + RandN(),
ml / 1000f + RandN(),
dv / 1000f + RandN());
_areaList[i - 1] = columns[3];
colors[i - 1] = HexToColor(columns[4]);
_namesList[i - 1] = i.ToString();
scales[i - 1] = 0.05f;
scales[i - 1] = 0.075f;
}

_meshManager.CreateMesh(_namesList);
_meshManager.SetPositions(_namesList, coords);
_meshManager.SetColor(_namesList, colors);
_meshManager.SetScale(_namesList, scales);

foreach (string name in _namesList)
_meshManager.GetMesh(name).Save();
}
else
{
Expand All @@ -110,6 +142,19 @@ private void LoadData()

_loaded = true;
}

private float BoxMullerTransform()
{
float u1 = 1f - Random.value; // Ensure u1 is in the range (0, 1] to avoid log(0)
float u2 = 1f - Random.value;
float z = Mathf.Sqrt(-2f * Mathf.Log(u1)) * Mathf.Sin(2f * Mathf.PI * u2);
return z;
}

float RandN()
{
return RandScale * BoxMullerTransform(); // Scale the value by standard deviation (10)
}

private Color HexToColor(string hex)
{
Expand Down
6 changes: 3 additions & 3 deletions Unity/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ PlayerSettings:
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 2560
defaultScreenHeight: 1440
defaultScreenWidthWeb: 1920
defaultScreenHeightWeb: 1200
defaultScreenWidthWeb: 800
defaultScreenHeightWeb: 1000
m_StereoRenderingPath: 0
m_ActiveColorSpace: 0
unsupportedMSAAFallback: 0
Expand Down Expand Up @@ -79,7 +79,7 @@ PlayerSettings:
androidAutoRotationBehavior: 1
defaultIsNativeResolution: 1
macRetinaSupport: 1
runInBackground: 1
runInBackground: 0
captureSingleScreen: 0
muteOtherAudioSources: 0
Prepare IOS For Recording: 0
Expand Down
Loading

0 comments on commit ae544e7

Please sign in to comment.