Segmentation Tutorial part 2 - veeninglab/BactMAP GitHub Wiki

Data Import

Loading the original .TIFF image

First, let’s put the original .TIFF image into our environment using extr_OriginalStack(). I’ll call the imported .TIFF “pneumoTIFF”.

All BactMAP functions which convert data from other programs to a standard dataframe (or list of dataframes) start with extr_. If you want to know more about a specific function, you can check it out in the BactMAP documentation. For instance, when you want to know more extr_OriginalStack(), type ?extr_OriginalStack in your terminal for more information. You can also find it on the wiki.

pneumoTIFF <- extr_OriginalStack('FigS2/PHASE.tif')

To see if the TIFF made it into R the right way, we can use BactMAP’s plotRaw() to display the TIFF file.

plotRaw(tiffdata=pneumoTIFF)

That looks good. I’ll get back to the plotRaw function later in this tutorial.

Import all segmentation datasets

We can use the specific extr_functions to get the segmentation data into R. I’ll go through each of the progams used by our lab members below.

If you use the S. aureus dataset instead in this tutorial, check the sources of each dataset in the documentation so you know which function to use for which subset. If you are using your own datasets, make sure to go through the extr_functions to see how you can import your data.

SuperSegger

Jun used SuperSegger and Oufti to segment the image. Let’s first import his SuperSegger results using the function extr_SuperSeggerCells().

extr_SuperSeggerCells() requires the following variables:

  • the path where the SuperSegger data is saved
  • the amount of frames you analyzed (in our case, just 1)
  • (optional) the magnification converter you want to use. I saved our magnification converters into BactMAP. Use the function getPixels2um() to see which ones I saved, and type `?Pixels2um in your console for more information on how to add a new conversion factor.
  • the start number of your frames. BactMAP finds the cell information in the SuperSegger subfolder(s) starting with "xy". In our case, we have only one subfolder which is called "xy1", so I put "startframe" to 1.
junSeg <- extr_SuperSeggerCells("FigS2/SgmentationTest.Jun/SuperSegger", 1, mag="100x_FRAP", startframe=1)

Oufti

Jun also used Oufti to segment the image, just as Clement did. We can get both of their analyses into the R environment using the function extr_Oufti.

extr_Oufti needs the following variables:

  • The MATLAB or CSV file output from Oufti
  • (Optional) the magnification converter.
junOuf <- extr_Oufti("FigS2/SgmentationTest.Jun/Oufti/PHASE.tif.mat", mag = "100x_FRAP")

clemOuf <- extr_Oufti("FigS2/Seg_Clement/PHASE_Clement.mat", mag="100x_FRAP")

MicrobeJ

Lance used MicrobeJ for segmentation and saved the contours of the cells as a .csv-file. Check the extr_MicrobeJ() documentation for instructions on how to obain the contour csv from MicrobeJ. Make sure you have an updated version of MicrobeJ (>5.13) if you want to do this yourself. We use extr_MicrobeJ() to get Lance’s data into R.

extr_MicrobeJ requires:

  • dataloc: the countour .CSV dataset output from MicrobeJ
  • the magnification converter (Obligatory! If you forget, the function will ask you)
  • (optional) spotloc: the output of detected Maxima from MicrobeJ
lanceMic <- extr_MicrobeJ(dataloc="FigS2/Segmentation.Lance/Contour.csv", mag="100x_FRAP")

3.2.4 Morphometrics

Finally, I used Morphometrics to get the cell outlines. The function for importing Morphometrics output is extr_Morphometrics().

extr_Morphometrics requires:

  • The MATLAB CONTOURS output from Morphometrics
  • (optional) the magnification converter
renMorph <- extr_Morphometrics("FigS2/Morphometrics_Renske/PHASE_17-Jan-2019_CONTOURS.mat", mag="100x_FRAP")

⬅️ Segmentation Tutorial part 1: Before Getting Started Segmentation Tutorial part 3: A Closer Look ➡️
⚠️ **GitHub.com Fallback** ⚠️