Skip to content

Commit b1ba564

Browse files
committed
Merge branch 'develop'
2 parents 1674ba8 + 8d3742a commit b1ba564

File tree

23 files changed

+619
-164
lines changed

23 files changed

+619
-164
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@ API/urchin-venv/*
9090
Examples/steinmetz_3dvol_test/testwf4.npy
9191
Examples/bwm_coverage/lab_clusters.csv
9292
Examples/lozano/channel_locations.json
93+
Examples/ottenheimer_hjort_bowen_2022.zip
94+
UnityClient/Assets/AddressableAssetsData/link.xml
95+
UnityClient/Assets/AddressableAssetsData/link.xml.meta
96+
UnityClient/UserSettings/Layouts/default-2021.dwlt
97+
98+
API/oursin-venv/*

API/oursin.egg-info/PKG-INFO

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Metadata-Version: 2.1
22
Name: oursin
3-
Version: 0.4.4
4-
Summary: Urchin - Universal Renderer for Neuroscience Python API
3+
Version: 0.4.5
4+
Summary: Urchin - Universal Renderer Creating Helpful Images for Neuroscience Python API
55
Author-email: Daniel Birman <danbirman@gmail.com>
66
License: GNU GENERAL PUBLIC LICENSE
77
Version 3, 29 June 2007
@@ -679,7 +679,7 @@ License: GNU GENERAL PUBLIC LICENSE
679679
<https://www.gnu.org/licenses/why-not-lgpl.html>.
680680

681681
Project-URL: Homepage, https://virtualbrainlab.org/03_unity_neuro/01_urn_intro.html
682-
Project-URL: Bug Tracker, https://github.com/VirtualBrainLab/UnityNeuroscience/issues
682+
Project-URL: Bug Tracker, https://github.com/VirtualBrainLab/Urchin/issues
683683
Classifier: Programming Language :: Python :: 3
684684
Classifier: License :: OSI Approved :: MIT License
685685
Classifier: Operating System :: OS Independent

API/oursin.egg-info/requires.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
python-socketio[client]
22
numpy
3+
PIL

API/oursin/camera.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
from . import client
44

5+
from PIL import Image
6+
import io
7+
8+
receive_fname = ''
9+
receive_count = 0
10+
receive_data = []
11+
12+
def receive_camera_img_meta(data):
13+
global receive_count, receive_data
14+
receive_count = int(data)
15+
print('(Camera receive meta) ' + str(data))
16+
17+
def receive_camera_img(data):
18+
global receive_count, receive_data
19+
20+
print(f'(Camera) received {str(len(data))} bytes')
21+
receive_data.append(data)
22+
receive_count -= 1
23+
24+
if (receive_count == 0):
25+
data_bytes = b''.join(receive_data)
26+
receive_data = []
27+
Image.open(io.BytesIO(data_bytes)).save(receive_fname)
28+
print('(Camera received all data)')
29+
530
def set_target(camera_target_coordinate):
631
"""Set the camera target coordinate in CCF space in um relative to CCF (0,0,0), without moving the camera. Coordinates can be negative or larger than the CCF space (11400,13200,8000)
732
@@ -82,4 +107,32 @@ def set_pan(pan_x, pan_y):
82107
--------
83108
>>> urn.set_pan(3.0, 4.0)
84109
"""
85-
client.sio.emit('SetCameraPan', [pan_x, pan_y])
110+
client.sio.emit('SetCameraPan', [pan_x, pan_y])
111+
112+
def set_mode(mode):
113+
"""Set camera perspective mode
114+
115+
Parameters
116+
----------
117+
mode : string
118+
mode options "perspective" or "orthographic" (default)
119+
120+
Examples
121+
--------
122+
>>> urn.set_mode('perspective')
123+
"""
124+
client.sio.emit('SetCameraMode', mode)
125+
126+
def capture_image(filename):
127+
""" Capture a full screenshot and save to filename
128+
129+
Note: only supports PNG filetypes, for now
130+
131+
Examples
132+
--------
133+
>>> urn.capture_image('./image.png')
134+
"""
135+
global receive_fname
136+
receive_fname = filename
137+
client.sio.emit('RequestCameraImg')
138+

API/oursin/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import socketio
33
import os
44

5+
from . import camera
6+
57
class bcolors:
68
WARNING = '\033[93m'
79
FAIL = '\033[91m'
@@ -32,6 +34,13 @@ def message(data):
3234
def message(data):
3335
print('(Renderer) ' + bcolors.FAIL + data)
3436

37+
@sio.on('ReceiveCameraImgMeta')
38+
def receive_camera_img_meta(data):
39+
camera.receive_camera_img_meta(data)
40+
41+
@sio.on('ReceiveCameraImg')
42+
def receive_camera_img(data):
43+
camera.receive_camera_img(data)
3544
def connected():
3645
return sio.connected
3746

API/oursin/primitives.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,19 @@ def set_color(mesh_color):
7272
>>> urn.set_color({'cube1': '#FFFFFF'})
7373
7474
"""
75-
client.sio.emit('SetColor', mesh_color)
75+
client.sio.emit('SetColor', mesh_color)
76+
77+
def set_material(mesh_material):
78+
"""Set the material of mesh renderer
79+
80+
Parameters
81+
----------
82+
mesh_material : dict {string : string}
83+
dictionary of object IDs and name of new material
84+
85+
Examples
86+
--------
87+
>>> urn.set_material({'cube1': 'unlit'})
88+
89+
"""
90+
client.sio.emit('SetMaterial', mesh_material)

API/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "oursin"
8-
version = "0.4.4"
8+
version = "0.4.5"
99
authors = [
1010
{ name="Daniel Birman", email="danbirman@gmail.com" },
1111
]
@@ -21,6 +21,7 @@ classifiers = [
2121
dependencies = [
2222
"python-socketio[client]",
2323
"numpy",
24+
"PIL"
2425
]
2526

2627
[project.urls]

0 commit comments

Comments
 (0)