C. Elegans Motion

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0-RC4 • Viewed 246 times • Downloaded 13 times • Run 0 times
Download the 'C. Elegans Motion' modelDownload this modelEmbed this model

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


WHAT IS IT?

This model intends to reproduce the locomotive and social behavior of c. elegans, a roundworm species often used in biology and neuroscience experiments. At present, several "interaction" mechanisms have been started, but none are working as desires. Extensive work to date has focused on reproducing a somewhat representative slithering pattern, enforcing a 2-D constraint that worms cannot occupy the same space, and incorporating reversal/stopping mechanisms. An example video of c. elegans motion can be seen below:

https://www.youtube.com/watch?v=GgZHziFWR7M

HOW IT WORKS

Setup:
    1. All patches are turned white.  These are effectively "inert" petri dish that serve as the background.
    2. If the "chase-food" mode is on, a fraction of the patches are seeded with food in the form of red dots.
    3. A fraction of the patches sprout a "leader" turtle
    4. The leader turtles grow worms by serving as the focal point for sequential addition of directed links to "follower" worm segments. 


Go: At each tick:

A. In chase-food mode, each patch with food does:
If a worm is here, I disappear and re-sprout elsewhere.

B. In attractive/repulsive signaling mode, each patch diffuses/evaporates chemical and updates its shade of green accordingly. The center-segment of each worm drops a finite packet of chemical onto its current patch.


Each leader does:
    1. I decide upon a heading for the whole worm. (see SET WORM HEADING below)
    2. If I am in stationary or reverse modes, I stay still or follow the segment to which I am linked. Otherwise, I continue:
    3. I set my individual heading by super-imposing a sinusoid onto the worm heading.  The period and amplitude of the wave are set by the user, with noise added by a Gaussian.
    4. I check that my current heading is feasible, and if it is not, I adjust it.  At this stage I consider switching to stationary and/or reverse modes (see CHECK/ADJUST HEADING below)
    5. I take a step forward


Each follower does:
    1. If I am in forward mode, I face the turtle from which I receive a link (i.e. the worm section in front of me). I step forward. If not in forward mode, I continue:
    2. If I am in stationary mode, I stop and increment my stationary countdown.
    3. If I am in reverse mode, I face directly opposite my overall worm heading, with a sinusoid superimposed upon my heading. 
    4. I check that my current heading is feasible (i.e. not facing a wall or another turtle). If not, I switch to stationary mode. If it is, I step forward.


SET WORM HEADING:

Several modes are available:

    chase-food : I set the worm-heading toward the nearest food source. 

    attractive-signaling : I set the worm heading to the highest chemical concentration in my cone of vision (distance+angle variable).

    repulsive-signaling : I set the worm heading to the lowest chemical concentration in my cone of vision (distance+angle variable).

    random-heading: At each tick there is a random chance that I change the worm heading to a random direction.


CHECK/ADJUST HEADING:

    1. I increment my "directions-checked" counter
    2. If my directions-checked counter surpasses a threshold, I switch to reverse mode.
    3. I check that I am not facing a wall or another turtle. If I am not, I step forward. If I am, I adjust my heading in the direction of my worm-segment's current concavity and return to step 1.

HOW TO USE IT

Set the number of worms, worm length, worm oscillation period, and worm turning amplitude using sliders on the interface.

The "mode" is set by a drop-down menu.

THINGS TO NOTICE

At present:
1. In chase-food mode, the worms all converge toward a single cluster. Over time, they begin chasing the same "nearest" food particles.
2. In random-heading mode, the worms eventually get stuck in the corners. I suspect this is because, when in a corner, if a heading is randomly selected from a 360 degree distribution there is only a 25% chance that it will get them out of the corner.  Even if that chance arises, they have to do it without running into themselves or a wall before the heading changes again.
3. The two signaling modes aren't yet working as planned.  In the attractive mode, worms get stuck trying to chase their own signal and curl up into a ball. Perhaps they must be forced to avoid their own signal.
4. The "repulsive-signaling" mode works a little bit better, but the frequent changes in heading tend to override the sinusoidal pattern, which detracts from the model as the qualitative "slithering" of the worms is lost.

EXTENDING THE MODEL

Planned future work:

  1. Add distributions of worm length
  2. Add metrics (linear velocity distribution)
  3. Improve chemical interaction mechanism, i.e. stop worms from following own signal.
  4. Add age distribution (and its impact on speed, responsiveness, vision)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [leaders leader]
breed [followers follower]
turtles-own [worm-number worm-position worm-heading reverse-counter stay-still]
leaders-own [direction-headed directions-checked obstacles]
patches-own [chemical-signal]
globals [average-leader-separation worm-number-in-reverse current-worm]

to setup
  clear-all
  
  ;;Set worm shapes
  set-default-shape leaders "head-2" ; "circle" 
  set-default-shape followers "worm-segment-2"
  
  ;;Initialize petri dish (background)
  ask patches [set pcolor white]  
  
  ;;Create worms by sprouting "leaders" on random patches
  ask n-of number-worms patches with [pcolor = white] 
  [sprout-leaders 1 [
    (set color black)
    (set size worm-display-thickness)
    (set worm-position 1)
    (set worm-heading heading)
    (set reverse-counter 0)]]
  
  ;;Append followers to grow worm, and assign worm number
  ask leaders [ 
    set worm-number who
    grow-worms 2 worm-number ]  
  
  
  
  
  if operating-mode = "chase-food" [
  ;Add "food" to plate for testing
  ask n-of food-added patches [set pcolor red]]
  
  
  reset-ticks  
end 

to grow-worms [counter leader-who]
;;Function generates worm bodies by sequentially adding segments to a leader.

hatch-followers 1 
  [
  set worm-number leader-who
  set worm-position counter  
  ifelse worm-position = 2 [bk 2] [bk 1]
  set size worm-display-thickness
  set color black
  create-link-to myself

  set counter (counter + 1)
  if counter < worm-length [grow-worms counter worm-number] ;;Re-iterate worm growth
  ]
end 

to go
;;GO code to run simulation
  
  calculate-metrics
  
  
  ask leaders [set-worm-heading]   ;;Set overall worm objectives
  ask leaders [lead]      ;;Execute leader motion
  ask followers [slither] ;;Execute segment motion
  
  
  ;;Runs chemical signaling
  ask followers with [worm-position = ceiling (worm-length / 2)] ;Ask worm mid-sections to drop chemical
    [ask patch-here [set chemical-signal chemical-signal + 200]] 
  diffuse chemical-signal (diffusion-rate / 100)  ;;Diffuse chemical signal. 
  ask patches [ set chemical-signal chemical-signal * (100 - evaporation-rate) / 100]  ;;  Evaporate chemical signal


  ;;If show-drivers is off, don't visualize signaling.
  if not show-drivers? 
    [ask patches with [pcolor != red] [set pcolor white]]
  
  update-patches
  tick
end 

to set-worm-heading
  ;;Leader function: I set the overall worm's destination, depending upon the current operating mode.
  
  if operating-mode = "chase-food"
    [face min-one-of patches with [pcolor = red] [distance myself]
     set worm-heading heading]
  
  if operating-mode = "attractive-signaling"
    [carefully
        [face max-one-of neighbors in-cone 10 25 [chemical-signal]
        set worm-heading heading]
        []]  
    
  if operating-mode = "repulsive-signaling"
     [face min-one-of neighbors [chemical-signal]
      set worm-heading heading]
  
  if operating-mode = "random-heading"
    [if (random-float 100) < heading-change-probability
       [set heading random 360
        set worm-heading heading]]    
end 

to lead

  ;;Executes forward or reverse mode
  ifelse reverse-counter > 0 
  
    ;;Reverse mode
    [set reverse-counter (reverse-counter - 1)
     face one-of in-link-neighbors]
  
    ;;Forward mode
    
    
    
    [let turn-radius random-normal slither-amplitude 5
     set heading ((cos ( ticks / oscillation-period * 360 ) * turn-radius) + worm-heading ) ;;Set individual leader heading
     set directions-checked 0
     avoid-collisions]  ;;I check to see if heading will collide with a wall or turtle, and adjust if so
  
  
  ;;I step forward
  ifelse stay-still = 0
    [fd worm-speed]
    []
end 

to avoid-collisions
  
  ;;If I've checked more than 4 directions, switch to reverse slither.
  ifelse directions-checked > 4 
  
    [set worm-number-in-reverse who
     ask turtles with [worm-number = worm-number-in-reverse] 
       [set reverse-counter reversal-duration]]
  
    [set directions-checked (directions-checked + 1)
      ifelse patch-ahead 1 = nobody 
        [adjust-heading]
        [if (any? turtles-on patch-ahead minimum-proximity)  
          [adjust-heading]]]
end 

to adjust-heading
    
    ;;Changes heading in direction of local worm curvature, then re-iterates "checking" procedure.
    
    ifelse  (subtract-headings heading worm-heading) > 0
    [set heading (heading + heading-adjustment)]
    [set heading (heading - heading-adjustment)]
  
    avoid-collisions
end 

to slither
  
  ;;FORWARD SLITHER MODE
    
  ;;Each followers follows its local leader
  face one-of out-link-neighbors
  
  
  ;;REVERSE SLITHER MODE
  
  if reverse-counter > 0
  [ ifelse not any? in-link-neighbors 
      ;;If I am the back end of the worm, set direction in reverse by following opposite sinusoid
      [set heading ((cos ( ticks / oscillation-period * 360 ) * slither-amplitude) + worm-heading ) + 180 
      avoid-collisions-reverse]
       
      ;;If I am a worm segment, I follow the segment behind me
      [face one-of in-link-neighbors] 
      set reverse-counter (reverse-counter - 1)]
  
  
  ;;BOTH MODES - TAKE STEP 

  ifelse stay-still = 0
    [fd worm-speed]
    []
end 

to avoid-collisions-reverse
  
  ;;If there is no patch ahead of me, or it is occupied by turtles, I stop moving in reverse
  ifelse patch-ahead 1 = nobody 
    [set stay-still 1] 
    [ifelse (any? turtles-on patch-ahead minimum-proximity) 
      [set stay-still 1]
      [set stay-still 0]]

  ifelse stay-still = 1 and reverse-counter > 1 
    [set current-worm worm-number
    ask turtles with [worm-number = current-worm] [set stay-still 1]]
    [set current-worm worm-number
    ask turtles with [worm-number = current-worm] [set stay-still 0]]
end 

to update-patches

     if operating-mode = "chase-food" [
       ;;Reassign eaten food to random other location
       ask patches with [pcolor = red] [
         if (count turtles-here) > 0 [ 
           set pcolor white  
           ask one-of other patches [set pcolor red]]]]

     if operating-mode = "attractive-signaling" or operating-mode = "repulsive-signaling" [ 
       ;;Recolors patches according to chemical signal concentration
       ask patches with [pcolor != red] [ set pcolor scale-color green chemical-signal 100 0 ]]
end 

to calculate-metrics
;;Store velocity, position, orientation distributions

;;TO BE DETERMINED



;;Average minimum distance between leaders
if count leaders > 1 [
  let total-distance 0
  ask leaders [
    set total-distance (total-distance + distance ( min-one-of other leaders [distance myself])) ];   
  set average-leader-separation (total-distance / ( count leaders ))]
end 









There are 2 versions of this model.

Uploaded by When Description Download
Sebastian Bernasek almost 9 years ago Signaling modes, enforced 2D Download this version
Sebastian Bernasek almost 9 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.