Skip to content

Commit

Permalink
added CARLsim version
Browse files Browse the repository at this point in the history
  • Loading branch information
nmsutton committed Mar 22, 2023
1 parent 9213f41 commit 60c89ca
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.class
*.csv
*.csv
/CARLsim_version/iz_fp_eval/build_dir
/CARLsim_version/iz_fp_eval/scripts/*.png
32 changes: 32 additions & 0 deletions CARLsim_version/iz_fp_eval/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
project(iz_fp_eval)

# Targets
add_executable(iz_fp_eval
src/main_iz_fp_eval.cpp
)

# definitions
if(CARLSIM_NO_CUDA)
target_compile_definitions(iz_fp_eval PUBLIC
-D__NO_CUDA__ )
endif()

# Linking
target_link_libraries(iz_fp_eval PRIVATE
carlsim
carlsim-stopwatch
)
target_include_directories(iz_fp_eval PRIVATE
../../tools/stopwatch
)


# Installation
install(TARGETS iz_fp_eval
EXPORT carlsim
RUNTIME
DESTINATION $<$<CONFIG:Debug>:debug/>samples
COMPONENT iz_fp_eval
)

#install(FILES run_iz_fp_eval DESTINATION $<$<CONFIG:Debug>:debug/>samples)
1 change: 1 addition & 0 deletions CARLsim_version/iz_fp_eval/rebuild_stellate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make clean && make && ./iz_fp_eval 118.000000 0.62 -58.53 -43.52 0.005 8.0 11.48 -49.52 8.5
37 changes: 37 additions & 0 deletions CARLsim_version/iz_fp_eval/scripts/demoOAT.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
% A simple demo of the NetworkMonitor functionality

% add Offline Analysis Toolbox to path
initOAT;

% init NetworkMonitor
NM = NetworkMonitor('../results/sim_hello world.dat');

% plot network activity
disp('NetworkMonitor.plot')
disp('-------------------')
disp('Press ''p'' to pause.')
disp('Press ''q'' to quit.')
disp(['Press ''s'' to enter stepping mode; then press the ' ...
'right arrow key to step'])
disp('one frame forward, press the left arrow key to step one frame back.')
disp('Press ''s'' again to leave stepping mode.')
disp(' ')
NM.plot;


% init ConnectionMonitor
CM = ConnectionMonitor('input','output','../results/');

% visualize receptive fields (little 2D Gaussian kernels for each post-neuron)
disp('ConnectionMonitor.plot(''receptivefield'')')
disp('-------------------')
disp('Press ''p'' to pause.')
disp('Press ''q'' to quit.')
disp(['Press ''s'' to enter stepping mode; then press the ' ...
'right arrow key to step'])
disp('one frame forward, press the left arrow key to step one frame back.')
disp('Press ''s'' again to leave stepping mode.')
CM.plot('receptivefield')

% analogously, the response field of each pre-neuron can be visualized:
% CM.plot('responsefield')
3 changes: 3 additions & 0 deletions CARLsim_version/iz_fp_eval/scripts/initOAT.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
% add path to Offline Analysis Toolbox
%addpath('../../../tools/offline_analysis_toolbox')
addpath('/comp_neuro/Software/CARLsim4_dgx_hc_09_18_21/tools/offline_analysis_toolbox')
18 changes: 18 additions & 0 deletions CARLsim_version/iz_fp_eval/scripts/plot_results.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% analyze voltage from a neuron using IZ 9-param model

function []=plot_results(volt_file, output_desc)
initOAT;
save_plot=1;
neur_read = NeuronReader(volt_file);
voltages = neur_read.readValues();
t_start = 1; % start time
t_end = 1100; % end time
t_range = linspace(t_start,t_end,(t_end-t_start+1));
selected_volt = voltages.v(1,t_start:t_end);
% plot
plot(t_range, selected_volt,'Color','#80B3FF','LineWidth',1.5);
if save_plot
output_filename = sprintf("voltage_%s.png",output_desc);
exportgraphics(gcf,output_filename,'Resolution',300)
end
end
1 change: 1 addition & 0 deletions CARLsim_version/iz_fp_eval/scripts/run_plot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plot_results('../build_dir/results/n_neuron.dat', 'test');
1 change: 1 addition & 0 deletions CARLsim_version/iz_fp_eval/src/.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Put all source files (.cpp and .cu) here
85 changes: 85 additions & 0 deletions CARLsim_version/iz_fp_eval/src/main_iz_fp_eval.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The names of its contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************************************** *
* CARLsim
* created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
* maintained by:
* (MA) Mike Avery <[email protected]>
* (MB) Michael Beyeler <[email protected]>,
* (KDC) Kristofor Carlson <[email protected]>
* (TSC) Ting-Shuo Chou <[email protected]>
* (HK) Hirak J Kashyap <[email protected]>
*
* CARLsim v1.0: JM, MDR
* CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
* CARLsim3: MB, KDC, TSC
* CARLsim4: TSC, HK
* CARLsim5: HK, JX, KC
* CARLsim6: LN, JX, KC, KW
*
* CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
* Ver 12/31/2016
*/

// include CARLsim user interface
#include <carlsim.h>

int main(int argc, char *argv[]) {
if (argc != 10) {
printf("\nUsage: iz_fp_eval <9_IM_params>\n");
printf("%d arguments found.\n",argc);
}
else {
// ---------------- CONFIG STATE -------------------
CARLsim sim("hello world", GPU_MODE, USER, 1, 42);
int dummy = sim.createSpikeGeneratorGroup("dummy_connection", 1, EXCITATORY_NEURON, 0, GPU_CORES);
int neuron=sim.createGroup("neuron", 1, EXCITATORY_NEURON, ANY, GPU_CORES);
sim.setNeuronParameters(neuron, atof(argv[1]), 0.0f, atof(argv[2]),
0.0f, atof(argv[3]), 0.0f, atof(argv[4]), 0.0f, atof(argv[5]), 0.0f,
atof(argv[6]), 0.0f, atof(argv[7]), 0.0f, atof(argv[8]), 0.0f,
atof(argv[9]), 0.0f, 150);
sim.connect(dummy, neuron, "one-to-one", 0.0f, SYN_FIXED); // CARLsim seems to require at least one connection. This is a dummy connection with no signaling to the other neuron.
sim.setNeuronMonitor(neuron,"DEFAULT");
sim.setIntegrationMethod(RUNGE_KUTTA4, 1);//40);
// ---------------- SETUP STATE -------------------
sim.setupNetwork();
SpikeMonitor* spk_mon = sim.setSpikeMonitor(neuron, "DEFAULT");
// ---------------- RUN STATE -------------------
spk_mon->startRecording();
for (int i=0; i<100; i++) {
if (i==1) {sim.setExternalCurrent(neuron, 200.0f);}
if (i==10) {sim.setExternalCurrent(neuron, 0.0f);}
sim.runNetwork(0,100, false);
}
spk_mon->stopRecording();
}

return 0;
}
58 changes: 58 additions & 0 deletions CARLsim_version/iz_fp_eval/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
project(carlsim-hello-world)
cmake_minimum_required(VERSION 3.19.4)


# Dependencies

find_package(carlsim REQUIRED)

# Targets

add_executable(hello_world
src/main_hello_world.cpp
)

if(CARLSIM_NO_CUDA)
target_compile_definitions(hello_world
PUBLIC
-D__NO_CUDA__
)
endif()

# include
target_include_directories(hello_world PRIVATE
${CARLSIM_INCLUDE_DIR}
)

# Linking

target_link_directories(hello_world PRIVATE
${CARLSIM_LIB_DIR}
)

if(NOT CARLSIM_NO_CUDA)
target_link_directories(hello_world PRIVATE
${CARLSIM_CUDA_LIB_DIR}
)
endif()

target_link_libraries(hello_world PRIVATE
carlsim$<$<CONFIG:Debug>:d>.lib
carlsim-stopwatch$<$<CONFIG:Debug>:d>.lib
# carlsim-interface
# carlsim-kernel
# carlsim-monitor
# carlsim-simple-weight-tuner
# carlsim-spike-generators
# carlsim-stopwatch
# carlsim-visual-stimulus
)

if(NOT CARLSIM_NO_CUDA)
target_link_libraries(hello_world PRIVATE
carlsim-kernel-cuda
cudart
curand
)
endif()

0 comments on commit 60c89ca

Please sign in to comment.