Monday, December 22, 2014

5 Months, Secondary Root Growth, and Things Moving Up

Compiled video for the last five months (see below). Brief notes of interest:

1. Secondary Root Growth. Around Sept. 21st there is a burst of root growth extending out from many of the existing roots. This lasts for about two weeks before settling down. Nearly all of the easily visible roots exhibit the same behavior at the same time. Neat! I'm assuming they are all coming from the same plant. What changed took place that enabled this process to happen? Temperature, sunlight change, moisture?

2. Underground Plant Growth. Plants generally start their life below ground, running their roots/radicles down, and their shoots/hypocotyl towards the sky. It's strange for me to see the upward growth below ground. At the 43s mark of this video you can see this happening. That behavior isn't abnormal, but it's growth I'm normally used to seeing only when a plant emerges above the earth. I mistakenly assume everything below ground is a root : )

43 seconds in the linked video puts us at late October with the growth continuing through November. With an average temperature of 34°F / 1°C, I have a hard time believing whatever sprouts above ground will survive long?

If this setup continues to survive, what other growth will we see as the temperature stays below freezing? It's about time I started measuring the soil temp!

~5 Months played back at ~10 seconds/month. 
See below for playback of 1 second/month.

~5 Months played back at ~1 second/month.  

Sunday, December 14, 2014

After These Messages

Spent the past two months out of the country. Automation was only partially functioning. In short, images from the scanner were not automatically offloading to a remote server, so I had to SSH in from Cambodia, Thailand, and New Zealand every few days to do this manually. A few days of data was lost, but beyond silly user error problems the setup has continued to function. The past week has seen an average temperature below freezing. Neat! Hoping to recompile some new timelapse videos over the next week. Will update soon.

Sunday, September 21, 2014

10 Weeks in 10 Seconds

The project has been running for approximately ten weeks. Geologists probably know this better than almost anyone: Ten weeks is a terribly short period. I think if this project lasts a year I will find myself only partially satisfied. Seeing things change (roots grow, leaves decompose, roots get eaten, water saturating the soil in a storm, etc.) is fascinating, but I still have no idea what the changes in seasons or significant temperature change will have on the appearance of the soil. Things to look forward to : )

Wednesday, September 17, 2014

Video / Automation Fun

The latest work on this project has been focused on automation and the last few posts have been a result of that. The next few days should see two posts each day of two slightly different views. Eventually that should change to two or three posts a week showing a compiled video of the past 7 days of footage. In the long run I would love to include some basic automated analysis: level of activity/change in images, brightness, changes in color, temperature & moisture. So far all of this is being done on a Raspberry Pi.

For the moment the automated steps are:
  1. Take the scan (scanimage)
  2. Modify images as needed (cropping, resizing, timestamping via imagemagick)
  3. Consolidate the original images (tar)
  4. Compile the current day's images into a video (mp4 via avconv)
  5. Combine the current day of video with all previous days of video (avconv)
  6. Upload the resulting video to youtube and make a blog post (googlecl)
So far I've written 7 or 8 short bash scripts that I compile into two separate scripts. If you've stumbled across this, please don't use any of this with any expectation that it's "the right way". Suggestions/advice are very, very welcome : )

The first three steps from above run every 15 minutes
#start a 300 dpi scan, convert it to a jpg and flip it vertically
#start scan
sudo /usr/bin/scanimage -l 0mm -t 0mm -x 215mm -y 297mm --format tiff --resolution 300 | sudo /usr/bin/convert - -flip /var/www/tmp/sc_$(date -d "today" +"%Y%m%dT%H%M%S").jpg 
#put files in /var/www/tmp
cd /var/www/tmp/ 
#loop through jpgs in directory
for file in *.jpg; do 
#save cropped version
convert -crop 1920x1080+310+285 $file zleaf_$file; 
#grab date and time from file name
#set appropriate width
width=$(identify -format %W zleaf_${file})
width=$((${width} * 2 / 10 )) 
#apply time stamp to image
convert                  \
     -background '#0008'    \
     -gravity center        \
     -fill white            \
     -size ${width}x50     \
      caption:"${ndate} ${ntime}"      \
      zleaf_"${file}"              \
     +swap                  \
     -gravity south         \
     -composite             \
#cleanup / move files to appropriate directories.
mv b$file /var/www/testcaption
if [ -f /var/www/300/300_$tdate.tar ]
tar -rvf /var/www/300/300_$tdate.tar $file
tar -cvf /var/www/300/300_$tdate.tar $file
if [ -f /var/www/300Zoom/300Zoom_$tdate.tar ]
                tar -rvf /var/www/300Zoom/300Zoom_$tdate.tar zleaf_$file
                tar -cvf /var/www/300Zoom/300Zoom_$tdate.tar zleaf_$file
sudo rm *.jpg
The last three steps run a few minutes after midnight
prev=$(date -d "yesterday" +"%Y%m%d")
echo $version >> $testdir/$prev.txt  
echo "begin rename $(date)" >> $testdir/$prev.txt
x=1; for i in b*.jpg; do counter=$(printf %04d $x); mv "$i" ${prev}-"$counter".jpg; x=$(($x+1)); done
echo "end rename: $(date)" >> $testdir/$prev.txt

echo "begin encode $(date)" >> $testdir/$prev.txt
ffmpeg -r 30 -i ${prev}-%04d.jpg -r 30  -vcodec libx264 -crf 20 -g 15 $prev.mp4
echo "end encode $(date)" >> $testdir/$prev.txt

#twodago=$(date -d "2 days ago" +"%Y%m%d")
onedago=$(date -d "yesterday" +"%Y%m%d")
echo "begin combine $(date)" >> $testdir/$onedago.txt
avconv -y -i $ongoing.mp4 -f mpegts -c copy -bsf:v h264_mp4toannexb $ongoing.mpeg.ts
avconv -y -i $onedago.mp4 -f mpegts -c copy -bsf:v h264_mp4toannexb $onedago.mpeg.ts
avconv -y -isync -i "concat:"$ongoing".mpeg.ts|"$onedago".mpeg.ts" -c copy $ongoing.mp4
echo "end combine $(date)" >> $testdir/$onedago.txt

echo "begin youtube upload $(date)" >> $testdir/$prev.txt
google youtube post --category Tech current.mp4 &> upload.txt
movie=$(grep -o -P '(?<==).*(?=&)' upload.txt)
google blogger post --title "Video Upload: $prev" --src "<iframe width=\"560\" height=\"315\" src=\"//$movie\" frameborder=\"0\" allowfullscreen></iframe>"
echo "end youtube upload $(date)" >> $testdir/$prev.txt 
echo "begin cleanup $(date)" >> $testdir/$prev.txt
sudo rm *.jpg
mv ${prev}*.* $testdir/prevdata/
echo "end cleanup $(date)" >> $testdir/prevdata/$prev.txt 
echo "begin notify $(date)" >> $testdir/prevdata/$prev.txt
cat $testdir/prevdata/$prev.txt | mail -s "Video upload "$prev""
echo "end notify $(date)" >> $testdir/prevdata/$prev.txt

Monday, September 8, 2014

Tech Summary

I think I have all the basic software and hardware components in place and functioning. The process is not as streamlined as I would like it to be and there's a million more things to resolve. That being said enough is in place that I can call this a functional setup : )

A Raspberry Pi with a Powered Plugable USB Hub connected to a WiFi Dongle and a USB Extension cable all sit above ground and inside.

The USB Extension cable runs outside through a small hole in a wall and connects to a buried Canon Lide 20 Scanner. Both data & power run over USB. This is convenient and less scary (to me) than connecting a 120v higher amperage scanner to the outside world. Also, not all scanners work when oriented vertically!

The scanner has been waterproofed (so far) via an application of neutral curing acid-free silicone and a thick plastic bag. The scanner sits vertically with the top a couple cm below the earth's surface and the bottom approx. 30cm below.

a) The Pi runs Raspbian, a linux distro based off of Debian.

b) SANE controls the Scanner.

c) ImageMagick is used to flip and convert the scanned image to a JPG.

d) ImageMagick is later used to overlay a timestamp onto the bottom of the JPG.

e) FFMPEG is used to convert a series of sequentially numbered JPGs into a h264 encoded video.

A few bash scripts automate most of this process.

I currently offload all of the images from the Pi onto a somewhat beefier Apple Laptop that process steps d & e. This could be done on the Pi, but would take almost forever.

Short Term Tech Future
1) Backup images to a separate local storage location.

2) Upload images to a separate online storage location.

3) Use online storage location to process and upload compiled videos to youtube.

4) Build new enclosure for webcam version

5) Bury webcam version below the frost line (42" in Michigan)

6) Build complete documentation for the Scanner version

7) Build complete documentation for the Camera version.

Long Term Tech Future
1) Utilize additional sensors to gather more data

2) Figure out more things that can be analyzed from the image feed along

3) Discover new methods of analyzing image feed.

Thursday, September 4, 2014

Worm sightings, books and more!

When I first started this project the first thing I thought I would see (aside from soil) were worms. It's been approximately 7 weeks since this scanner was buried and above is the first decent sighting of a worm! Update: Soil Flatworm! 

Perhaps the scanner isn't in soil conditions worms prefer, maybe the scanner emits something worms don't like. It could be that we're looking at such a small sliver of soil that the the chances of seeing a large portion of any worm is slim (we're only seeing a few millimeters deep). Towards the end of the video you see the worm burrow out of view, and a realization sets in of just how three dimensional soil is that the plant and animal life traverse! Also, more awesome videos showing 3D soil reconstructions.

I finished reading "What a Plant Knows" by Daniel Chamovitz and have just started "Know Soil Know Life" by David Lindbo, Deb Kozlowski, and Clay Robinson. What a Plant Knows has been a wonderful snapshot of our current scientific understanding on the various sensing abilities of plants. Without little to no background in plant biology I found this to be an easy and engaging read. It's fascinating that to a certain extent plants can sense light, smells, touch, and retain and pass on memories.

So far I've only had time to skim through Know Soil Know Life. It contains beautiful color photos, drawings, and graphs in abundance. A welcome change from the previous books I've been reading, and I'm looking forward to actually read it!

Books are such wonderful resources, but I'm curious to know what digital (and not just videos or recreations of books) options there are for teaching something many might consider a fairly mundane subject... ? : )

People generally react to the timelapse videos of soil with a mixture of confused enthusiasm. There's a lot going on below the earth that is difficult to ascertain with a few minutes of reading. And while digging through the soil is highly recommended, it's very difficult to grasp things that often happen in non-human sizes and timescales. I'm fascinated by the reconstructions of soil by Prof. John Crawford, A/Prof. Margaret Barbour, and Prof. Mark Adams, and wonder how they can be used to further engage an earlier interest in something like soil : )

Wednesday, September 3, 2014

Following the Roots

Taking footage that's already been recorded, but focusing on the growth of roots. This view is zoomed in, and we're exceeding the resolution the images were captured, hence the blur.

If the purpose is to track root growth, I could have set the scanning resolution to be significantly higher to enable much clearer and closer looking footage. The downside would be that faster moving (nematodes, arthropods, etc.) would appear blurry as the scanning head moved across them.

Future options:
 - Running two scans at different resolutions would resolve that issue.
 - Find a scanner that can scan quicker at a higher resolution
 - - How fast does it need to run to keep most things in focus?
 - - How often does one need to take a picture to more intuitively pick up the path of a nematode?
 - - One minute image captures on a buried webcam seemed adequate.
 - - Six minute image captures on the scanner is inadequate.

Why are the roots growing into the earth? Mmmmmm gravitropism ftw! Why do the roots stop growing? The Radish roots (at top) I believe had their tops devoured by an animal, as no radishes were every found when checked ~3 weeks in. I'm not sure what the roots are coming from in the bottom video.

I learned of the software RootFly, but haven't tried using it yet as it's windows based. I'm currently doing most of this on a Raspberry Pi (Linux) and Mac (OSX).

Wednesday, August 27, 2014

Rhizotrons and Scanners!

Buried scanner showing comparison of root growth with and without fertilizer.
The word "Rhizotron" is an amazing sounding word by itself, today I stumbled across a group that have been burying mini-rhizotron scanners!

Jared Williams and Rob Mikkelsen started doing this years ago with their students and have put together a great presentation on it.

A few of his observations I found interesting:
  • Use of technology in this way is more engaging to students.
    • Students are so excited they end up sharing results on their own Facebook accounts. 
  • He covers the basic build process in a way that can easily be done inside a classroom.
    • My current implementation has been buried outside. This provides different opportunities, but comes with a number of additional obstacles / difficulties.
  • Experimenting with the affects of fertilizer on root/plant growth
    • This is awesome. Being able to watch the difference both above and below ground.

Also, unrelated to above but amazing to watch:

Monday, August 18, 2014

Mmmmm, leaf decomposition and questions!

So many questions come up as I crunch these videos together. The above is 34 days (~July 13th - August 16th) time lapsed down to 34 seconds. Below is a quick list of questions/observations that I think would be neat to edit into the video and provide clickable links for further info.
  1. Did the fungus in the first few seconds target the grass, or did it just expand outward?
  2. Can / Does / Why / How would fungus travel in a specific direction?
  3. What goes after leaf/grass first, is it bacteria, fungus, bugs, a combination?
  4. After the soil has been rained on and the leaf turns very dark there's a significant influx of skinny semi transparent worms? What are these?
  5. What are ALL of the bugs that we can see? (another post coming soon)
  6. Bugs eating roots. Tasty!
  7. What are roots made of, what sort of nutrients do the bugs gain from eating them?
  8. Fungus! Can we find any fungal traps for bugs?
  9. Vertical Root Growth (Radishes)
    1. When / why does it begin and stop?
    2. Circumference change over time?
  10. Secondary/Horizontal Root Growth (Radishes)
    1. When / why does it begin and stop?
    2. Circumference change over time?
  11. Gravitropism & Phototropism
  12. Leaf decomposition process
    1. Mid rib last to go? In a few days all should be gone except that.
  13. Can we find any worm casts?
    1. Is that what we see in the first second of the video, above the left middle portion of the leaf?
I started reading "What a Plant Knows" by Daniel Chamovitz. Sufficiently awesome if you want a basic overview of plant senses. Last: Michigan Interlibrary Loan / MeLCat program FTW for making library books more accessible : )

Wednesday, August 13, 2014

Rain vs. Image Brightness over 30 Days

A quick comparison of rain fall vs. brightness of the soil over the past 30 days. The numbers on the left represent inches of rainfall on a given day and are associated with the green lines. It's neat seeing the two largest points of rainfall corresponding to a change in the soil brightness (blue line).

Started experimenting with the compare tool of ImageMagick. Using this scanner has some interesting problems. It doesn't always start and stop at the same point. Doing a comparison between two images when they are shifted up or down a couple millimeters seems to throw the compare tool off quite a bit. Using the fuzz option so it ignores that level of change is probably enough to cause it to ignore most of the other small movements.

These small movements being that of bugs. It would be fascinating to quantify some level of movement / change influenced by the number of bugs crawling around. In order to do so I think I first need a stable image. Whether that means using a different scanner, correcting the start/stop position change, or correcting for by identifying one or two points to crop the images at. I'm not sure, or maybe something else.

Either way, this is awesome, and you should probably go hug a bug. Or at least listen to an amazing radio show named just that : )

Tuesday, August 12, 2014

What does soil look like as it rains?

This is a quick six second video that covers a 24 hour period. Around the half way mark (mid day) the rain begins and you can see the change in soil color/brightness(?).  Images were taken every 15 minutes.

I used the program "Identify" from the software suite ImageMagick to get a rough idea of the average brightness of each image taken. Values below are from samples taken every hour. Over a 24 hour period this looks like:
The numbers on the left, 10200 thru 11400 are the values provided by identify when running the command: 
identify -format "%[mean]" image.jpg
I am not familiar with the method identify determines the average brightness. When comparing percentage differences of luminosity histogram values in Adobe Photoshop CS2 with those of identify, they were quite close. Though only a couple images were compared

I am guessing the scanner affects this in a number of ways:
  1. Scanner surface is very different than soil, may affect water path/flow
  2. Light from the scanner, may (seems negligible) provide enough heat to evaporate water quicker?
  3. Slight vibrations from the scanner operating may (seems negligible) affect water path/flow
Regardless, it's awesome to see this visually in terms of video and numbers/graphs.

Wednesday, August 6, 2014


So far images have been coming in at 300 DPI. My initial thoughts were that >300 DPI takes too long, would result in blurred movement and gigantic files. But so much of what I see moving at 300 DPI is too small!!

It's amazing just how many bugs are moving about down there.  Many of the ones that we can see with our eyes are small enough, and move slowly enough that it would be difficult to see if we weren't speeding time up. Most of the videos that have been posted are sped up over 30,000 times.

But even so, scanning at 300 DPI isn't enough to reveal many of the details on most of what's moving down there. So I've added a second scan at 1200 DPI to target the area the leaf still (barely) occupies. The above image is the first scan, measuring ~5.75x3cm. Click it for a higher res version. I should have a very short video up of this early next week.

I've been on and off reading "The World Beneath our Feet" by James B. Nardi. I would love to learn more about what we're seeing, and be able to document within these images and videos the processes that are covered in the book. It also mentions things like Berlese Funnels, incredibly simple devices to discover more of what's in our soil.

Other random things learned today: The terms Pedology (the study of soils in their natural environment) and Edaphology (influence of soils on living things, particularly plants). Which reminds me, I should go learn from the crew over at Photosynq!

Tuesday, August 5, 2014

Time lapse & image crunching

Over the past three weeks I have amassed approximately 2200 images. One image taken every 15 minutes. This is far too many files for me to handle with something like GIMP or Photoshop. Thankfully I am not the first person to have this problem, and the internet makes it very easy to find solutions to problems other people have already had.

Each image is approximately 2539 × 3507 pixels, and the orientation is not pleasant to view on a standard widescreen monitor. Further, there is so much activity that trying to view a series of images with everything visible tends to drown out any specific area of interest. So I've taken to cropping down to smaller 1280x720 or 1920x1080 pixel regions.

I've been using the software suite Imagemagick to handle the bulk of this.  For example:
for file in *.jpg; do convert -crop 1920x1080+310+285 $file tc/zleaf_$file; done
This takes every jpg in a given directory: Move to a point 310 pixels in from the left and 285 pixels down from the top, and then crop out an area 1920 pixels to the right and 1080 pixels down.

It places each of these new images in a directory (previously created) called "tc" and labels the new images with the prefix "zleaf_" followed by the original file name. I preserve all the original files and have a separate directory with the new cropped images.

I have been using a few different programs to generate the videos. Originally I started with Apple's free iMovie '09 and an ancient version of Adobe After Effects. iMovie is a breeze to use and After Effects seems to offer more than I could imagine needing for this. However both require me to be involved in the process. They also won't run (easily) on a *nix system.

So I'm working to settle on Mencoder, a part of the Mplayer program used to play videos. Using two commands I'm able to easily (and so far much quicker than iMovie or Adobe After Effects) generate videos:
ls -1tr *.jpg | grep -v files.txt > video.txt
Creates and saves a files called video.txt, it contains a list of all the jpgs in a given directory.
mencoder -idx -nosound -noskip -ovc x264 -x264encopts bitrate=3000 -o video.avi -mf fps=30 'mf://@video.txt' 
Creates a video file that plays back at 30fps with no sound at the same resolution of the source images. It takes ~5 minutes to create a 1920x1080 video out of the 2200 image files, the file size of the resulting video is ~28MB. The original images totaled ~1.8GBs. Video below (recommended playback: Full screen at HD if possible)

The next step in this project (I think) involves
 - Figuring out how to overlay 1cm grid lines
 - Figuring out how to embed a timer
 - Finding a few areas of interest so images can be automatically
 - - Cropped and saved as they are captured (keeping the original intact)
 - - Lists generated for each day of images
 - - Videos generated for each day of images
 - - Compiled video based on each daily video
 - - -

Various links to places that helped me figure all this out:
 - Converting/Cropping image files
 - Generating timelapse videos with Mencoder

Monday, August 4, 2014

Video editing, germination, root growth and for loops!

Adobe After Effects v7.0 doesn't have native support for Intel hardware. It works, but supposedly has limitations on available RAM.

Using a for loop and the linux software imagemagick (convert) to crop a specific region out of a series of images and save with a new file name. This was done to focus on the area of a germinating radish seed.

Using a script to include an hour timer within Adobe After Effects. This was used to show the time elapsed in the first 58 hours of the germinating seed.

Plant life:
Germination is the process of a plant growing from a seed. A Radish seed is considered to be a dicot, meaning the embryo will have two cotyledons, aka two leaves arising from the seed.

It took approximately 13 hours after planting the seed for a visible change to occur within our view. This may have happened sooner, but we can't easily see the whole seed with this setup. It's possible it started much earlier in non visible area.

The video above shows a 1cm grid overlay, at hour:
13 = Seed bulges
24 = White of root barely visible on the top side of the seed
31 = White of root barely visible below the seed
39 to 48 = 1cm of root growth
48 to 54 = 1cm of root growth
53 = A second root is seen growing.

If we measure the root growth from the 39th to 54th hour, we have it growing at roughly 1cm p/7.5 hours. Woohoo!

There are numerous other time lapse videos of radish growth, very cool! All of the ones I have seen show the plants in containers of some sort, or above the ground. The video above is taken from the ground, the container being the earth.