Skip to content

Commit

Permalink
CMCImacrocourse.tex
Browse files Browse the repository at this point in the history
  • Loading branch information
miura committed May 15, 2014
1 parent 2198bf0 commit e629856
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions CMCImacrocourse.tex
Expand Up @@ -755,7 +755,11 @@ \subsubsection{Stack Analysis by for-looping}
Here is an example of measuring intensity change over time\footnote{What we write as macro here could be done with a single command \ilcom{[Image > Stacks > Plot Z-Profile]} but this only measures intensity. If you want to measure other values such as the minimum intensity, a macro should be written. }.
\lstinputlisting[morekeywords={*, run, setSlice, nSlices}]{code/code10.ijm}
\begin{itemize}
<<<<<<< HEAD
\item Line 3: \ilcom{nSlices} is a macro function that returns the number of slices in the active stack.
=======
\item Line 3: \ilcom{nSlices} is a function that returns the number of slices in the active stack.
>>>>>>> 223305f57120dbf0ace6b71292d90de2ad2cb6b6

\item Line 4: Sets measurement parameters, from the menu would be \ilcom{[Analyze > Set measurements\ldots]}. In this case "mean min integrated" is added as part of the second argument. ``mean'' is the mean intensity, ``min'' is the minimum intensity and ``integrated'' is integrated density (total intensity). These keys for measured parameters could be known by using the command recorder.
You do not have to care for now about the "redirect" argument. "decimal" This is the number of digits to
Expand Down Expand Up @@ -2065,7 +2069,7 @@ \subsection{Using Values in Results Window}

\lstinputlisting[morekeywords={*, getResult, nResults}]{code/code24.ijm}

At line 1, \ilcom{nResults} is a function that returns number of rows in the Results table.
At line 1, \ilcom{nResults} is a function that returns the number of rows in the Results table.
Frame number is added with 1 in the line 2 because frame number in ParticleTracker plugin starts from 0,
while it starts from 1 in ImageJ.
In line 3 and 4, xpos and ypos is inverted,
Expand Down Expand Up @@ -2168,10 +2172,10 @@ \subsection{Using values in non-Results table}
\end{figure}

So far so good, we succeeded in getting data out of the results table.
Then what we need to do now is to play around with \ilcom{str} variable,
where all the data is now contained as a chunk. Since this chunk of data is not usable directly,
we first split the \ilcom{str} to single lines of string array.
For this we use \ilcom{split} function, the definition of which is
Then what we need to do now is to play around with the \ilcom{str} variable,
where all the data is now contained as a chunk. Since this chunk of data is not usable directly,
we first split the \ilcom{str} to single lines of a string array.
For this we use the \ilcom{split} function, the definition of which is

\begin{indentCom}
\textbf{split(string, delimiters)}\\
Expand All @@ -2182,17 +2186,17 @@ \subsection{Using values in non-Results table}
Returns a one element array if no delimiter is found.
\end{indentCom}

Using this function to convert the string to a string array and adding two more lines to check the content of array,
code now looks like this:\\
Using this function to convert the string to a string array and adding two more lines to check the content of the array,
the code now looks like this:\\
\begin{lstlisting}[numbers=none, morekeywords={*, split}]
str = getInfo("window.contents");
//print(str);
strA = split(str, "\n");
print(strA[0]);
print(strA[1]);
\end{lstlisting}
We use delimiter \ilcom{\textbackslash{}n} which means "new line", a hidden character in \ilcom{str}
that feeds new line to form a table. When we run above code we will see two data shown in the log window (Fig. \ref{fig:splittedLine}).
We use the delimiter \ilcom{\textbackslash{}n} which means "new line", a hidden character in \ilcom{str}
that feeds a new line to form a table. When we run the above code we will see two lines of data shown in the log window (Fig. \ref{fig:splittedLine}).
%figure
\begin{figure}[htbp]
\begin{center}
Expand All @@ -2210,7 +2214,7 @@ \subsection{Using values in non-Results table}
print(lineA[3]);
\end{lstlisting}

We use delimiter \ilcom{\textbackslash{}t}, which means "tab", to convert single line to an array of data. each for a column.
We use the delimiter \ilcom{\textbackslash{}t}, which means "tab", to convert a single line to an array of individual pieces of data (one element for each column).
%figure
\begin{figure}[htbp]
\begin{center}
Expand All @@ -2221,18 +2225,18 @@ \subsection{Using values in non-Results table}
\end{figure}

The value shown in the Log window (Fig. \ref{fig:doublesplittedLine})
should be the same as X value in the first row of the original table (Fig. \ref{fig:manualtrackingresults}).
should be the same as the X value in the first row of the original table (Fig. \ref{fig:manualtrackingresults}).

We now know how to access individual data values within \ilcom{str},
by first splitting it with delimiter \ilcom{\textbackslash{}n} and then by
\ilcom{\textbackslash{}t}. We can print all XY coordinates in Log window by following code.
by first splitting it with delimiter \ilcom{\textbackslash{}n} and then by
\ilcom{\textbackslash{}t}. We can print all XY coordinates in the Log window with the following code.

\lstinputlisting[morekeywords={*, split}]{code/code25.ijm}

If you encounter error message with \ilcom{lineA[]} such as shown in fig.\ref{fig:fig262_ErrorMessage},
this is just because there is another text widow opened and \ilcom{getInfo()} function worked on
If you encounter an error message with \ilcom{lineA[]} such as shown in fig.\ref{fig:fig262_ErrorMessage},
this is just because there is another text widow open and the \ilcom{getInfo()} function worked on
that window rather than the results table of the Manual Tracking. To avoid such error,
close extra text windows and then try running the macro again.
close the extra text windows and then try running the macro again.
%figure
\begin{figure}[htbp]
\begin{center}
Expand All @@ -2254,15 +2258,15 @@ \subsection{Using values in non-Results table}
\end{figure}

Check the log window (Fig. \ref{fig:fig253_CoordinatesPrintedOut}),
compare the output with manual tracker results table, and if you are confident that you are accessing data in table,
you could then use XY coordinates to place a circular ROI,
measure average intensity in that area and list them in ImageJ Results window.
compare the output with the manual tracker results table, and if you are confident that you are accessing the right data in the table,
you could then use the XY coordinates to place a circular ROI,
measure the average intensity in that area and list them in the ImageJ Results window.

\lstinputlisting[morekeywords={*, split}]{code/code25_5.ijm}

Running this code, you should see Results window that looks like figure
Running this code, you should see a Results window that looks like figure
\ref{fig:fig262_ManualTrackIntfinalResults}, tracking data plus measured intensity is shown in
column titled "RoiInt". The way oval ROI is used to measure mean intensity is similar to what
the column titled "RoiInt". The way the oval ROI is used to measure the mean intensity is similar to what
we have coded in the previous subsection. A difference is that this time, we use arrays that store data
extracted by splitting the chunk of string data.

Expand Down

0 comments on commit e629856

Please sign in to comment.