TITLE: High time-resolution of root tracking of Arabidopsis roots using SPIRO, SmartRoot and BackTracker
AUTHORS: Magdalena M Julkowska

[DESCRIPTION]
This protocol describes an alternative way of analyzing SPIRO images for root growth of plants that are transferred to the treatment plates - and thus not imaged from the germination onwards. This protocol combines SPIRO tools, SmartRoot and BackTracker script, as well as R-scripts for data curation. The protocol was thus far tested on Arabidopsis roots - and we intend to test it in the future on tomato roots as well.  

[STEPS]
1. Collect your images caputred by SPIRO from the Raspberry Pi by going into the FileManager - and downloading your experiment:

  

2. Pre-process your images for drifting using the SPIRO pre-process in ImageJ / Fiji - as described on SPIRO Assay github page here. This will result in all of your images being cropped and ALIGNED, and also transferred as multiple layers into one TIFF file. 

  

3. Now we need to transfer this multi-layer tiff file into individual tif files - preferably containing their timestamp for our future steps.

At this  moment - you have two options 

1) rather painful (manual) solution that will maintain the information and timestamps in the file name OR 

2) fully automated one - but your images will be renamed into 1, 2, 3, 4 ... and you will loose a timestamp information - if you are confident you will be able to add it back in later in R - go for it - but just beware that this might be a source of potential problems in the future.  

BUT FIRST - For both options - you need to first invert the image - since SmartRoot prefers the root to be DARKER than the background. Open your mutli-layer tiff in ImageJ/Fiji and select invert function - save the inverted file in your Experiment folder:

  
now - you can choose whatever option you feel most comfortable with:

OPTION 1: manual splitting image using ImageJ/Fiji

Open the multi-layer-tiff file in Fiji/ImageJ - and select "Stack to Images" like on the screenshot below:

 
It will open ALL layers as individual images and then save individual images through SAVE KEYBOARD SHORTCUT (Mac = cmnd + S; Windows = ctrl + S). It will feel like it takes forever - but its actually not that bad. And also - I really hope to have a more automated solution for this soon. 
 

NOTE - make sure to save individual files in ONE FOLDER per plate - similar to the original SPIRO setup.  

As a reference - here is how my folder looks like before I start my SmartRoot part after this option:

  

OPTION 2: automatic split of the images using ImgMagick

1) Make sure to install ImgMagick on your computer  

2) Navigate to your folder containing the multi-layered tiff file

3) run the following command - adjusting the file name:
 
 4) put all single layer tiff file into one folder per plate - and maybe move it into your SmartRoot Experimental directory. 

As a reference - here is how my folder looks like before I start my SmartRoot part after this option:

    

4. Trace the LAST file of each plate - containing the longest roots - using SmartRoot plugin for ImageJ / Fiji.

Do NOT put any effort in naming the roots - they will be renamed anyways afterwards - so save your time. We will figure it out what genotype is where later. 

I advise NOT to trace the roots that are entangled within each other in the last image and/or end in a shoot - they need to be all clearly distinguished roots - not growing into the other root.

Here is a screenshot of the roots that I did/did not trace on my plate:
  
5. Make sure to install all the dependencies on your computer for BackTracer:

 

6. Once you have everything installed - download the python script from the BackTracker repository, and open it in a code-writing software like Atom.io.

In the python code - you will need to change TWO things:

1) adjust the image repository to the folder containing the files with your plate images (and SmartRoot traced the last image - you will get rsml file once the image is traced). 

  
2) Make sure to replace all "tiff" by "tif" - since the BackTracker is using "tiff" in their original file format. 

I only found one location where it needs to be changed (line 29) - but double check if it isn't popping anywhere else: 

  
You can find this file - where I already adjusted all the "tiff" to "tif" and you just need to change your directory in line 8 of this script:

  


7. Make sure to save changes to the file - and run the python file by typing in your terminal / Conda window:


 

Running this step might take a while, so be patient, go make yourself coffee / tea or stretch your legs and arms. 
8. Make a Quality Control - by going into your original Experiment folder - and figuring out if you have any EMPTY RSML files. You can easily see it by the size of the rsml files. As long as the files are NOT empty - it will be fine.

You can easily see the size of the files by changing the view in your Finder window:

  

9. Export your rsml files as csv file one plate as the time through SmartRoot Batch export window:

  

10. The last thing that we need to do in SmartRoot is to figure out what root ID corresponds to your individual genotypes. 

1) Open the penultimate image in your image stack and add tracing data by the BackTracer by selecting with the right click "Import previous datafile" - and select the file that was generated by the BackTracker.

   
2) Once you imported the automatically traced RSML file - go to RootList on the SmartRoot menu and click "Refresh" at the bottom of the root list menu - the root names will appear automatically:

  
3) By selecting individual roots - you will be able to tell what root is belonging to what genotype

  

4) make a decoding file - containing the root name as in the rsml file as well as its actual genotype and/or condition - I attach my own decoding file below as an example:

   

11. Import the data into R and for analysis, you can follow the R-pipeline developed by Magda here. 

NOTE: There is a big chance there will be MANY outliers / odd time points - so you will spend a significant amount of time in R analysis on data curation. 

I have a number of data curation methods described in my pipeline - please use whichever you think will apply the best for your specific scenario and the precision of this automatic tracing.