Scripting

Intermediate

Breaking up days with EOD

Usually, we want to break up our long running experiments into days, to make it easier to handle the extremely large amount of data that is collected. Our processing tools generally work with one 'day' (or more accurately, one camera-day) of data at a time.

Breaking up the experiment with EODs also has the benefit of telling the chamber that the previous day is ready to begin processing: with the right modules installed and a compatable VisualPhenomics5+, the data will begin being analyized as soon as the EOD triggers.

Starting comment

Just like before, we start out by giving our script a comment describing what it's for. Don't think we forgot!

/**
 * Intermediate Scripting 1 - EOD
 *
 * Demonstrates the usage of EOD statements and day seperation within a script
 *   to break up output directories and make the files easier to manage.
 *
 * made: 2017-03-17
 * by:   William A. Norman
 */

Get a protocol

To see the results of EOD (without digging through the log), we're going to need to capture some images. Lets declare a really simple protocol:

// Takes a single image with red lights.
var protocol = new CameraProtocol("example_protocol")
    protocol.setAnalysisID       ("example")
    protocol.setNumberLoops      ( 1 )
    protocol.setFramesPerLoop    ([ 1 ])
    protocol.setMeasuringLight   ([ 1 ])
    protocol.setSaturationFlash  ([ 0 ])
    protocol.setExposure         ([ "50us" ])
    protocol.setFrameInterval    ([ "70ms" ])

Set starting conditions

Remember how the chamber keeps its last setting after a script ends? It's good practice to zero out everything when a script terminates, but we shouldn't assume the previous user did so. So, we should set the starting conditions at the beginning of our script.

// Set starting conditions
set_intensity(0)

Folder output before EOD

Go ahead and add run_camera_protocol(protocol) to your script (temporarily, don't forget to remove it once we're done!). Now run the script, and the output folder should look like this:

  • root
    • Timeline.xml
    • cam_0
      • day_-1
    • cam_1
      • day_-1
    • cam_2
      • day_-1

If you don't declare otherwise, the system starts out on day -1, which is why all our images are inside folders named day_-1.

Don't forget to remove that line before you continue!

Adding EOD

Okay, lets break up this script into 3 days, each with a single image set.

// Main day loop
wait("5s")

EOD(1)
run_camera_protocol(protocol)

wait("5s")

EOD(2)
run_camera_protocol(protocol)

wait("5s")

// Putting in '+' increments the day by 1. Here, it has the same effect as
//   typing EOD(3).
EOD('+') 
run_camera_protocol(protocol)

Now take a look at your output directory. The structure should look something like this:

  • root
    • Timeline.xml
    • cam_0
      • day_1
      • day_2
      • day_3
    • cam_1
      • day_1
      • day_2
      • day_3
    • cam_2
      • day_1
      • day_2
      • day_3

And each day_# folder will have exactly one image: the one from run_camera_protocol(protocol), after the EOD(#) specifying that number.

Putting it together

Okay, so put together your script should look like this:

/**
 * Intermediate Scripting 1 - EOD
 *
 * Demonstrates the usage of EOD statements and day seperation within a script
 *   to break up output directories and make the files easier to manage.
 *
 * made: 2017-03-17
 * by:   William A. Norman
 */

// Takes a single image with red lights.
var protocol = new CameraProtocol("example_protocol")
    protocol.setAnalysisID       ("example")
    protocol.setNumberLoops      ( 1 )
    protocol.setFramesPerLoop    ([ 1 ])
    protocol.setMeasuringLight   ([ 1 ])
    protocol.setSaturationFlash  ([ 0 ])
    protocol.setExposure         ([ "50us" ])
    protocol.setFrameInterval    ([ "70ms" ])

// Set starting conditions
set_intensity(0)

// Main day loop
wait("5s")

EOD(1)
run_camera_protocol(protocol)

wait("5s")

EOD(2)
run_camera_protocol(protocol)

wait("5s")

// Putting in '+' increments the day by 1. Here, it has the same effect as
//   typing EOD(3).
EOD('+') 
run_camera_protocol(protocol)