# Central Amygala: Noiceceptive output model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

## HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

## HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

## THINGS TO NOTICE

(suggested things for the user to notice while running the model)

## THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

## EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

## NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

## RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

## CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

## Comments and Questions

extensions [csv] ;VARIABLES ------------------------------------------------------------------------------------------------------------------------------------------------------------- ;defining patch attributes patches-own [InAmygdala? InCeC? InCeM? InCeL? Bregma] ;InAmygdala? holds "Yes" or "No" ;InCeC/M/L? (yes/no) is this patch in the CeC/M/L ;Bregma holds values of Dr. Kolberâ€™s slices (x-values) ;defining turtle variables turtles-own [Firing-Rate Damage-Latency Sensitivity Damage Expression-Type Rate-Type Inhibited? Incoming-Connections Outgoing-Connections Incoming-Connections-IDs Outgoing-Connections-IDs numToSOM numToPKC sumDistances CeL_turtle? CeC_turtle? CeM_turtle? Inhibited_Laser? Activated_Laser?] ; Firing-Rate is the firing rate of each neuron (V), Damage-Latency is how long each neuron can withstand distension before becoming damaged (C), ; Sensitivity is the sensitivity of each neuron (C), Damage is the damage accumulated by each neuron (V) ; Expression-Type is the protein expressed, SOM or PKC, of each neuron (C), Rate-Type is the type of firing rate, regular or late or silent, of each neuron (C for regular and late, but V for silent), ; Inhibited? is a tracker variable for if a neuron was turned off by a connection (V), Incoming/Outgoing-Connections are variables to count the number of incoming/outgoing connections a neuron has (C) ; Incoming/Outgoing-Connections-IDs are variables that track the IDs of turtles that are sending/receiving signals to/from a turtle (List) ; numToSOM/PKC are variables to count the number of connections a turtle made to SOM and PKC turtles, sumDistances is a variable to record the sum of the distances between a turtle and its connections ;CeL/M/C_turtle? (Yes/no) is this neuron in the CeL? ;Inhibited/Activated_Laser? (T/F) was the button pressed on interface? Laser indicates that the neurons' firing rates will be updated based on if they are inhibited or activated. globals [ Stimulation-Time ;tracks the total "time" measured in ticks that all the neurons have experienced stimulation. It is the same for all neurons but changes with time ;cumulative firing rates for SOM/PKC regular/late firing neurons CR-SOM-regular CR-PKC-regular CR-SOM-late CR-PKC-late ;cumulative damage for SOM/PKC regular/late firing neurons ; CD-SOM-regular CD-PKC-regular CD-SOM-late CD-PKC-late ;average damage overall all neurons avgDamage ;cumulative firing rate for SOM/PKC neurons CR-SOM CR-PKC Pain ;Pain value for that time tick Stimulated? ;value read from the stimulation history file (current values in pA) ;keeps track of the ratio of PKC/SOM RS neurons to PKC/SOM neurons Ratio-PKC Ratio-SOM ;number of SOM/PKC inhibited neurons SOMInhibited PKCInhibited TotInhibited ;total number of PKC and SOM neurons that are inhibited ;Agent sets PKC-Late-turtles PKC-Regular-turtles PKC-Spontaneous-turtles SOM-Late-turtles SOM-Regular-turtles SOM-Spontaneous-turtles SOM-turtles PKC-turtles ;holds the percentage of each connection after the neural network is established %-SOM-SOM-connections %-SOM-PKC-connections %-SOM-OTHER-connections %-PKC-SOM-connections %-PKC-PKC-connections %-PKC-OTHER-connections ;holds the mean link lengths of PKC and SOM neurons Mean-SOM-link-length Mean-PKC-link-length ; (On/Off) boolean that allows for activation/inhibition Laser? setup-world? ;(T/F) boolean that allows the CeA structure to not be cleared after it has been genereated once ] ; END VARIABLES ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; MODEL INITIALIZATION ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;SETUP - creates CeA structure (if it has not been created yet) and the uniform distribution of neurons. --button on interface-- to setup-uniform reset-timer let setup-world-local? setup-world? ;clear all recordings of previous runs clear-globals ;Sets all code-defined global variables (i.e., those defined inside of globals [ ... ]) to 0. Global variables defined by widgets are not affected by this primitive. clear-ticks ;Clears the tick counter. clear-turtles ;Kills all turtles. clear-all-plots ;Clears every plot in the model clear-output ;Clears all text from the model's output area file-close-all ; closes all files that have been previously opened ;if the CeA structure has not been created yet, execute this code ifelse setup-world-local? != True [ set-up-amygdala ;executes this procedure below. creates the CeA structure. set setup-world? True ;indictaes that the CeA structure has been created and does not need to be created again ] [ set setup-world? True ; reset the global var setup-world? to match the local var setup-world-local? (i.e. True) ] setup-turtles-uniform ;executes procedure below. creates uniform distribution of turtles. setup-turtles-expression-type ;executes this procedure below. assigns each neuron's expression type PKC/SOM ;assigns Rate Types (Reg,Late,Spon) to each PKC and SOM turtle setup-turtles-SOM ;executes this procedure below setup-turtles-PKC ;executes this procedure below ;sets damage-latency, sensitivity, & damage of each neuron ask turtles [ set Damage-Latency random (81 - 40) + 40 set Sensitivity random (151 - 50) + 50 set Damage 0 ;sets damage-latency, sensitivity, & damage of each neuron set Inhibited_Laser? False set Activated_Laser? False ;sets every neuron's laser to false indicating that no neuron has been marked as inhibited/activated. Changed to true when button is pressed on interface indicating these neurons are marked as inhibited/activated ] ; sets laser off by default. Changes to "On" when activation/inhibition buttons are pressed on interface set Laser? "Off" ;-- AGENT SETS of TURTLES -- set PKC-Late-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Late"] set PKC-Regular-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Regular"] set PKC-Spontaneous-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Spontaneous"] set PKC-turtles turtles with [Expression-Type = "PKC"] set SOM-Late-turtles turtles with [ Expression-Type = "SOM" and Rate-Type = "Late"] set SOM-Regular-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Regular"] set SOM-Spontaneous-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Spontaneous"] set SOM-turtles turtles with [Expression-Type = "SOM"] ;---------------------------- ; if the switch Neural-Network? (on interface) is turned to on, execute this block of code. if Neural-Network? [ create-network ;executes procedure below that creates the neural network Calculate-Connection-%s Calculate-Mean-Connection-Distance ] ; executes procedure below. decides which file to open based on the drop down on the interface of which current values you want to use file-opening-setup ; clears the tick counter reset-ticks show timer end ;SETUP - creates CeA structure (if it has not been created yet) and the non-uniform distribution of neurons. --button on interface-- to setup-nonuniform let setup-world-local? setup-world? ;;clear all recordings of previous runs clear-globals ;Sets all code-defined global variables (i.e., those defined inside of globals [ ... ]) to 0. Global variables defined by widgets are not affected by this primitive. clear-ticks ;Clears the tick counter. clear-turtles ;Kills all turtles. clear-all-plots ;Clears every plot in the model clear-output ;Clears all text from the model's output area file-close-all ; closes all files that have been previously opened ;if the CeA structure has not been created yet, execute this code ifelse setup-world-local? != True [ set-up-amygdala ;executes this procedure below. creates the CeA structure. set setup-world? True ;indictaes that the CeA structure has been created and does not need to be created again ] [ set setup-world? True ; reset the global var setup-world? to match the local var setup-world-local? (i.e. True) ] setup-turtles-nonuniform ;executes procedure below. creates non-uniform distribution of turtles and assigns each neuron's expression type PKC/SOM ;assigns Rate Types (Reg,Late,Spon) to each PKC and SOM turtle setup-turtles-SOM ;executes this procedure below setup-turtles-PKC ;executes this procedure below ;sets damage-latency, sensitivity, & damage of each neuron ask turtles [ set Damage-Latency random (81 - 40) + 40 set Sensitivity random (151 - 50) + 50 set Damage 0 set Inhibited_Laser? False set Activated_Laser? False ] ; sets laser off by default. Changes to "On" when activation/inhibition buttons are pressed on interface set Laser? "Off" ; -- AGENT SETS of TURTLES -- set PKC-Late-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Late"] set PKC-Regular-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Regular"] set PKC-Spontaneous-turtles turtles with [Expression-Type = "PKC" and Rate-Type = "Spontaneous"] set PKC-turtles turtles with [Expression-Type = "PKC"] set SOM-Late-turtles turtles with [ Expression-Type = "SOM" and Rate-Type = "Late"] set SOM-Regular-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Regular"] set SOM-Spontaneous-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Spontaneous"] set SOM-turtles turtles with [Expression-Type = "SOM"] ;---------------------------- ; if the switch Neural-Network? (on interface) is turned to on, execute this block of code. if Neural-Network? [ create-network Calculate-Connection-%s Calculate-Mean-Connection-Distance ] ; executes procedure below. decides which file to open based on the drop down on the interface of which current values you want to use file-opening-setup ; clears the tick counter reset-ticks show timer end ; END MODEL INITIALIZATION ------------------------------------------------------------------------------------------------------------------------------------------------------ ; SUB-PROCEDURES FOR INITIALIZATION ----------------------------------------------------------------------------------------------------------------------------------------- ; Procedures (below) called by setup procedures (above) ;sets which current file to read from for the next model run to file-opening-setup let s File-To-Use ;assigns the file chosen on the interface to variable s if s = "Ramping Current" [file-open "stimulationhistory2.csv"] ; opens the stimulation history file with all current values, which must be located in the same folder as this program, others should only be used for BehaviorSpace experiments if s = "Current Values: All 120" [file-open "stimulationhistory120.csv"] ; opens the stimulation history file with all values of 120, which must be located in the same folder as this program end ;creates CeA structure to set-up-amygdala ;reset-timer ;---------------------------CeC Patches --------------------------------; file-open "CeC_Patches.txt" ;opens file containing the CeC patches ;while loop to read the file while [not file-at-end? ] [ ;reads the next x,y,z coordinates let next-X file-read let next-Y file-read let next-Z file-read ask patch next-X next-Y next-Z ;ask this patch to execute the code below [ set InAmygdala? "Yes" set InCeC? "Yes" ; set pcolor lput 25 extract-rgb red set pcolor red ] ] file-close ;close this file ;---------------------------CeM Patches ---------------------------------; file-open "CeM_Patches.txt" ;opens file containing the CeM patches ;while loop to read the file while [not file-at-end? ] [ ;reads the next x,y,z coordinates let next-X file-read let next-Y file-read let next-Z file-read ask patch next-X next-Y next-Z ;ask this patch to execute the code below [ ; set pcolor lput 25 extract-rgb green set pcolor green set InAmygdala? "Yes" set InCeM? "Yes" ] ] file-close ;close this file ;---------------------------CeL Patches ----------------------------------; file-open "CeL_Patches.txt" ;opens file containing the CeL patches ;while loop to read the file while [not file-at-end? ] [ ;reads the next x,y,z coordinates let next-X file-read let next-Y file-read let next-Z file-read ask patch next-X next-Y next-Z ;ask this patch to execute the code below [ ; set pcolor lput 25 extract-rgb blue set pcolor blue set InAmygdala? "Yes" set InCeL? "Yes" ] ] file-close ;close this file ;-------------------------------------------------------------------------; ;Set bregma values of the patches in the CeA ask patches with [InAmygdala? = "Yes"] [ set Bregma precision(-0.675 -((pxcor - 2)*(0.025))) 3 ] ;set values of the patches not in the CeA ask patches with [pcolor = black] [set InAmygdala? "No" set InCeC? "No" set InCeM? "No" set InCeL? "No"] set setup-world? True ;indictaes that the CeA structure has been created and does not need to be created again ;show timer end to setup-turtles-uniform ; places neurons within the CeA ask n-of neurons patches with [InAmygdala? = "Yes"] [sprout 1] ;creates neurons in the Left amygdala ask turtles [ setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) set shape "circle" ;set neuron shape to sphere set size .5 ;set neuron shape to 0.5 ] end to setup-turtles-expression-type ;sets the expression type of the neurons as either SOM or PKC (based on the sliders for the percentages) let a count turtles ;counts the number of neurons in the left hemisphere let %b SST ;is a slider determining the number of SOM neurons in the left hemisphere as a decimal between 0 and 1,the rest are PKC Note: sliders are global variables (not listed above) ask n-of (%b * a) turtles ;asks random number of neurons (based on sliders) with these properties to execute following code [ set Expression-Type "SOM" ;set the left SOM neurons set color red ;sets all SOM neurons in the left to red ] ask turtles ;asks random number of neurons (based on sliders) with these properties to execute following code [if Expression-Type != "SOM" [ set Expression-Type "PKC" ;set the left PKC neurons set color blue ;sets all PKC neurons in the left to blue ] ] end to setup-turtles-nonuniform ; places neurons within the CeC CeL CeM of the CeA let counter 0 ;local variable that tracks the number of turtles being created in each region let num_PKC_CeC (%PKC_CEC * ((1 - SST) * neurons)) ;calculates number of PKC turtles to be generated in CeC (% comes from slider of interface) while [counter <= num_PKC_CeC] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeC? = "Yes"] ;moves the turtle to the middle of a CeC patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "PKC" set shape "circle" set size 0.5 set color blue set CeC_turtle? "Yes" ] set counter counter + 1 ;increment counter ] set counter 0 ;reset counter let num_PKC_CeL (%PKC_CEL * ((1 - SST) * neurons)) ;calculates number of PKC turtles to be generated in CeL (% comes from slider of interface) while [counter <= num_PKC_CeL] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeL? = "Yes"] ;moves the turtle to the middle of a CeL patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "PKC" set shape "circle" set size 0.5 set color blue set CeL_turtle? "Yes" ] set counter counter + 1 ;increment counter ] set counter 0 ;reset counter let num_PKC_CeM ((1 - (%PKC_CEL + %PKC_CeC)) * ((1 - SST) * neurons)) ;calculates number of PKC turtles to be generated in CeM while [counter <= num_PKC_CeM] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeM? = "Yes"] ;moves the turtle to the middle of a CeM patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "PKC" set shape "circle" set size 0.5 set color blue set CeM_turtle? "Yes" ] set counter counter + 1 ;increment counter ] set counter 0 ;reset counter let num_SOM_CeC (%SST_CeC * (SST * neurons)) ;calculates number of SOM turtles to be generated in CeC (% taken from slider of interface) while [counter <= num_SOM_CeC] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeC? = "Yes"] ;moves the turtle to the middle of a CeC patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "SOM" set shape "circle" set size 0.5 set color red set CeC_turtle? "Yes" ] set counter counter + 1 ;increment counter ] set counter 0 ;reset counter let num_SOM_CeL (%SST_CeL * (SST * neurons)) ;calculates number of SOM turtles to be generated in CeL (% taken from slider of interface) while [counter <= num_SOM_CeL] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeL? = "Yes"] ;moves the turtle to the middle of a CeL patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "SOM" set shape "circle" set size 0.5 set color red set CeL_turtle? "Yes" ] set counter counter + 1 ;increment counter ] set counter 0 ;reset counter let num_SOM_CeM ((1 - (%SST_CeL + %SST_CeC)) * (SST * neurons)) ;calculates number of SOM turtles to be generated in CeM while [counter <= num_SOM_CeM] [ crt 1 ;creates a turtle at the origin [ move-to one-of patches with [InAmygdala? = "Yes" and InCeM? = "Yes"] ;moves the turtle to the middle of a CeM patch setxyz (xcor + (random-float(1) - 0.5)) (ycor + (random-float(1) - 0.5)) (zcor + (random-float(1) - 0.5)) ;modify coordinates so turtle is not in the center if the patch set Expression-Type "SOM" set shape "circle" set size 0.5 set color red set CeM_turtle? "Yes" ] set counter counter + 1 ;increment counter ] end to setup-turtles-SOM ;assigns each SOM neuron in the subject, a neural firing rate type (based on color) let d count turtles with [Expression-Type = "SOM"] ;assign local variable to the number of left SOM neurons let %e SST-regular ;assign local variable to a number from a slider determining the number of left SOM regular firing neurons in the subject as a decimal between 0 and 1 let %f SST-late ;assign local variable to a number from a slider determining the number of left SOM late firing neurons in the subject as a decimal between 0 and 1 ask n-of (%e * d) turtles with [Expression-Type = "SOM"] [ set Rate-Type "Regular" ] ask n-of (%f * d) turtles with [Expression-Type = "SOM" and Rate-Type != "Regular"] [ set Rate-Type "Late" ] ask turtles with [Expression-Type = "SOM" and Rate-Type != "Regular" and Rate-Type != "Late"] ;set the remaining neurons that haven't been assigned to spontaneous [ set Rate-Type "Spontaneous" ] end to setup-turtles-PKC ; same as the setup-turtles-SOM function, but with PKC neurons. See above. let g count turtles with [Expression-Type = "PKC"] ; left PKC neurons let %h PKC-regular ;is a slider determining the number of left PKC regular firing neurons in the subject as a decimal between 0 and 1 let %i PKC-late ;is a slider determining the number of left PKC late firing neurons in the subject as a decimal between 0 and 1 ask n-of (%h * g) turtles with [Expression-Type = "PKC"] [ set Rate-Type "Regular" ] ask n-of (%i * g) turtles with [Expression-Type = "PKC" and Rate-Type != "Regular"] [ set Rate-Type "Late" ] ask turtles with [Expression-Type = "PKC" and Rate-Type != "Regular" and Rate-Type != "Late"] [ set Rate-Type "Spontaneous" ] end ;procedure that creates the neural network to create-network ask turtles [ set Incoming-Connections-IDs (list) ; creates an empty list. This list tracks the IDs of the turtles that are sending signals to a turtle. set Outgoing-Connections-IDs (list) ; creates an empty list. This list tracks the IDs of the turtles that are receiving signals from a turtle. set Incoming-Connections 0 ;set the neuron's Incoming-Connections to 0 set Outgoing-Connections 0 ;set the neuron's Outgoing-Connections to 0 ] ;ask all SOM neurons to execute code below ask SOM-turtles [ let dummy2 0 ;local dummy variable that allows easy exit from while loop let SOM-turtle-ID [who] of self ;while the SOM neuron's outgoing connections are less than the max number of outgoing connections that a SOM neuron is allowed to make, AND the dummy variable is 0 while [Outgoing-Connections < Max-SST-Outputs and dummy2 = 0] [ ;find a neuron within a radius of (neighborhood selected on interface) of myself(the transmitting SOM neuron) that I(the asking neuron), has not connected to yet (not a member of the asking neuron's list). let b one-of (other turtles) with [distance turtle SOM-turtle-ID < SST_neighborhood and not member? self ([Outgoing-Connections-IDs] of turtle SOM-turtle-ID)] ;If a turtle exists that has met the criteria above, execute this code ifelse (b != Nobody) [ ask b [ set Incoming-Connections-IDs lput myself Incoming-Connections-IDs set Incoming-Connections Incoming-Connections + 1 ] set Outgoing-Connections-IDs lput b Outgoing-Connections-IDs set Outgoing-Connections Outgoing-Connections + 1 ;update the transmitting neuron's outgoing connections ] [set dummy2 1] ;there is no turtle that can be connected to. Move on to the next SOM turtle. ] ] ;ask all PKC neurons to execute code below ask PKC-turtles [ let dummy2 0 ;local dummy variable that allows easy exit from while loop let PKC-turtle-ID [who] of self ;while the PKC neuron's outgoing connections are less than the max number of outgoing connections that a PKC neuron is allowed to make, AND the dummy variable is 0 while [Outgoing-Connections < Max-PKC-Outputs and dummy2 = 0] [ ;find a neuron within a radius of (neighborhood selected on interface) of myself(the transmitting PKC neuron) that I(the asking neuron), has not connected to yet (not a member of the asking neuron's list). let b one-of (other turtles) with [distance turtle PKC-turtle-ID < PKC_neighborhood and not member? self ([Outgoing-Connections-IDs] of turtle PKC-turtle-ID)] ;If a turtle exists that has met the criteria above, execute this code ifelse (b != Nobody) [ ask b [ set Incoming-Connections-IDs lput myself Incoming-Connections-IDs set Incoming-Connections Incoming-Connections + 1 ] set Outgoing-Connections-IDs lput b Outgoing-Connections-IDs set Outgoing-Connections Outgoing-Connections + 1 ;update the transmitting neuron's outgoing connection ] [set dummy2 1] ;there is no turtle that can be connected to. Move on to the next PKC turtle. ] ] end to Calculate-Connection-%s ask turtles [ let j 0 set numToSOM 0 set numToPKC 0 ;let numSOMtoOTHER 0 while [j < Outgoing-Connections] [ ask item j Outgoing-Connections-IDs [ if Expression-Type = "SOM" [ask myself [set numToSOM numToSOM + 1]] if Expression-Type = "PKC" [ask myself [set numToPKC numToPKC + 1]] ;if Expression-Type = "Other" [set numSOMtoOTHER numSOMtoOTHER + 1] ] set j ( j + 1) ] ] set %-SOM-SOM-connections (sum [numToSOM] of SOM-turtles / (sum [Outgoing-Connections] of SOM-turtles)) set %-SOM-PKC-connections (sum [numToPKC] of SOM-turtles / (sum [Outgoing-Connections] of SOM-turtles)) ;set %-SOM-OTHER-connections (1 - (%-SOM-SOM-connections + %-SOM-PKC-connections)) set %-PKC-SOM-connections (sum [numToSOM] of PKC-turtles / (sum [Outgoing-Connections] of PKC-turtles)) set %-PKC-PKC-connections (sum [numToPKC] of PKC-turtles / (sum [Outgoing-Connections] of PKC-turtles)) ;set %-PKC-OTHER-connections (1 - (%-PKC-SOM-connections + %-PKC-PKC-connections)) end to Calculate-Mean-Connection-Distance ask turtles [ let k 0 set sumDistances 0 while [k < Outgoing-Connections] [ set sumDistances sumDistances + ([distance item k Outgoing-Connections-IDs] of self) set k ( k + 1) ] ] let sumDistancesToSOM sum [sumDistances] of SOM-turtles let sumDistancesToPKC sum [sumDistances] of PKC-turtles set mean-SOM-link-length ((sumDistancesToSOM) / (sum [Outgoing-Connections] of SOM-turtles)) set mean-PKC-link-length ((sumDistancesToPKC) / (sum [Outgoing-Connections] of PKC-turtles)) end ; END SUB-PROCEDURES FOR INITIALIZATION ------------------------------------------------------------------------------------------------------------------------------------- ; MODEL SIMULATION ---------------------------------------------------------------------------------------------------------------------------------------------------------- to go set Stimulated? file-read ; sets Stimulated? to a value between 0 and 220 found in the stimulation history file (current values in pA) if Stimulated? > 0 ; stimulation is happening [ set Stimulation-Time Stimulation-Time + 1 ;this tracks the total "time" measured in ticks that all the neurons have experienced stimulation. It is the same for all neurons but changes with time let c count SOM-turtles; added to deal with the runtime error of division by 0 when all left SOM neurons have been silenced if c > 0 [set Ratio-SOM (count SOM-Regular-turtles) / (count SOM-turtles)] ; keeps track of the ratio of SOM RS neurons to SOM neurons, might change depending on what is recruited from silent neurons *SEE ABOVE if c <= 0 [ set Ratio-SOM 0 ] ; ask turtles with [Expression-Type != "Other"] ask turtles [ if Stimulated? < 120 ; if less than the threshold (120) stimulation is on but not at the damage accumulation mark [ if Damage >= 100 [ set Damage 100 ; a necessary redundancy so all neurons stop accumulating damage no matter the pain state ] ] if Stimulated? >= 120 ; if greater than the threshold (120) stimulation is on and can accumulate damage [ if Damage >= 100 [ set Damage 100 ; Damage is a normalized so it only takes values between 0 and 100. In order words, this is a percentage whose max value is 100% ] if Damage < 100 and Stimulation-Time >= Damage-Latency ;damage is only accumulated if damage hasn't reach its maximum, pain is on, and the time experiencing Stimulation is greater than the latency ;the damage-latency is the threshold beyond which neurons begin to accumulate damage. Before this threshold, no damage is accumulated even while pain is on. this value remains constant while ;pain is off. This means that, as of now, there is no repair mechanism counter-acting damage accumulation [ set Damage Damage + (100 / Sensitivity) ;updates damage for each neuron based on their initially assigned sensitivity to stimulation if Damage >= 100 [ set Damage 100 ; Damage is a normalized so it only takes values between 0 and 100. In order words, this is a percentage whose max value is 100%, to fix going over 100% damage if Damage >= 100 ] ] ] let %e SST-regular if Ratio-SOM < (%e + 0.21) ; if all SOM neurons have not been silenced and the ratio of SOM RS neurons to SOM neurons in the left hemisphere is less than 0.48 (percentage of SOM RS neurons in the injured model), will add more of this type of neurons [ [ if (Expression-Type = "SOM" and Rate-Type = "Spontaneous" and Damage = 100) [ set Rate-Type "Regular" ] ] ] ] ; Update your SOM-Regular-Left-turtles, SOM-Regular-Right-turtles, SOM-Spontaneous-Left-turtles, SOM-Spontaneous-Right-turtles after recruitment of Spontaneous neurons to RS neurons set SOM-Regular-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Regular"] ;updating SOM RS neurons in the Left after recruitment set SOM-Spontaneous-turtles turtles with [Expression-Type = "SOM" and Rate-Type = "Spontaneous"] ;updating SOM Spont neurons in the Left after recruitment Assign-Firing-Rates ; assigns firing rates to each neuron using a linear combo of the control (damage = 0) and injured (damage = 100) data depending on the damage, procedure below ; ;************************************* This block of code can be edited to target specific neurons ; if ticks = 248 ; [ ; activate-posterior-SOM ; ] ; ;************************************* if Laser? = "On" [ ask turtles [ if (Activated_Laser? = True) [ set Firing-Rate 15 ] if (Inhibited_Laser? = True) [ set Firing-Rate 0 ] ] ] Update-Firing-Rates ; if the network is on, will use the links to re-update the firing rates, procedure below ;the following series of "set" statements are used in calculating various firing rate metrics which are used in the measure of pain set CR-SOM-regular sum [Firing-Rate] of SOM-Regular-turtles ; cumulative firing rates for SOM regular firing neurons in the subject (red) set CR-SOM-late sum [Firing-Rate] of SOM-Late-turtles ; cumulative firing rates for left SOM late firing neurons in the subject (pink) set CR-PKC-regular sum [Damage / 100 * Firing-Rate] of PKC-Regular-turtles ; cumulative firing rates for left PKC regular firing neurons in the subject (blue) set CR-PKC-late sum [Damage / 100 * Firing-Rate] of PKC-Late-turtles ; cumulative firing rates for left PKC late firing neurons in the subject (cyan) ; -------------------------------------------------------- ; the following "set statements are normalized calculations of the cumulated average damage for each type of neuron to observed the progression of the entire population to the completely sensitized (damaged) state ; let q count PKC-turtles with [Rate-Type != "Silent"]; added to deal with the runtime error of division by 0 when all left PKC neurons are silent ; if q > 0 ; [ ; set CD-PKC-regular ((sum [Damage] of PKC-Regular-turtles)/(count PKC-Regular-turtles)) ; cumulative damage for left PKC regular firing neurons in the subject (blue) ; set CD-PKC-late ((sum [Damage] of PKC-Late-turtles)/(count PKC-Late-turtles)) ; cumulative damage for left PKC late firing neurons in the subject (cyan) ; ] ; if q <= 0 ; [ ; set CD-PKC-regular 0 ; set CD-PKC-late 0 ; ] ; ; let r count SOM-turtles with [Rate-Type != "Silent"] ; added to deal with the runtime error of division by 0 when all left SOM neurons are silenced ; if r > 0 ; [ ; set CD-SOM-regular ((sum [Damage] of SOM-Regular-turtles)/(count SOM-Regular-turtles)) ; cumulative damage for SOM regular firing neurons in the subject (red) ; set CD-SOM-late ((sum [Damage] of SOM-Late-turtles)/(count SOM-Late-turtles)) ; cumulative damage for left SOM late firing neurons in the subject (pink) ; ] ; if r <= 0 ; [ ; set CD-SOM-regular 0 ; set CD-SOM-late 0 ; ] ; ------------------------------------------------------- set avgDamage ((sum [Damage] of turtles)/(count turtles)) ; the following "set statements are for the calculation of the pain output of the subject set CR-SOM (CR-SOM-regular + CR-SOM-late) ; cumulative firing rate for SOM neurons set CR-PKC (CR-PKC-regular + CR-PKC-late) ; cumulative firing rate for left PKC neurons set Pain (CR-PKC - CR-SOM) ; pain output of the left hemisphere ; ------------------------------------------------------- ; ifelse Neural-Network? ; if the network is on, will calculate the number of inhibited neurons, then reset it, first block ; [set TotInhibited count turtles with [Expression-Type != "Other" and Inhibited? = "Yes"] ;number of PKC and SOM inhibited turtels ; set SOMInhibited count turtles with [Expression-Type = "SOM" and Inhibited? = "Yes"] ;number of SOM inhibited turtles ; set PKCInhibited count turtles with [Expression-Type = "PKC" and Inhibited? = "Yes"] ;number of PKC inhibited turtles ; ask turtles with [Inhibited? = "Yes"] [set Inhibited? "No"] ] ; [] ; ------- OR ---------- ; if Neural-Network? ; [ set SOMInhibited 0 ; set PKCInhibited 0 ; ask turtles with [Inhibited? = "Yes"] ; [ ; ifelse Expression-Type = "SOM" ; [set SOMInhibited (SOMInhibited + 1)] ; [set PKCInhibited (PKCInhibited + 1)] ; set Inhibited? "No" ; ] ; set TotInhibited (SOMInhibited + PKCInhibited) ; ] ; ------------------------------------------------------- tick end ; END MODEL SIMULATION ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; SUB-PROCEDURES FOR SIMULATION (GO) -------------------------------------------------------------------------------------------------------------------------------------------------------------- ; the following "to-report" function is the primary method for defining the behavior of each neuron. It is a bounded, normal distribution whose average, standard deviation, min and max are all ; calibrated from the laboratory data, used in the Assign-Firing-Rates procedure to-report random-normal-in-bounds [mn dev mmin mmax] ;this is the main command for the bounded normal distribution let result random-normal mn dev if result < mmin ; if the result is less than the min, will assign the min firing rate to that neuron to more accurately reflect the laboratory data [set result mmin] if result > mmax ; if the result is more than the max, will assign the max firing rate to that neuron ..... (see above) [set result mmax] report result ;the "result" generated is a number that represents the firing rate of a neuron at that moment. Calling the function again yields another firing rate as if its has changed through time end ;the following function "Assign-Firing-Rates" describes the behavior of all the firing neurons depending on whether stimulation is happening and their current damage level to Assign-Firing-Rates; assigns the firing rates of firing neurons depending on damage, using the control or unsensitized distribution (x) and the injured or sensitized distribution (y) ; in this equation, (((100 - Damage) / 100) * x) + ((Damage / 100) * y), still depends on current let %r 4.887 ; lab data, known firing rate of SST spontaneous let %s 2.833 ; lab data, known firing rate of PKC spontaneous ask SOM-Spontaneous-turtles [set Firing-Rate %r] ask PKC-Spontaneous-turtles [set Firing-Rate %s] ask SOM-Regular-turtles [ ifelse Stimulated? >= 100 and Stimulated? < 120 ; if stim >= 100 true execute this first block (1) ; current is from 100 (inclusive) to 120 (exclusive) [ let x random-normal-in-bounds 8.0769 4.9068 1 17 let y random-normal-in-bounds 5.15 6.1239 0 19 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2) ifelse Stimulated? >= 120 and Stimulated? < 140 ; if 120 <= stim < 400 true execute this first block (2-1) [ let x random-normal-in-bounds 11.2308 5.5551 2 22 let y random-normal-in-bounds 7 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2-2) ifelse Stimulated? >= 140 and Stimulated? < 160 ; if 140 <= stim < 160 true execute this first block (2-2-1) [ let x random-normal-in-bounds 13 4.6726 4 23 let y random-normal-in-bounds 8.51 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2-2-2) ifelse Stimulated? >= 160 and Stimulated? < 180 ; if 160 <= stim < 180 execute this first block (2-2-2-1) [ let x random-normal-in-bounds 14.3077 4.9897 5 28 let y random-normal-in-bounds 10.16 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2-2-2-2) ifelse Stimulated? >= 180 and Stimulated? < 200 ; if 180 <= stim < 200 true execute this first block (2-2-2-2-1) [ let x random-normal-in-bounds 15.9231 6.1028 6 30 let y random-normal-in-bounds 11.81 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2-2-2-2-2) ifelse Stimulated? >= 200 and Stimulated? < 220 ; if 200 <= stim < 220 true execute this first block (2-2-2-2-2-1) [ let x random-normal-in-bounds 16.7692 6.2471 7 30 let y random-normal-in-bounds 13.46 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ ; otherwise move to this second block (2-2-2-2-2-2) ifelse Stimulated? >= 220 and Stimulated? < 240 ; if 220 <= stim < 240 true execute this first block (2-2-2-2-2-2-1) [ let x random-normal-in-bounds 17.1538 5.97 8 31 let y random-normal-in-bounds 15.11 7.0038 0 21 set Firing-Rate (((100 - Damage) / 100) * x) + ((Damage / 100) * y) ] [ show "stimulation error SOM-Regular-turtles" ] ; otherwise show error message (2-2-2-2-2-2-2) ] ; close ifelse 6 ] ; close ifelse 5 ] ; close ifelse 4 ] ; close ifelse 3 ] ; close ifelse 2 ] ; close ifelse 1 ] ;close ask ask SOM-Late-turtles [ ifelse Stimulated? >= 100 and Stimulated? < 120 [ let z random-normal-in-bounds 0.375 1.0607 0 3 set Firing-Rate (((100 - Damage) / 100) * z) ] [ ifelse Stimulated? >= 120 and Stimulated? < 140 [ let z random-normal-in-bounds 1 2.4495 0 7 let v random-normal-in-bounds 0.1429 0.378 0 1 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ ifelse Stimulated? >= 140 and Stimulated? < 160 [ let z random-normal-in-bounds 1.5 3.2071 0 9 let v random-normal-in-bounds 0.4286 1.1339 0 3 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ ifelse Stimulated? >= 160 and Stimulated? < 180 [ let z random-normal-in-bounds 2.5 4 0 11 let v random-normal-in-bounds 1.1429 2.2678 0 6 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ ifelse Stimulated? >= 180 and Stimulated? < 200 [ let z random-normal-in-bounds 3.25 4.7734 0 13 let v random-normal-in-bounds 1.8571 2.9114 0 8 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ ifelse Stimulated? >= 200 and Stimulated? < 220 [ let z random-normal-in-bounds 4.5 5.6315 0 15 let v random-normal-in-bounds 3.1429 3.9761 0 11 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ ifelse Stimulated? >= 220 and Stimulated? < 240 [ let z random-normal-in-bounds 5.625 5.7554 0 16 let v random-normal-in-bounds 4.4286 4.237 0 12 set Firing-Rate (((100 - Damage) / 100) * z) + ((Damage / 100) * v) ] [ show "stimulation error SOM-Late-turtles"] ] ] ] ] ] ] ] ask PKC-Regular-turtles [ ifelse Stimulated? >= 100 and Stimulated? < 120 [ let n random-normal-in-bounds 3.9167 4.0169 0 13 let m random-normal-in-bounds 5.3889 4.6291 0 15 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 120 and Stimulated? < 140 [ let n random-normal-in-bounds 5.5833 4.5127 0 14 let m random-normal-in-bounds 7.6111 4.6544 1 17 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 140 and Stimulated? < 160 [ let n random-normal-in-bounds 7.1389 4.9289 0 15 let m random-normal-in-bounds 9.6111 4.6417 2 19 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 160 and Stimulated? < 180 [ let n random-normal-in-bounds 8.75 5.1513 1 16 let m random-normal-in-bounds 10.571 4.6417 2 19 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 180 and Stimulated? < 200 [ let n random-normal-in-bounds 10.0833 5.261 1 18 let m random-normal-in-bounds 12.18 4.6417 2 19 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 200 and Stimulated? < 220 [ let n random-normal-in-bounds 11.4444 5.2777 2 20 let m random-normal-in-bounds 13.789 4.6417 2 19 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [ ifelse Stimulated? >= 220 and Stimulated? < 240 [ let n random-normal-in-bounds 12.6389 5.3353 3 21 let m random-normal-in-bounds 15.398 4.6417 2 19 set Firing-Rate (((100 - Damage) / 100) * n) + ((Damage / 100) * m) ] [show "stimulation error PKC-Regular-turtles"] ] ] ] ] ] ] ] ask PKC-Late-turtles [ ifelse Stimulated? >= 100 and Stimulated? < 120 [ let b random-normal-in-bounds 0.25 0.6216 0 2 set Firing-Rate ((Damage / 100) * b) ] [ ifelse Stimulated? >= 120 and Stimulated? < 140 [ let b random-normal-in-bounds 0.9167 1.505 0 5 set Firing-Rate ((Damage / 100) * b) ] [ ifelse Stimulated? >= 140 and Stimulated? < 160 [ let a random-normal-in-bounds 0.1111 0.3234 0 1 let b random-normal-in-bounds 2 2.0889 0 7 set Firing-Rate (((100 - Damage) / 100) * a) + ((Damage / 100) * b) ] [ ifelse Stimulated? >= 160 and Stimulated? < 180 [ let a random-normal-in-bounds 0.3889 0.6978 0 2 let b random-normal-in-bounds 3 2.5226 0 8 set Firing-Rate (((100 - Damage) / 100) * a) + ((Damage / 100) * b) ] [ ifelse Stimulated? >= 180 and Stimulated? < 200 [ let a random-normal-in-bounds 0.8889 1.1827 0 3 let b random-normal-in-bounds 4.25 2.958 1 10 set Firing-Rate (((100 - Damage) / 100) * a) + ((Damage / 100) * b) ] [ ifelse Stimulated? >= 200 and Stimulated? < 220 [ let a random-normal-in-bounds 1.3889 1.4608 0 4 let b random-normal-in-bounds 5.3333 2.9336 2 11 set Firing-Rate (((100 - Damage) / 100) * a) + ((Damage / 100) * b) ] [ ifelse Stimulated? >= 220 and Stimulated? < 240 [ let a random-normal-in-bounds 2.1667 1.9778 0 6 let b random-normal-in-bounds 6.75 3.1659 3 13 set Firing-Rate (((100 - Damage) / 100) * a) + ((Damage / 100) * b) ] [show "stimulation error PKC-Late-turtles"] ] ] ] ] ] ] ] ask SOM-turtles with [Inhibited_Laser? != True] [set color red] ask PKC-turtles with [Inhibited_Laser? != True] [set color blue] end to Update-Firing-Rates if Neural-Network? ; if the network is on, will use connections to reupdate the firing rates [ ask turtles [ let suminputFRs 0 let i 0 while [i < Incoming-Connections] [ set suminputFRs ( suminputFRs + [Firing-Rate] of (item i Incoming-Connections-IDs)) set i ( i + 1 ) ] if suminputFRs >= Inhibition-Threshold [ set Firing-Rate 0 set Inhibited? "Yes" ifelse Inhibited_Laser? = True [set color black] ; if inhibited by laser turn black [set color yellow] ; if inhibited by other neurons turn yellow ] ] ] end ; END SUB-PROCEDURES FOR MODEL INITIALIZATION-------------------------------------------------------------------------------------------------------------------------------------------------- ; VISUALIZATION ON INTERFACE ------------------------------------------------------------------------------------------------------------------------------------------------------------------ ;procedure that will highlight the z-axis when button pressed on interface to create-z-axis let index 0 ;initializes loop counter loop [ ;begins loop ask patch 0 0 index ;ask each patch along z-axis, [ set pcolor orange ;turn orange ] if (index = 60) ;stopping condition [ stop ] set index (index + 1) ;increment counter ] end ;procedure that will highlight the x-axis when button pressed on interface to create-x-axis let index 0 ;initializes loop counter loop [ ;begin loop ask patch index 0 0 ;ask each patch along x-axis, [ set pcolor yellow ;turn yellow ] if (index = 75) ;stopping condition [ stop ] set index (index + 1) ;increment counter ] end ;procedure that will highlight the y-axis when button pressed on interface to create-y-axis let index 0 ;initializes loop counter loop [ ;begin loop ask patch 0 index 0 ;ask each patch along y-axis, [ set pcolor 95 ;turn this shade of blue ] if (index = 60) ;stopping condition [ stop ] set index (index + 1) ;increment counter ] end to create-slice_1-6 let s Slices_1-6 ask patches with [Bregma = s][set pcolor yellow] end to show-dis-from-bregma let s Distance_From_Bregma ask patches with [Bregma = s][set pcolor white] end ; END VISUALIZATION ON INTERFACE --------------------------------------------------------------------------------------------------------------------------------------------- ; PROECURES FOR TARGETED ACTIVATION/INHIBTION -------------------------------------------------------------------------------------------------------------------------------- ;the following procedures sets the laser variable of each neuron with the designated x-vals to true to activate-anterior-PKC ask PKC-turtles with [[pxcor] of patch-here <= 25] [ set Activated_Laser? True ] end to activate-posterior-PKC ask PKC-turtles with [[pxcor] of patch-here >= 48] [ set Activated_Laser? True ] end to inhibit-anterior-PKC ask PKC-turtles with [[pxcor] of patch-here <= 25] [ set Inhibited_Laser? True set color black ] end to inhibit-posterior-PKC ask PKC-turtles with [[pxcor] of patch-here >= 48] [ set Inhibited_Laser? True set color black ] end to activate-anterior-SOM ask SOM-turtles with [[pxcor] of patch-here <= 25] [ set Activated_Laser? True ] end to activate-posterior-SOM ask SOM-turtles with [[pxcor] of patch-here >= 48] [ set Activated_Laser? True ] end to inhibit-anterior-SOM ask SOM-turtles with [[pxcor] of patch-here <= 25] [ set Inhibited_Laser? True set color black ] end to inhibit-posterior-SOM ask SOM-turtles with [[pxcor] of patch-here >= 48] [ set Inhibited_Laser? True set color black ] end ; END PROCEDURES FOR TARGETED ACTIVATION/INHIBTION ---------------------------------------------------------------------------------------------------------------------------

There is only one version of this model, created 7 months ago by Abraham Nofal.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Central Amygala: Noiceceptive output model.png | preview | Preview for 'Central Amygala: Noiceceptive output model' | 7 months ago, by Abraham Nofal | Download |

This model does not have any ancestors.

This model does not have any descendants.