diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cdd2302a2d7ac6d0fdf9ce8c1a41df3c8df2832..1e0f46912157f75c3bd224322f2f9c185f91a037 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,30 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) +#-------------------------------------------------------------------- +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +include(ConanHelpers) +include(CTest) +include(GenerateExportHeader) +include(rwthvr) + +enable_testing() + +conan_or_find_package(catch REQUIRED) +conan_or_find_package(contra REQUIRED) +conan_or_find_package(nesci REQUIRED) + +conan_or_find_package(cpplint REQUIRED) +include(cpplint) + +conan_or_find_package(cppcheck REQUIRED) +include(cppcheck) + +find_package(PythonInterp REQUIRED) + +add_subdirectory(demos) +#-------------------------------------------------------------------- + # on OS X set( CMAKE_MACOSX_RPATH ON ) @@ -231,9 +255,6 @@ add_custom_target( dist COMMENT "Creating a source distribution from ${MODULE_NAME}..." ) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup( TARGETS ) - if ( BUILD_SHARED_LIBS ) # When building shared libraries, also create a module for loading at runtime # with the `Install` command. @@ -296,27 +317,6 @@ if ( NOT CMAKE_CROSSCOMPILING ) ) endif () -#-------------------------------------------------------------------- -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include(ConanHelpers) -include(CTest) -include(GenerateExportHeader) -include(rwthvr) - -enable_testing() - -conan_or_find_package(catch REQUIRED) -conan_or_find_package(contra REQUIRED) -conan_or_find_package(nesci REQUIRED) - -conan_or_find_package(cpplint REQUIRED) -include(cpplint) - -conan_or_find_package(cppcheck REQUIRED) -include(cppcheck) -add_subdirectory(demos) -#-------------------------------------------------------------------- - message( "" ) message( "-------------------------------------------------------" ) message( "${MODULE_NAME} Configuration Summary" ) diff --git a/conanfile.py b/conanfile.py index f1566ae334b2533288aaddf5cdadbe83d9a9f2c9..351bf6ad21d82efbcdcd6acc208607ea034507ac 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,9 +26,8 @@ class nest(ConanFile): description = """NEST is a simulator for spiking neural network models that focuses on the dynamics, size and structure of neural systems rather than on the exact morphology of individual neurons.""" settings = "os", "compiler", "build_type", "arch" - requires = (("contra/18.05@RWTH-VR/develop"), - ("nesci/18.05@RWTH-VR/develop"), - ("Qt/5.11.1@bincrafters/stable"), + requires = (("contra/18.07@RWTH-VR/develop"), + ("nesci/18.07@RWTH-VR/develop"), ("conduit/0.3.1@RWTH-VR/thirdparty")) generators = "cmake" diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index 9d501569440ae5e9a0be63a8b15aac974a796909..974fc37ef8db4c122a478576272ddd8b95b221c6 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -19,4 +19,17 @@ # limitations under the License. #------------------------------------------------------------------------------- -add_subdirectory(QVTK-Demo) +# add_subdirectory(QVTK-Demo) + +option(BUILD_BRUNEL_SIMULATION "Build the brunel simulation" ON) +option(BUILD_QVTK_DEMO "Build the QVTK visualization demo" OFF) + +if (${BUILD_BRUNEL_SIMULATION}) + add_subdirectory(brunel_simulation) +endif (${BUILD_BRUNEL_SIMULATION}) + +if (${BUILD_QVTK_DEMO}) + add_subdirectory(QVTK-Demo) +endif (${BUILD_QVTK_DEMO}) + + diff --git a/demos/QVTK-Demo/CMakeLists.txt b/demos/QVTK-Demo/CMakeLists.txt index fa221e450ae431e47d1aa8272f1037c3a22e4aae..492be448f7d430f12d10ca085c0e18ce7c72454e 100644 --- a/demos/QVTK-Demo/CMakeLists.txt +++ b/demos/QVTK-Demo/CMakeLists.txt @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------- -# nest-streaming-module +# QVTK-Demo # -# Copyright (c) 2018 RWTH Aachen University, Germany, +# Copyright (c) 2017-2018 RWTH Aachen University, Germany, # Virtual Reality & Immersive Visualization Group. #------------------------------------------------------------------------------- # License @@ -19,6 +19,6 @@ # limitations under the License. #------------------------------------------------------------------------------- -#add_subdirectory(qvtk-app) +add_subdirectory(qvtk-app) add_subdirectory(qvtk-lib) diff --git a/demos/QVTK-Demo/Readme.txt b/demos/QVTK-Demo/Readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..8602ac1f9b151f31187404906c1cbde5b65e521d --- /dev/null +++ b/demos/QVTK-Demo/Readme.txt @@ -0,0 +1,36 @@ +#------------------------------------------------------------------------------- +# QVTK-Demo +# +# Copyright (c) 2017-2018 RWTH Aachen University, Germany, +# Virtual Reality & Immersive Visualization 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. +#------------------------------------------------------------------------------- + +This is a brief summary on how to get the QVTK-Demo running. + +Prerequisites: + -QT (Version 5.9 or higher is advised! -older versions might work aswell but havent been tested). + -Get this first and build it. + -The Visualization Toolkit(VTK) (The demo was originally build with version 8.0.1. Newer versions should work too but havent been tested). + -Ŵhen building VTK with CMake make sure you enable VTK_BUILD_QT_DESIGNER_PLUGIN, VTK_Group_Qt and set VTK_QT_VERSION to 5. + +Installing: +When running CMake enable BUILD_QVTK_DEMO and BUILD_BRUNEL_SIMULATION. + +Running the Demo: +To run the Demo start both, the QVTK-Demo(qvtk-app) and the Brunel Simulation(run_sim.sh) from your build folder. + + diff --git a/demos/QVTK-Demo/qvtk-app/CMakeLists.txt b/demos/QVTK-Demo/qvtk-app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa8b8c96f551b878ec5dfbbb749c9b7d9e5c0009 --- /dev/null +++ b/demos/QVTK-Demo/qvtk-app/CMakeLists.txt @@ -0,0 +1,71 @@ +#------------------------------------------------------------------------------- +# QVTK-Demo +# +# Copyright (c) 2017-2018 RWTH Aachen University, Germany, +# Virtual Reality & Immersive Visualisation Group. +#------------------------------------------------------------------------------- +# License +# +# This framework is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# In the future, we may decide to add a commercial license +# at our own discretion without further notice. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesse r General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#------------------------------------------------------------------------------- + +set(CMAKE_AUTOMOC ON) +set(QVTK_APP_API_HEADER_DIR include/qvtk_app) + +file(GLOB QVTK_APP_SOURCES src/*.cpp) +file(GLOB QVTK_APP_HEADERS include/qvtk_app/*.hpp) +file(GLOB QVTK_APP_API_HEADERS ${QVTK_APP_API_HEADER_DIR}/*.hpp) +file(GLOB QVTK_APP_SUPPRESS_WARNING_HEADERS include/qvtk_app/suppress_warnings/Qt *.hpp) + +add_executable(qvtk_app + ${QVTK_APP_SOURCES} + ${QVTK_APP_HEADERS} + ${QVTK_APP_API_HEADERS} + ${QVTK_APP_SUPPRESS_WARNING_HEADERS} +) + +target_include_directories( + qvtk_app PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR} +) + +#add_test_cpplint(NAME "qvtk_app--cpplint" +# ${QVTK_APP_SOURCES} +# ${QVTK_APP_HEADERS} +# ${QVTK_APP_API_HEADERS} +# ${QVTK_APP_SUPPRESS_WARNING_HEADERS} +#) + +set_warning_levels_RWTH(qvtk_app + SUPPRESS_WARNINGS_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/qt_app/suppress_warnings.hpp +) + +include_directories(include) + +# --- dependencies --- + +# VTK +find_package(VTK REQUIRED) +include(${VTK_USE_FILE}) +target_include_directories(qvtk_app PUBLIC ${VTK_INCLUDE_DIR}) + +#vtkexperiment +target_include_directories(qvtk_app PUBLIC ${QVTK_LIB_INCLUDE_DIRS}) + +target_link_libraries(qvtk_app PUBLIC qvtk-lib debug ${VTK_LIBRARIES} optimized ${VTK_LIBRARIES}) + diff --git a/demos/QVTK-Demo/qvtk-app/include/qvtk_app/application.hpp b/demos/QVTK-Demo/qvtk-app/include/qvtk_app/application.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b2beda8abf3487f26919ba90f914135075bb5e5c --- /dev/null +++ b/demos/QVTK-Demo/qvtk-app/include/qvtk_app/application.hpp @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// QVTK-Demo +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualisation Group. +//------------------------------------------------------------------------------ +// License +// +// This framework is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// In the future, we may decide to add a commercial license +// at our own discretion without further notice. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +//------------------------------------------------------------------------------ + +#ifndef QVTK_APP_INCLUDE_QVTK_APP_APPLICATION_HPP_ +#define QVTK_APP_INCLUDE_QVTK_APP_APPLICATION_HPP_ + +#include "QApplication" + +#include "qvtk-lib/main_window.hpp" +#include "qvtk-lib/point_data.hpp" + +class Application +{ +public: + Application(int *argc, char **argv); + ~Application() {} + + int Run(); + +private: + QApplication qt_app_; + + vtkexp::PointData points_; + vtkexp::MainWindow window_; +}; + +#endif // QVTK_APP_INCLUDE_QVTK_APP_APPLICATION_HPP_ diff --git a/demos/QVTK-Demo/qvtk-app/src/application.cpp b/demos/QVTK-Demo/qvtk-app/src/application.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b5fd95dab12a074e3b1eb5875cb22666947bb9c --- /dev/null +++ b/demos/QVTK-Demo/qvtk-app/src/application.cpp @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// QVTK-Demo +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualisation Group. +//------------------------------------------------------------------------------ +// License +// +// This framework is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// In the future, we may decide to add a commercial license +// at our own discretion without further notice. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +//------------------------------------------------------------------------------ + +#include "qvtk_app/application.hpp" + +Application::Application(int *argc, char **argv) + : qt_app_{*argc, argv}, points_(6, 6, 1), window_{&points_} {} + +int Application::Run() +{ + window_.show(); + return qt_app_.exec(); +} diff --git a/demos/QVTK-Demo/qvtk-app/src/main.cpp b/demos/QVTK-Demo/qvtk-app/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1fc8d5018dc15715da06ac22aace0dd6ab7a78b6 --- /dev/null +++ b/demos/QVTK-Demo/qvtk-app/src/main.cpp @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// QVTK-Demo +// +// Copyright (c) 2017-2018 RWTH Aachen University, Germany, +// Virtual Reality & Immersive Visualisation Group. +//------------------------------------------------------------------------------ +// License +// +// This framework is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// In the future, we may decide to add a commercial license +// at our own discretion without further notice. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +//------------------------------------------------------------------------------ + +#include "qvtk_app/application.hpp" + +int main(int argc, char **argv) +{ + Application app(&argc, argv); + return app.Run(); +} diff --git a/demos/QVTK-Demo/qvtk-lib/CMakeLists.txt b/demos/QVTK-Demo/qvtk-lib/CMakeLists.txt index 984e636828f71211d6bf54d4e4f58128560ac4fa..32ce237d4fbb58314fee48eb5541bf8bc4f9ba4a 100644 --- a/demos/QVTK-Demo/qvtk-lib/CMakeLists.txt +++ b/demos/QVTK-Demo/qvtk-lib/CMakeLists.txt @@ -1,42 +1,45 @@ #------------------------------------------------------------------------------- # QVTK-Demo # -# Copyright (c) 2018 RWTH Aachen University, Germany, -# Virtual Reality & Immersive Visualization Group. +# Copyright (c) 2017-2018 RWTH Aachen University, Germany, +# Virtual Reality & Immersive Visualisation Group. #------------------------------------------------------------------------------- -# License +# 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 +# This framework is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -# http://www.apache.org/licenses/LICENSE-2.0 +# In the future, we may decide to add a commercial license +# at our own discretion without further notice. # -# 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. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesse r General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. #------------------------------------------------------------------------------- set(CMAKE_AUTOMOC ON) -set(QVTK_DEMO_API_HEADER_DIR include/qvtk-lib) +set(QVTK_LIB_API_HEADER_DIR include/qvtk-lib) -file(GLOB QVTK_DEMO_SOURCES src/*.cpp) -file(GLOB QVTK_DEMO_HEADERS include/qvtk-lib/*.hpp) -file(GLOB QVTK_DEMO_API_HEADERS ${QVTK_DEMO_API_HEADER_DIR}/*.hpp) +file(GLOB QVTK_LIB_SOURCES src/*.cpp) +file(GLOB QVTK_LIB_HEADERS include/qvtk-lib/*.hpp) +file(GLOB QVTK_LIB_API_HEADERS ${QVTK_LIB_API_HEADER_DIR}/*.hpp) -set(QVTK_DEMO_INCLUDE_DIRS +set(QVTK_LIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}qvtk-lib/include ${PROJECT_BINARY_DIR} CACHE PATH "Path to public headers in vtk's source tree." ) -rwthvr_add_library(NAME qvtk-lib - SOURCES ${QVTK_DEMO_SOURCES} - HEADERS ${QVTK_DEMO_HEADERS} - SUPPRESS_WARNINGS_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/contra/qvtk-lib/suppress_warnings.hpp" +add_library(qvtk-lib + ${QVTK_LIB_SOURCES} + ${QVTK_LIB_HEADERS} ) target_include_directories(qvtk-lib @@ -48,33 +51,33 @@ generate_export_header(qvtk-lib EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/qvtk-lib/export.hpp ) -add_test_cpplint(NAME "qvtk-lib--cpplint" - ${QVTK_DEMO_SOURCES} - ${QVTK_DEMO_HEADERS} +set_warning_levels_RWTH(qvtk-lib + SUPPRESS_WARNINGS_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/qvtk-lib/suppress_warnings.hpp ) -#generate_configure_files(qvtk-lib) +#add_test_cpplint(NAME "vtkexperiment--cpplint" +# ${VTKEXPERIMENT_SOURCES} +# ${VTKEXPERIMENT_HEADERS} +#) include_directories(include) # --- dependencies --- - - # VTK find_package(VTK REQUIRED) include(${VTK_USE_FILE}) target_include_directories(qvtk-lib PUBLIC ${VTK_INCLUDE_DIR}) -target_link_libraries(qvtk-lib debug ${VTK_LIBRARIES} optimized ${VTK_LIBRARIES}) target_include_directories(qvtk-lib PUBLIC ${CONAN_INCLUDE_DIRS} ) target_link_libraries(qvtk-lib - PUBLIC ${CONAN_OR_CMAKE_conduit} - PUBLIC ${CONAN_OR_CMAKE_Qt} - PUBLIC ${CONAN_OR_CMAKE_nesci} - PUBLIC ${CONAN_OR_CMAKE_contra} + PUBLIC ${CONAN_OR_CMAKE_contra} + PUBLIC ${CONAN_OR_CMAKE_nesci} + PUBLIC ${CONAN_OR_CMAKE_conduit} + PUBLIC ${CONAN_OR_CMAKE_Qt} + PUBLIC ${CONAN_OR_CMAKE_VTK} + debug ${VTK_LIBRARIES} + optimized ${VTK_LIBRARIES} ) - - diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/animate.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/animate.hpp index cd460822e60c2511694fe021ec6c03930656afe2..bdedbbb2a48fbb1af8ebc09ba19d67a7ce51dad8 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/animate.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/animate.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,15 +23,15 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_ANIMATE_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_ANIMATE_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_ANIMATE_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_ANIMATE_HPP_ #include "QObject" #include "QTimer" #include "include/qvtk-lib/suppress_warnings.hpp" SUPPRESS_WARNINGS_BEGIN -#include "include/qvtk-lib/point_data.hpp" +#include "qvtk-lib/point_data.hpp" SUPPRESS_WARNINGS_END namespace vtkexp @@ -73,4 +73,4 @@ private: } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_ANIMATE_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_ANIMATE_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/data_stream.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/data_stream.hpp index bc9e58dde76a288e7bc62f365fbf271c846d3dc5..7254ccf5045a38be1e1a0289dda4fd2773c25ec0 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/data_stream.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/data_stream.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,39 +23,42 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_DATA_STREAM_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_DATA_STREAM_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_DATA_STREAM_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_DATA_STREAM_HPP_ #include <vector> #include "conduit/conduit_node.hpp" +//#include "contra/boost-shmem/shared_memory_transport.hpp" #include "contra/relay.hpp" -#include "contra/shared_memory_transport.hpp" +#include "contra/zmq/zeromq_transport.hpp" + #include "nesci/consumer/nest_multimeter.hpp" -namespace vtkexp { +namespace vtkexp +{ -class DataStream { - public: +class DataStream +{ +public: DataStream(); ~DataStream() {} std::vector<double> GetMultValuesAt(int time_step); std::vector<double> GetTimeSteps(); - private: +private: void SetUpStream(); void Update(int time_step); std::vector<double> mult_values_; - contra::Relay<contra::SharedMemoryTransport>* relay_; - nesci::consumer::NestMultimeter* multimeter_; + contra::Relay<contra::ZMQTransport> *relay_; + nesci::consumer::NestMultimeter *multimeter_; conduit::Node node_; - std::vector<conduit::Node> node_vec_; }; -} // namespace vtkexp +} // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_DATA_STREAM_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_DATA_STREAM_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/interaction.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/interaction.hpp index b110ddd92e5bf68ef8b2f0e1118e8345848bbeaa..cfc6b51abc9a946416fdae1aac9885ac5eef47fa 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/interaction.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/interaction.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,8 +23,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_INTERACTION_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_INTERACTION_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_INTERACTION_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_INTERACTION_HPP_ #include <string> @@ -84,4 +84,4 @@ class Interaction : public vtkInteractorStyleTrackballCamera } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_INTERACTION_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_INTERACTION_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_widget.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_widget.hpp index a2e7e51d99807dd7bffbae2f319e0806eda2e763..fd0ec97094735bb488f0a6ff010f87d9e7a80968 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_widget.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_widget.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,12 +23,12 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WIDGET_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WIDGET_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WIDGET_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WIDGET_HPP_ -#include "include/qvtk-lib/visualize.hpp" +#include "qvtk-lib/visualize.hpp" -#include "include/qvtk-lib/interaction.hpp" +#include "qvtk-lib/interaction.hpp" #include "QObject" @@ -68,4 +68,4 @@ private: } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WIDGET_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WIDGET_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_window.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_window.hpp index 9c889c8f54c24379eb580ee9f811e2d3111c28ae..a9bf28246dd4a41fcfff408052b1315bd10761f2 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_window.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/main_window.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,15 +23,15 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WINDOW_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WINDOW_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WINDOW_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WINDOW_HPP_ #include "include/qvtk-lib/suppress_warnings.hpp" -#include "include/qvtk-lib/animate.hpp" -#include "include/qvtk-lib/main_widget.hpp" +#include "qvtk-lib/animate.hpp" +#include "qvtk-lib/main_widget.hpp" SUPPRESS_WARNINGS_BEGIN -#include "include/qvtk-lib/point_data.hpp" +#include "qvtk-lib/point_data.hpp" SUPPRESS_WARNINGS_END #include "QComboBox" @@ -96,4 +96,4 @@ private: } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_MAIN_WINDOW_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_MAIN_WINDOW_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/point_data.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/point_data.hpp index 6f75a6fc7a7db6d6fff79b46a4f120179e5dde14..934ccb63c71b959d625599c0d47165c43f71e4c8 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/point_data.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/point_data.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,8 +23,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_POINT_DATA_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_POINT_DATA_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_POINT_DATA_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_POINT_DATA_HPP_ #include <vector> @@ -70,4 +70,4 @@ private: } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_POINT_DATA_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_POINT_DATA_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/visualize.hpp b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/visualize.hpp index 23fb764d6ba2a5a2d07bef3a082d697131c565ed..9b0fc750c88a364b742638dfca86b0cfaef2a5bc 100644 --- a/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/visualize.hpp +++ b/demos/QVTK-Demo/qvtk-lib/include/qvtk-lib/visualize.hpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,8 +23,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#ifndef VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_VISUALIZE_HPP_ -#define VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_VISUALIZE_HPP_ +#ifndef QVTK_LIB_INCLUDE_QVTK_LIB_VISUALIZE_HPP_ +#define QVTK_LIB_INCLUDE_QVTK_LIB_VISUALIZE_HPP_ #include <string> @@ -32,8 +32,8 @@ SUPPRESS_WARNINGS_BEGIN #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" -#include "include/qvtk-lib/interaction.hpp" -#include "include/qvtk-lib/point_data.hpp" +#include "qvtk-lib/interaction.hpp" +#include "qvtk-lib/point_data.hpp" #include "vtkActor.h" #include "vtkAxesActor.h" @@ -95,4 +95,4 @@ private: } // namespace vtkexp -#endif // VTKEXPERIMENT_INCLUDE_VTKEXPERIMENT_VISUALIZE_HPP_ +#endif // QVTK_LIB_INCLUDE_QVTK_LIB_VISUALIZE_HPP_ diff --git a/demos/QVTK-Demo/qvtk-lib/src/animate.cpp b/demos/QVTK-Demo/qvtk-lib/src/animate.cpp index 76ca602fc5643b81d9beeabbe72e9e6c69f5b0de..fb736464121e7be169c2964721cefc1bc50b45fa 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/animate.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/animate.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,7 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#include "include/qvtk-lib/animate.hpp" +#include "qvtk-lib/animate.hpp" namespace vtkexp { diff --git a/demos/QVTK-Demo/qvtk-lib/src/data_stream.cpp b/demos/QVTK-Demo/qvtk-lib/src/data_stream.cpp index f19a58aa9a59ec2b55df594e46418a1e1203d32f..16d39ab583025c37bb8a81023f361835eb6ec853 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/data_stream.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/data_stream.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,7 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#include "include/qvtk-lib/data_stream.hpp" +#include "qvtk-lib/data_stream.hpp" #include <vector> @@ -34,8 +34,8 @@ DataStream::DataStream() { SetUpStream(); } void DataStream::SetUpStream() { - relay_ = new contra::Relay<contra::SharedMemoryTransport>(); - relay_->SetNode(&node_); + relay_ = new contra::Relay<contra::ZMQTransport>( + contra::ZMQTransport::Type::CLIENT, "tcp://localhost:5555"); multimeter_ = new nesci::consumer::NestMultimeter("recordingNode51"); multimeter_->SetNode(&node_); @@ -43,24 +43,20 @@ void DataStream::SetUpStream() void DataStream::Update(int time_step) { - time_step = time_step + 1; - auto time_step_string = std::to_string(time_step); + auto time_step_string = std::to_string(static_cast<double>(time_step)); const auto received_nodes = relay_->Receive(); for (auto node : received_nodes) { - node_vec_.push_back(node); + node_.update(node); } - if (!node_vec_.empty()) + if (time_step == -1 && !multimeter_->GetTimesteps().empty()) { - node_ = node_vec_.back(); - if (time_step == -1 && !multimeter_->GetTimesteps().empty()) - { - time_step_string = multimeter_->GetTimesteps().back(); - } - mult_values_ = multimeter_->GetTimestepData(0, "V_m"); + time_step_string = multimeter_->GetTimesteps().back(); } + + mult_values_ = multimeter_->GetTimestepData(time_step_string, "V_m"); } std::vector<double> DataStream::GetMultValuesAt(int time_step) @@ -72,12 +68,10 @@ std::vector<double> DataStream::GetMultValuesAt(int time_step) std::vector<double> DataStream::GetTimeSteps() { std::vector<double> ret; - for (auto value : multimeter_->GetTimesteps()) { ret.push_back(std::stod(value)); } - return ret; } diff --git a/demos/QVTK-Demo/qvtk-lib/src/interaction.cpp b/demos/QVTK-Demo/qvtk-lib/src/interaction.cpp index 227039c37af1b3b9661631425a67e0c726023bcf..d6554811cb363e5cf50c4f4e98e7f648ac146c31 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/interaction.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/interaction.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,7 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#include "include/qvtk-lib/interaction.hpp" +#include "qvtk-lib/interaction.hpp" #include <string> diff --git a/demos/QVTK-Demo/qvtk-lib/src/main_widget.cpp b/demos/QVTK-Demo/qvtk-lib/src/main_widget.cpp index a2d9f20b4b292d802549878348f4be7a6efee32c..dcc6f6cf638bb7153e63d7cac1d99fc9f63e2c67 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/main_widget.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/main_widget.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,7 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------ -#include "include/qvtk-lib/main_widget.hpp" +#include "qvtk-lib/main_widget.hpp" #include "vtkGenericOpenGLRenderWindow.h" diff --git a/demos/QVTK-Demo/qvtk-lib/src/main_window.cpp b/demos/QVTK-Demo/qvtk-lib/src/main_window.cpp index fedfdbc326cf0df0bc565493b3eb6d9ed6dc506f..980eb8afc59c25bff71de6222b5a2fa810fb21e2 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/main_window.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/main_window.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,9 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#include "include/qvtk-lib/main_window.hpp" - -#include <algorithm> +#include "qvtk-lib/main_window.hpp" namespace vtkexp { @@ -135,7 +133,16 @@ void MainWindow::Rerender() { mainwidget_->Rerender(); } void MainWindow::IncrementSlider() { - int newval = std::min(time_slider_->value() + 1, time_slider_->maximum()); + int newval; + if (time_slider_->value() + 1 < time_slider_->maximum()) + { + newval = time_slider_->value() + 1; + } + else + { + newval = time_slider_->maximum(); + } + time_slider_->setValue(newval); slider_line_edit_->setText(std::to_string(newval).c_str()); } diff --git a/demos/QVTK-Demo/qvtk-lib/src/point_data.cpp b/demos/QVTK-Demo/qvtk-lib/src/point_data.cpp index 2a49cbadffb8de0a85592a1d0dfe96c3833bf803..263c7bc1d82a35fcb489f6fc975d98ad7c22edfc 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/point_data.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/point_data.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -27,7 +27,7 @@ #include "include/qvtk-lib/suppress_warnings.hpp" SUPPRESS_WARNINGS_BEGIN -#include "include/qvtk-lib/point_data.hpp" +#include "qvtk-lib/point_data.hpp" #include "vtkCellArray.h" #pragma GCC diagnostic push @@ -89,7 +89,8 @@ void PointData::AttachColorsToPoints(const std::vector<double> &scalars) { for (int i = 0; i < num_points_; ++i) { - pointcolors_->SetValue(i, scalars.at(static_cast<int>(i))); + pointcolors_->SetValue( + i, static_cast<float>(scalars.at(static_cast<int>(i)))); } points_polydata_->GetPointData()->SetScalars(pointcolors_); } @@ -115,7 +116,7 @@ int PointData::GetStartTime() const { if (!stream_->GetTimeSteps().empty()) { - return stream_->GetTimeSteps().front(); + return static_cast<int>(stream_->GetTimeSteps().front()); } return 0; } @@ -124,7 +125,7 @@ int PointData::GetEndTime() const { if (!stream_->GetTimeSteps().empty()) { - return stream_->GetTimeSteps().back(); + return static_cast<int>(stream_->GetTimeSteps().back()); } return 100; } diff --git a/demos/QVTK-Demo/qvtk-lib/src/visualize.cpp b/demos/QVTK-Demo/qvtk-lib/src/visualize.cpp index 53e33638499db43f2d12b22f8b5310a979c033d3..614c74b13507c2eb05468c8c82d0c27f60686e96 100644 --- a/demos/QVTK-Demo/qvtk-lib/src/visualize.cpp +++ b/demos/QVTK-Demo/qvtk-lib/src/visualize.cpp @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------ -// vtkexperiment +// QVTK-Demo // // Copyright (c) 2017-2018 RWTH Aachen University, Germany, // Virtual Reality & Immersive Visualisation Group. @@ -23,7 +23,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. //------------------------------------------------------------------------------ -#include "include/qvtk-lib/visualize.hpp" +#include "qvtk-lib/visualize.hpp" #include <string> @@ -45,7 +45,7 @@ void Visualize::Initialize( SetUpScene(); SetUpRenderer(); SetUpAxes(); - // SetUpLegend(); + SetUpLegend(); } void Visualize::SetUpLegend() @@ -55,14 +55,13 @@ void Visualize::SetUpLegend() scalar_bar_widget_->SetEnabled(true); scalar_bar_ = scalar_bar_widget_->GetScalarBarActor(); - scalar_bar_->SetTitle("Legend"); + // scalar_bar_->SetTitle("Legend"); scalar_bar_->SetLookupTable(transfer_function_); scalar_bar_->SetOrientationToVertical(); - scalar_bar_->SetNumberOfLabels(4); + scalar_bar_->SetNumberOfLabels(0); - scalar_bar_widget_->EnabledOn(); - - interactor_->Initialize(); + scalar_bar_->SetPosition2(0, 0); + scalar_bar_->SetBarRatio(0.6); } void Visualize::SetUpAxes() @@ -73,7 +72,7 @@ void Visualize::SetUpAxes() axes_widget_->SetOutlineColor(0.9300, 0.5700, 0.1300); axes_widget_->SetOrientationMarker(axes_); axes_widget_->SetInteractor(interactor_); - axes_widget_->SetViewport(0., 0.0, 0.2, 0.2); + axes_widget_->SetViewport(0.0, 0.0, 0.2, 0.2); axes_widget_->SetEnabled(1); axes_widget_->InteractiveOn(); diff --git a/demos/brunel_simulation/CMakeLists.txt b/demos/brunel_simulation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d3ef96fed9fec640b54a71445f59fa350e92ab6 --- /dev/null +++ b/demos/brunel_simulation/CMakeLists.txt @@ -0,0 +1,30 @@ +#------------------------------------------------------------------------------- +# nest-streaming-module +# +# Copyright (c) 2018 RWTH Aachen University, Germany, +# Virtual Reality & Immersive Visualization 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. +#------------------------------------------------------------------------------- + +get_filename_component(NEST_DIR ${with-nest} DIRECTORY) + +set(SCRIPT_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/run_sim.sh") + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run_sim.sh.in ${SCRIPT_FILENAME}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/brunel_example.py ${CMAKE_CURRENT_SOURCE_DIR}/nest_sim.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_target(brunel_simulation ALL chmod "+x" "run_sim.sh" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${SCRIPT_FILENAME} ${CMAKE_CURRENT_BINARY_DIR}/brunel_example.py ${CMAKE_CURRENT_SOURCE_DIR}/nest_sim.py) diff --git a/demos/brunel_simulation/brunel_example.py b/demos/brunel_simulation/brunel_example.py new file mode 100644 index 0000000000000000000000000000000000000000..4c59b60dbaa9fd1c84c694131ef9825f736d9a3c --- /dev/null +++ b/demos/brunel_simulation/brunel_example.py @@ -0,0 +1,265 @@ + +""" +Definition of spatially extended Brunel network. +This module provides layer and projections declarations suitable for +use with the NEST Topology Module. +It defines a Brunel-style network with neurons placed on a regular grid. +Connectivity is probabilitstic from the entire network, i.e., connectivity +is not structured spatially. +""" + +from copy import deepcopy +from math import sqrt +import numpy as np +from mpl_toolkits.mplot3d import Axes3D +import matplotlib.pyplot as plt + +import nest +import nest.raster_plot +import nest.topology as tp + + +class Brunel3D: + + def __init__(self): + self.layer_dict = {} + nest.Install("streamingmodule") + # nest.SetKernelStatus({'print_time': True}) + + class Parameters: + """ + Define model parameters. + """ + order = 9 # must be square + NE = 4 * order # number of excitatory neurons. + NI = 1 * order # number of inhibitory neurons + + lengthE = int(sqrt(NE)) + lengthI = int(sqrt(NI)) + + if not (lengthE**2 == NE and lengthI**2 == NI): + raise ValueError('Order must be a square number (order = n**2)') + + # neuron_model = 'iaf_psc_alpha' + neuron_model = 'mat2_psc_exp' + + g = 5.0 # ratio inhibitory weight/excitatory weight + eta = 2.0 # external rate relative to threshold rate + epsilon = 0.1 # connection probability + + delay = 1.5 # synaptic delay in ms + + tauMem = 20.0 # time constant of membrane potential in ms + theta = 20.0 # membrane threshold potential in mV + + J = 0.1 # postsynaptic amplitude in mV + J_ex = J # amplitude of excitatory postsynaptic potential + J_in = -g * J_ex # amplitude of inhibitory postsynaptic potential + + CE = int(epsilon * NE) # number of excitatory synapses per neuron + + nu_th = theta / (J * CE * tauMem) + nu_ex = eta * nu_th + p_rate = 1.0 * nu_ex * CE + + neuron_params = {"C_m": 1.0, + "tau_m": tauMem, + "t_ref": 2.0, + "E_L": 0.0, + # "V_reset": 0.0, # doesn't work with mat2_psc_exp + # "V_th": theta, # doesn't work with mat2_psc_exp + "V_m": 0.0 + } + mm_params = {'record_from': ['V_m', 'V_th'], + 'record_to': ['streaming']} + poisson_params = {"rate": p_rate} + + def modified_copy(self, orig, diff): + """ + Returns a deep copy of dictionary with changes applied. + @param orig original dictionary, will be deep-copied + @param diff copy will be updated with this dict + """ + + tmp = deepcopy(orig) + tmp.update(diff) + return tmp + + def make_layer_specs(self): + """ + Returns lists of dictionaries with model, layer, and synapse model + specifications. + """ + + P = self.Parameters + + self.models = [(P.neuron_model, 'excitatory', P.neuron_params), + (P.neuron_model, 'inhibitory', P.neuron_params), + ('poisson_generator', 'noise', P.poisson_params), + ('multimeter', 'recordingNode', P.mm_params)] + + self.syn_models = [('static_synapse', 'static_excitatory', {})] + + dE = 1.0 / float(P.lengthE) + limE = (1.0 - dE) / 2.0 + posE = np.linspace(-limE, limE, num=P.lengthE) + + dI = 1.0 / float(P.lengthI) + limI = (1.0 - dI) / 2.0 + posI = np.linspace(-limI, limI, num=P.lengthI) + + self.layers = [('Excitatory', {'positions': [[x, y, 0.4] + for x in posE + for y in posE], + 'edge_wrap': True, + 'elements': 'excitatory'}), + ('Inhibitory', {'positions': [[x, y, -0.4] + for x in posI + for y in posI], + 'edge_wrap': True, + 'elements': 'inhibitory'})] + self.layers.append(('PoissonGenerator', + {'positions': [[0.0, 0.0, 0.0]], + 'elements': 'noise'})) + self.layers.append(('Multimeter', + {'positions': [[0.0, 0.0, 0.0]], + 'elements': 'recordingNode'})) + self.layers.append(('SpikeDetector', + {'positions': [[0.0, 0.0, 0.0]], + 'elements': 'spike_detector'})) + + def make_connection_specs(self): + """ + Returns list of dictionaries specifying projections for Brunel network. + """ + + P = self.Parameters + + self.projections = [('Excitatory', 'Excitatory', + {'connection_type': 'convergent', + 'synapse_model': 'static_synapse', + 'kernel': P.epsilon, + 'weights': P.J_ex, + 'delays': P.delay}), + ('Excitatory', 'Inhibitory', + {'connection_type': 'convergent', + 'synapse_model': 'static_synapse', + 'kernel': P.epsilon, + 'weights': P.J_ex, + 'delays': P.delay}), + ('Inhibitory', 'Excitatory', + {'connection_type': 'convergent', + 'synapse_model': 'static_synapse', + 'kernel': P.epsilon, + 'weights': P.J_in, + 'delays': P.delay}), + ('Inhibitory', 'Excitatory', + {'connection_type': 'convergent', + 'synapse_model': 'static_synapse', + 'kernel': P.epsilon, + 'weights': P.J_in, + 'delays': P.delay}), + ('Multimeter', 'Excitatory', + {'connection_type': 'convergent'}), + ('Excitatory', 'SpikeDetector', + {'connection_type': 'convergent'}), + ('Inhibitory', 'SpikeDetector', + {'connection_type': 'convergent'}), + ('PoissonGenerator', 'Excitatory', + {'connection_type': 'convergent'})] + + def make_layers(self): + # First, we copy the models with custom specifications + # Neuron models + for model in self.models: + old_name, new_name, spec = model + nest.CopyModel(old_name, new_name, spec) + # Synapse models + for model in self.syn_models: + old_name, new_name, spec = model + nest.CopyModel(old_name, new_name, spec) + + # Next we make the layers + for l in self.layers: + name = l[0] + specs = l[1] + self.layer_dict.update({name: tp.CreateLayer(specs)}) + + def make_connections(self): + # Connect layers + for proj in self.projections: + pre_layer = self.layer_dict[proj[0]] + post_layer = self.layer_dict[proj[1]] + conn_specs = proj[2] + tp.ConnectLayers(pre_layer, post_layer, conn_specs) + + def simulate(self): + nest.Simulate(1000) + + def plot_positions(self): + ex_pos = self.layers[0][1]['positions'] + in_pos = self.layers[1][1]['positions'] + fig = plt.figure() + ax = Axes3D(fig) + for c, m, positions in [('b', 'o', ex_pos), ('r', '^', in_pos)]: + ax.scatter([x for x, y, z in positions], + [y for x, y, z in positions], + [z for x, y, z in positions], + c=c, marker=m) + + def get_results(self): + mm = (self.layer_dict['Multimeter'][0] + 1,) + sd = (self.layer_dict['SpikeDetector'][0] + 1,) + mm_status = nest.GetStatus(mm)[0] + sd_status = nest.GetStatus(sd)[0] + + nest.raster_plot.from_device(sd, hist=True) + + senders = mm_status['events']['senders'] + times = mm_status['events']['times'] + v_m = mm_status['events']['V_m'] + v_th = mm_status['events']['V_th'] + step = int(max(senders)/100 + 1) # Only plot results from some GIDs + + mm_events = [] + for i in range(1, max(senders) + 1, step): + if i in senders: + indices = np.argwhere(senders == i) + mm_events.append({'GID': i, + 'times': [times[n] for n in indices], + 'V_m': [v_m[n] for n in indices], + 'V_th': [v_th[n] for n in indices]}) + + return {'multimeter': mm_events, + 'spike_detector': nest.GetStatus(sd)[0]} + + +if __name__ == '__main__': + nest.ResetKernel() + + print('Making specifications') + brunel = Brunel3D() + brunel.make_layer_specs() + brunel.make_connection_specs() + + print('Making layers') + brunel.make_layers() + nest.topology.DumpLayerNodes([l[0] for l in brunel.layer_dict.values()][:2], + 'brunel_nodes.txt') + + print('Making connections') + brunel.make_connections() + + brunel.simulate() + + print('Getting results') + brunel.plot_positions() + results = brunel.get_results() + + for value in ['V_m', 'V_th']: + plt.figure() + for n in results['multimeter'][::20]: + plt.plot(n['times'], n[value], label='{}'.format(n['GID'])) + plt.legend() + plt.title(value) + plt.show() diff --git a/demos/brunel_simulation/nest_sim.py b/demos/brunel_simulation/nest_sim.py new file mode 100644 index 0000000000000000000000000000000000000000..65788db7fdfa3b6b407bc8f91ba08e04e1dc8dfc --- /dev/null +++ b/demos/brunel_simulation/nest_sim.py @@ -0,0 +1,94 @@ +#------------------------------------------------------------------------------- +# 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 nest +import numpy + +from PyQt5.QtWidgets import QApplication, QPushButton +from PyQt5.QtCore import QTimer + +import brunel_example + +class Simulation: + def __init__(self): + self.SetupSim() + + def SetupSim(self): + nest.ResetKernel() + + print('Making specifications') + self.brunel = brunel_example.Brunel3D() + self.brunel.make_layer_specs() + self.brunel.make_connection_specs() + + print('Making layers') + self.brunel.make_layers() + nest.topology.DumpLayerNodes([l[0] for l in self.brunel.layer_dict.values()][:2], + 'brunel_nodes.txt') + + print('Making connections') + self.brunel.make_connections() + + def Simulate(self, steps): + nest.Simulate(steps) + + +class MainWindow: + def __init__(self, screen_resolution): + self.screen_resolution = screen_resolution + self.SetupWindow() + self.simulation = Simulation() + + def SetupWindow(self): + self.simulate_button = QPushButton("nest.Simulate(1000)") + self.simulate_button.clicked.connect(self.SimulateButtonClicked) + + def SimulateButtonClicked(self): + self.simulate_button.setEnabled(False) + QApplication.processEvents() + + self.simulation.Simulate(1000) + + QApplication.processEvents() + self.simulate_button.setEnabled(True) + + def Show(self): + self.simulate_button.show() + button_geometry = self.simulate_button.geometry() + self.simulate_button.setGeometry( + self.screen_resolution.width() - button_geometry.width(), + self.screen_resolution.height() - button_geometry.height(), + button_geometry.width(), + button_geometry.height()) + + +def main(argv): + app = QApplication(argv) + screen_resolution = app.desktop().screenGeometry() + + w = MainWindow(screen_resolution) + w.Show() + + return app.exec_() + +if __name__ == "__main__": + main(sys.argv) diff --git a/demos/brunel_simulation/run_sim.sh.in b/demos/brunel_simulation/run_sim.sh.in new file mode 100644 index 0000000000000000000000000000000000000000..4ce4dd2b4a1963b434be5e484798e2645f8cbba1 --- /dev/null +++ b/demos/brunel_simulation/run_sim.sh.in @@ -0,0 +1,2 @@ +source ${NEST_DIR}/nest_vars.sh +LD_LIBRARY_PATH=$NEST_MODULE_PATH:$LD_LIBRARY_PATH ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/nest_sim.py \ No newline at end of file diff --git a/sli/mymodule-init.sli b/sli/streamingmodule-init.sli similarity index 100% rename from sli/mymodule-init.sli rename to sli/streamingmodule-init.sli