﻿ RCon3D

# Sectioning of images

This is a tutorial on sectioning on 3D confocal images. Sectioning is in the z-direction, i.e. layer-wise.

``````library(RCon3D)
library(plotly)``````

### Find the images

``img <- findIMG("/Data")``

## Sectioning

The `xy_splits` function runs an analysis for each xy-position. If we for example sum for each xy-position we will get a biomass distribution across the image. We can also use the function to section the image and then sum. We can for example say that the top is the upper 10 layers for each xy position. Here we say that the upper part is the upper 50% for each xy-position. It is therefore dynamic sectioning that follows the thickness of the specimen.

Sectioning is done for all the channels given as input.

``````my.xy.split <- xy_splits(img, channels = c("xan","pan","ste","mic"),
do = "section", upper.part = 0.5, layer.start = "Top", cores = 1)``````
``## Starting sectioning``
``````##
|
|                                                                 |   0%
|
|=================================================================| 100%``````

The result is a recursive list with matrices of results for each xy-position as elements:

``str(my.xy.split)``
``````## List of 1
##  \$ FourSpecies24h_:List of 2
##   ..\$ Upper:List of 4
##   .. ..\$ xan: num [1:512, 1:512] 5 10 27 33 31 36 37 32 26 32 ...
##   .. ..\$ pan: int [1:512, 1:512] 60 51 42 39 36 30 36 21 29 16 ...
##   .. ..\$ ste: num [1:512, 1:512] 6 9 8 9 10 16 12 23 35 31 ...
##   .. ..\$ mic: num [1:512, 1:512] 0 2 0 0 0 0 0 1 0 8 ...
##   ..\$ Lower:List of 4
##   .. ..\$ xan: num [1:512, 1:512] 0 0 4 9 2 1 0 2 5 3 ...
##   .. ..\$ pan: int [1:512, 1:512] 60 66 73 74 75 81 70 76 74 78 ...
##   .. ..\$ ste: num [1:512, 1:512] 11 6 2 0 0 1 16 2 11 7 ...
##   .. ..\$ mic: num [1:512, 1:512] 0 0 0 0 0 0 0 0 0 0 ...``````

From the quantification tutorial “xan” appeared to be mainly in the top, lets see if it is consistent with this analysis.

``````# Upper part
up.sum <- sum(my.xy.split[[1]][["Upper"]][["xan"]])

# Lower part
lo.sum <- sum(my.xy.split[[1]][["Lower"]][["xan"]])

up.sum/lo.sum``````
``## [1] 9.932445``

10 times more pixels in the upper part than the lower part! Note that the first list denotes the image number `[[1]]`, second list the section `[[Upper]]`, and third list the channel `[["xan]]`. This outputs a matrix in which the position correspond to the xy-coordinate and the value to the sum of pixels in the section

Lets plot heatmaps of the upper and lower sections:

``heatmap(my.xy.split[[1]][["Lower"]][["xan"]],Rowv = NA,Colv = NA,main="Lower part",col=colorRampPalette(c("white","blue"))(10))``

``heatmap(my.xy.split[[1]][["Upper"]][["xan"]],Rowv = NA,Colv = NA,main="Upper part",col=colorRampPalette(c("white","blue"))(10))``