-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
3,658 additions
and
795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ build* | |
BUILD* | ||
.dir-locals.el | ||
*.pyc | ||
TAGS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#------------------------------------------------------------------------------- | ||
# nest in situ vis | ||
# | ||
# Copyright (c) 2017-2018 RWTH Aachen University, Germany, | ||
# Virtual Reality & Immersive Visualisation Group. | ||
#------------------------------------------------------------------------------- | ||
# License | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#------------------------------------------------------------------------------- | ||
|
||
function(ADD_PYTHON_MODULE) | ||
# parse arguments | ||
set(options ) | ||
set(oneValueArgs NAME OUTPUT_DIRECTORY) | ||
set(multiValueArgs | ||
SOURCES HEADERS PYTHON_SOURCES INCLUDE_DIRECTORIES LINK_LIBRARIES) | ||
cmake_parse_arguments(ADD_PYTHON_MODULE | ||
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
python_add_module(${ADD_PYTHON_MODULE_NAME} | ||
${ADD_PYTHON_MODULE_SOURCES} | ||
${ADD_PYTHON_MODULE_HEADERS} | ||
) | ||
|
||
target_include_directories(${ADD_PYTHON_MODULE_NAME} | ||
PRIVATE ${Boost_INCLUDE_DIRS} | ||
PRIVATE ${PYTHON_INCLUDE_DIRS} | ||
${ADD_PYTHON_MODULE_INCLUDE_DIRECTORIES} | ||
) | ||
|
||
target_link_libraries(${ADD_PYTHON_MODULE_NAME} | ||
${Boost_LIBRARIES} | ||
${PYTHON_LIBRARIES} | ||
${ADD_PYTHON_MODULE_LINK_LIBRARIES} | ||
) | ||
|
||
set_warning_levels_RWTH(${ADD_PYTHON_MODULE_NAME} | ||
SUPPRESS_WARNINGS_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/pyniv/suppress_warnings.hpp | ||
) | ||
|
||
add_test_cpplint(NAME "${ADD_PYTHON_MODULE_NAME}--cpplint" | ||
${ADD_PYTHON_MODULE_SOURCES} | ||
${ADD_PYTHON_MODULE_HEADERS} | ||
) | ||
|
||
add_custom_command(TARGET ${ADD_PYTHON_MODULE_NAME} | ||
POST_BUILD | ||
#OUTPUT ${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${ADD_PYTHON_MODULE_NAME}> | ||
#DEPENDS $<TARGET_FILE:${ADD_PYTHON_MODULE_NAME}> | ||
COMMAND ${CMAKE_COMMAND} | ||
-E copy_if_different | ||
$<TARGET_FILE:${ADD_PYTHON_MODULE_NAME}> | ||
${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${ADD_PYTHON_MODULE_NAME}> | ||
) | ||
|
||
foreach (ADD_PYTHON_MODULE_PYTHON_INPUT ${ADD_PYTHON_MODULE_PYTHON_SOURCES}) | ||
get_filename_component(ADD_PYTHON_MODULE_PYTHON_INPUT_NAME | ||
${ADD_PYTHON_MODULE_PYTHON_INPUT} | ||
NAME) | ||
set(ADD_PYTHON_MODULE_PYTHON_OUTPUT | ||
"${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/${ADD_PYTHON_MODULE_PYTHON_INPUT_NAME}" | ||
) | ||
set(ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME | ||
"${ADD_PYTHON_MODULE_NAME}_COPY_${ADD_PYTHON_MODULE_PYTHON_INPUT_NAME}" | ||
) | ||
add_custom_command( | ||
OUTPUT ${ADD_PYTHON_MODULE_PYTHON_OUTPUT} | ||
DEPENDS ${ADD_PYTHON_MODULE_PYTHON_INPUT} | ||
COMMAND ${CMAKE_COMMAND} | ||
-E copy_if_different | ||
${ADD_PYTHON_MODULE_PYTHON_INPUT} | ||
${ADD_PYTHON_MODULE_PYTHON_OUTPUT} | ||
) | ||
add_custom_target(${ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME} | ||
DEPENDS | ||
${ADD_PYTHON_MODULE_PYTHON_OUTPUT} | ||
) | ||
add_dependencies(${ADD_PYTHON_MODULE_NAME} | ||
${ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME} | ||
) | ||
endforeach(ADD_PYTHON_MODULE_PYTHON_INPUT) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#------------------------------------------------------------------------------- | ||
# nest in situ vis | ||
# | ||
# Copyright (c) 2017-2018 RWTH Aachen University, Germany, | ||
# Virtual Reality & Immersive Visualisation Group. | ||
#------------------------------------------------------------------------------- | ||
# License | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#------------------------------------------------------------------------------- | ||
|
||
set(PYTHON_DUMP_SOURCE dump_to_stdout.py) | ||
set(PYTHON_VIS_SOURCE vis.py) | ||
|
||
if(NOT CMAKE_MAKE_PROGRAM STREQUAL "/usr/bin/xcodebuild") | ||
|
||
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_dump.sh | ||
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${PYTHON_DUMP_SOURCE}" | ||
) | ||
|
||
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_vis.sh | ||
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${PYTHON_VIS_SOURCE}" | ||
) | ||
|
||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#------------------------------------------------------------------------------- | ||
# nest in situ vis | ||
# | ||
# Copyright (c) 2017-2018 RWTH Aachen University, Germany, | ||
# Virtual Reality & Immersive Visualisation Group. | ||
#------------------------------------------------------------------------------- | ||
# License | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#------------------------------------------------------------------------------- | ||
|
||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import seaborn as sns | ||
|
||
import pyniv | ||
|
||
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton | ||
from PyQt5.QtCore import QTimer | ||
|
||
class MainWindow: | ||
def __init__(self): | ||
self.SetupStreaming() | ||
self.SetupWindow() | ||
self.SetupUpdateTimer() | ||
|
||
def SetupStreaming(self): | ||
self.receiver = pyniv.consumer.Receiver() | ||
|
||
self.multimeter = pyniv.consumer.ArborMultimeter("multimeter") | ||
|
||
self.backend = pyniv.consumer.Backend(); | ||
self.backend.Connect(self.receiver); | ||
self.backend.Connect(self.multimeter); | ||
|
||
def SetupWindow(self): | ||
self.print_button = QPushButton("Print") | ||
self.print_button.clicked.connect(self.PrintButtonClicked) | ||
|
||
def SetupUpdateTimer(self): | ||
self.update_timer = QTimer() | ||
self.update_timer.timeout.connect(self.Receive) | ||
self.update_timer.start(1) | ||
|
||
def PrintButtonClicked(self): | ||
print 60 * '=' | ||
timesteps = self.multimeter.GetTimestepsString() | ||
for t in timesteps: | ||
print 't = {}'.format(t) | ||
attributes = self.multimeter.GetAttributes(t) | ||
for a in attributes: | ||
values = self.multimeter.GetTimestepData(t, a) | ||
print a + ': ' + ', '.join(['{}'.format(v) for v in values]) | ||
print 40 * '-' | ||
|
||
def Show(self): | ||
self.print_button.show() | ||
button_geometry = self.print_button.geometry() | ||
self.print_button.setGeometry( | ||
0, 0, | ||
button_geometry.width(), | ||
button_geometry.height()) | ||
|
||
def Receive(self): | ||
self.backend.Receive() | ||
|
||
def Dump(self): | ||
print("DUMP") | ||
|
||
|
||
def main(argv): | ||
app = QApplication(argv) | ||
|
||
w = MainWindow() | ||
w.Show() | ||
|
||
return app.exec_() | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#------------------------------------------------------------------------------- | ||
# nest in situ vis | ||
# | ||
# Copyright (c) 2017-2018 RWTH Aachen University, Germany, | ||
# Virtual Reality & Immersive Visualisation Group. | ||
#------------------------------------------------------------------------------- | ||
# License | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#------------------------------------------------------------------------------- | ||
|
||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import seaborn as sns | ||
|
||
import pyniv | ||
|
||
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton | ||
from PyQt5.QtCore import QTimer | ||
|
||
class MainWindow: | ||
def __init__(self): | ||
self.SetupStreaming() | ||
self.SetupWindow() | ||
self.SetupPlot() | ||
self.SetupUpdateTimer() | ||
|
||
def SetupStreaming(self): | ||
self.receiver = pyniv.consumer.Receiver() | ||
|
||
self.multimeter = pyniv.consumer.ArborMultimeter("multimeter") | ||
|
||
self.backend = pyniv.consumer.Backend(); | ||
self.backend.Connect(self.receiver); | ||
self.backend.Connect(self.multimeter); | ||
|
||
def SetupWindow(self): | ||
self.visualize_button = QPushButton("Visualize") | ||
self.visualize_button.clicked.connect(self.VisualizeButtonClicked) | ||
|
||
def SetupUpdateTimer(self): | ||
self.update_timer = QTimer() | ||
self.update_timer.timeout.connect(self.Visualize) | ||
|
||
def SetupPlot(self): | ||
sns.set_style("darkgrid") | ||
self.fig = plt.figure() | ||
self.ax1 = self.fig.add_subplot(1,1,1) | ||
|
||
|
||
def VisualizeButtonClicked(self): | ||
self.visualize_button.setEnabled(False) | ||
self.update_timer.start(250) | ||
self.Visualize() | ||
|
||
def Show(self): | ||
self.visualize_button.show() | ||
button_geometry = self.visualize_button.geometry() | ||
self.visualize_button.setGeometry( | ||
0, 0, | ||
button_geometry.width(), | ||
button_geometry.height()) | ||
|
||
def Visualize(self): | ||
self.backend.Receive() | ||
self.Plot(); | ||
|
||
def Plot(self): | ||
timesteps = self.multimeter.GetTimestepsString() | ||
attribute = 'v' | ||
neuron_ids = [] | ||
if len(timesteps) > 0: | ||
neuron_ids = self.multimeter.GetNeuronIds(timesteps[0], attribute) | ||
|
||
self.ax1.clear() | ||
|
||
for neuron_id in neuron_ids: | ||
values = self.multimeter.GetTimeSeriesData(attribute, neuron_id) | ||
times = [float(t) for t in timesteps] | ||
self.ax1.plot(times, values) | ||
|
||
self.ax1.set_title("Arbor Miniapp Niv Example") | ||
self.ax1.set_xlabel("Time") | ||
self.ax1.set_ylabel("v") | ||
self.ax1.set_ylim([-80,50]) | ||
|
||
plt.show(block=False) | ||
self.fig.canvas.draw() | ||
|
||
|
||
def main(argv): | ||
app = QApplication(argv) | ||
|
||
w = MainWindow() | ||
w.Show() | ||
|
||
return app.exec_() | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.