Commit 5c3e0e3d by Turnhout, M.C. van

 ... ... @@ -4,10 +4,14 @@ Feel it in the one drop; And we'll still find time to rap; \qauthor{Bob Marley \ \end{savequote} \chapter{Under the hood}\label{hood} As mentioned in chapter \ref{workflow}, the analysis consists of three steps: droplet tracing (\texttt{BF}), fluorescence image pre-processing (\texttt{fluo}), and cell counting (\texttt{ncel}). These steps are taken care of by \DMA{analyseFoV}: As mentioned in chapter \ref{workflow}, a image-stack analysis consists of four steps: droplet tracing (\texttt{BF}), fluorescence image pre-processing (\texttt{fluo}), cell counting (\texttt{ncel}) and events parsing (\texttt{dcel}). These steps are taken care of by \DMA{analyseFoV}: \vspace*{-.4em}\begin{lstlisting}[language=DMAlab, numbers=none] [BF, fluo, ncel] = DMA_analyseFoV; [BF, fluo, ncel, dcel] = DMA_analyseFoV; \end{lstlisting} where \DMA{analyseFoV} calls \DMA{analyseevents} after the stack analysis to get \texttt{dcel}. In this chapter, we will briefly describe what \dmalab\ actually does' in each step.\\ \noindent Note that all images (brightfield and fluorescence channels) are scaled with the bit range of the camera so that the maximum possible intensity (white') gets value 1. Raw' data means the image data converted from \texttt{uint16} to \texttt{double} and divided by $2^\text{\param{nbit}}$ (\DMA{tifread}). ... ... @@ -72,7 +76,7 @@ Droplet tracing (or more precise: circle tracing) is done by comparison of circl \item we then loop over the detected circles in the current frame; and \item we look for the closest circle in the previous time point for each circle in the current time point, and assume that this is the same droplet. \end{itemize} This is of course bound to go wrong when droplets move too much between frames. We therefore check the detected movement of the circle centres between frames (their Eucliden distance) against \param{maxmove}: when the closest circle centre in the previous frame is further than \param{maxmove}$\cdot$(circle radius) pixels away from the current circle centre, we do \textsl{not} assume that these circles represent the same droplet {\color{red}(not yet implemented)}.\\ This is of course bound to go wrong when droplets move too much between frames. We therefore check the detected movement of the circle centres between frames (their Eucliden distance) against \param{maxmove}: when the closest circle centre in the previous frame is further than \param{maxmove}$\cdot$(circle radius) pixels away from the current circle centre, we do \textsl{not} assume that these circles represent the same droplet.\\ \noindent All this (and further analysis) requires some bookkeeping. We of course track droplet centres and radii, but we also keep track of the circle index and between-frame-movement (Euclidean distance). The circle indices are all over the place' (figure \ref{droplettracingb}), and in different time points these indices can be all over totally different places (droplets may move in and out of the images, and circle indexing is unpredictable to start with). We store the between-frame-movement in order to be able to dismiss (more) circles in post-processing. ... ... @@ -146,10 +150,39 @@ instead of the line above. In fact, the value of \param{cellminIraw} controls just that: with which image, \texttt{raw} or \texttt{A}, does \DMA{analyseFoV} call \DMA{countfluo}. \subsection{Output} The output argument \texttt{ncel} contains a row for each fluorescence channel of a droplet with a column for each time frame with the number of detected cells in that channel in that droplet in that time frame (up to \param{maxcells}). This output is collected by \DMA{analyseFoV} into a single matrix \texttt{ncel} for all detected droplets in \texttt{BF} (section \ref{outputncel}, \ref{countfluocollect}). The output argument \texttt{mi} contains \param{maxcells} rows for that channel in that droplet with the mean intensity, the coordinates and the size (area) of the detected objects. This output, per droplet, per channel, is also collected by \DMA{analyseFoV} into single matrices \texttt{ob(IxyA)} for all detected droplets in \texttt{BF} (section \ref{outputobX}, \ref{countfluocollect}). \section{Collecting results in \texttt{ncel}, \texttt{fluo}, and \texttt{ob(IxyA)}}\label{countfluocollect} \DMA{analyseFoV} calls \DMA{countfluo} for each individual droplet and fluorescence channel, and it collects all those individual per channel cell counts (\texttt{ncel}) and object properties (\texttt{mi}) and in single output matrices for the entire image stack, similar to \texttt{BF}. It is these stack-matrices' that are written to files in the directory \param{odir} (section \ref{outputncel}).\\ \noindent The \DMA{analyseFoV} output matrix for \texttt{ncel} contains a row for each droplet with with [result fluo 1, results fluo 2, result fluo 3, \dots] successively for each time point. Its size is thus (number of detect droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row. The output matrix for \texttt{fluo} has the same format, and contains the mean (relative or absolute) intensities of the detected objects. This is the mean of the first column of the output argument \texttt{mi} from \DMA{countfluo}. In other words: if there are multiple objects in the droplet for that fluorescence channel, the file will contain the mean intensities of (all) those objects.\\ \noindent Properties for the (up to \param{maxcells}) individual objects are written to the \texttt{obI} (intensities), \texttt{obx} ($x$-coordinate of object centre), \texttt{oby} ($y$-coordinate of object centre), and \texttt{obA} (size/area of the object) files (section \ref{outputobX}). And it is these files with individual object properties that are used by \DMA{analyseevents} to assess events' (which cell in which channel died, in which frame). \section{Parsing events}\label{eventparsing} \DMA{analysevents} reads the \texttt{ncel} file and the files with individual object properties that were produced by \DMA{analyseFoV}. It first selects the droplets of interest' from \texttt{ncel}: only droplets that had at least one cell detected during the experiment will be analysed. \DMA{analyseevents} will then look at the dead cell' channel for these droplets of interest. When a dead cell is detected in that channel, \DMA{analyseevents} will attempt to match that cell (object) with the cells found in the other fluorescence channels. If an object in the other channels has a centroid that falls within the area of the detected dead cell, we assume that that was the cell that died. The area is assumed to be a circle with a certain radius so that the circles area matches that of the dead cell area (in pixels). The check on the centroids is performed with the radius of that circle (it is a match' when the centroid distance is smaller than that radius). If a possible candidate for this dying/dead cell is not found in the same frame (time-point), we look 1 frame back: a cell may disappear as living before it is detected as dead'.\\ \noindent \DMA{analyseevents} writes its results to the \texttt{dcel} file in \param{odir} (section \ref{outputdcel}). \section{Collecting results, \texttt{fluo} and \texttt{ncel}} \DMA{analyseFoV} calls \DMA{countfluo} for each individual droplet and time point, and its collects all those individual mean intensities (\texttt{mi}) and cell counts in two output matrices, similar to \texttt{BF}. Both matrices contain a row for each analysed droplet with [result fluo 1, results fluo 2, result fluo 3, \dots] successively for each time point. Its size is thus (number of detect droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row.\\ \noindent For the output argument \texttt{fluo} the result that is stored is the (absolute or relative) mean intensity \texttt{mi} from \DMA{countfluo}, and for the output argument \texttt{ncel} the result that is stored is the cell count \texttt{ncell} from \DMA{countfluo}. These two matrices are also written to a text file, the \texttt{ncel}-matrix twice (section \ref{flowresults.bf}).
 ... ... @@ -138,7 +138,7 @@ And then it will simply call \DMA{analyseFoV} with the obtained settings on all \DMA{analyseFoV} writes a number of files to disk for each analysed image stack in the directory defined by \param{odir}. The filenames will be the same as that of the analysed image stack, but with e.g.\ \texttt{.bf}, \texttt{.fluo}, \texttt{.ncel} or \texttt{.csv} substituted for the extension \texttt{.tif}. These are all just and regular text files. \subsubsection{Droplet tracing, \texttt{.bf}} \subsubsection{Droplet tracing, \texttt{.bf}}\label{outputbf} The \texttt{.bf}-file contains the results of the droplet tracing. For each detected droplet it contains a row with five results for each time point. Its size is thus (number of detect droplets)$\times$($5\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $5(n-1)+1$ through $5n$ in each row. ... ... @@ -151,16 +151,16 @@ The five parameters are \item droplet centre movement compared to previous frame [pixel] \end{enumerate} \subsubsection{Mean fluorescence intensities, \texttt{.fluo}} \subsubsection{Mean fluorescence intensities, \texttt{.fluo}}\label{outputfluo} The \texttt{.fluo}-file contains the mean intensity of the detected cell(s), either absolute or relative to background (section \ref{countfluosec}). For each detected droplet in \texttt{.bf} it contains a row with \param{nchan}-1 mean intensities for each time point. Its size is thus (number of detected droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row. \subsubsection{Mean background intensity, \texttt{.bgi}} \subsubsection{Mean background intensity, \texttt{.bgi}}\label{outputbgi} The \texttt{.bgi}-file contains the mean pixel intensity of the background. For each detected droplet in \texttt{.bf} it contains a row with \param{nchan}-1 mean intensities for each time point. Its size is thus (number of detected droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row. \subsubsection{Cell counts, \texttt{.ncel}} \subsubsection{Cell counts, \texttt{.ncel}} \label{outputncel} The \texttt{.ncel}-file contains the number of detected cell(s). For each detected droplet in \texttt{.bf} it contains a row with \param{nchan}-1 counts for each time point. Its size is thus (number of detect droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row. ... ... @@ -170,16 +170,17 @@ The \texttt{.csv}-file collects the results of \texttt{.ncel} in a different for Its size is thus ((number of detected droplets)$\cdot$((\text{\param{nchan}}-1))$\times$((number of time points)+1), and results for the $n$\ap{th} channel of the $d$\ap{th} droplet are in row $(\text{\param{nchan}}-1)d+n$. \subsubsection{Dead cell counts, \texttt{.dcel}} \subsubsection{Dead cell counts, \texttt{.dcel}} \label{outputdcel} The \texttt{.dcel}-file contains the number of detected cell(s) that have died during the experiment (cells that were already dead at the start of the experiment are not counted). For each detected droplet with at least one cell appearing in the `dead cell' fluorescence channel (last index in \param{fluo}), it contains \param{nchan}-1 rows with dead cell counts for each time point. Each row starts with the droplet index (row reference for \texttt{.bf}, \texttt{.fluo} and \texttt{.ncel}). The first \param{nchan}-2 rows are for the fluorescence channels with (initially) living cells and contain with the count of the number of cells that have died in that droplet and channel . The last row for each droplet contains the total number Its size is thus (number of detect droplets)$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in each row. Each row starts with the droplet index (row reference for \texttt{.bf}, \texttt{.fluo} and \texttt{.ncel}). The first \param{nchan}-2 rows are for the fluorescence channels with (initially) living cells and contain with the count of the number of cells that have died in that droplet and channel . That is: when a cell is detected to have died in a fluorescence channel in a certain frame, the index for that frame will be increased with 1. The last row for each droplet contains the counts of cells in the dead cell channel over time (frames), and the index for cells that were already dead at the start of the experiment will be set to -1. The size is thus ((number of detect droplets with dead cells)$\cdot$(number of fluorescence channels))$\times$ (number of time points)). \subsubsection{Individual cell properties, \texttt{.ob}(IxyA)} \subsubsection{Individual cell properties, \texttt{.ob}(IxyA)}\label{outputobX} The \texttt{.ob}(IxyA)-files contain the individual data for \param{maxcells} detected cell(s) per fluorescence channel per droplet. These files contain (number of detected droplets)$\cdot$\param{maxcells} rows with \param{nchan}-1 values for each time point for each droplet in \texttt{.bf}. Their size is thus ((number of detect droplets)$\cdot$(\param{maxcells}))$\times$((number of fluorescence channels)$\cdot$(number of time points)), and the results of the $n$\ap{th} time point for the $d$\ap{th} droplet can be found at positions $(\text{\param{nchan}}-1)(n-1)+1$ through $(\text{\param{nchan}}-1)n$ in rows \param{maxcells}$(d-1)+1$ through \param{maxcells}$d$. ... ...