ROIanalyser

This website contains the most recent stable version of the ROIanalyzer plugin developed by Dr. Timo Rantalainen and A/Prof. Daniel Belavy. The current jar file can be downloaded from here. The source code for this plugin can be found on Github here.

First usage: Setup ImageJ

If you are using this for the first time, follow the following steps.

  • Download and install on your computer https://imagej.nih.gov/ij/download.html We suggest using the "Platform Independent" version. If if the platform independent version does not work at first go, you may need to install the "Java Runtime Environment".
  • Download the current version of ROIanalyzer and save it to your computer.
  • Open ImageJ, drag and drop the ROIanalyzer_.jar file onto ImageJ. Then save it in \plugins\jars\. Alternatively, open up the folder "jars" in the ImageJ folder on your computer (\ImageJ\plugins\jars\) and copy this file here. If you are using a Mac and need to go via Finder but if you cannot see your harddrive icon, see here.
  • Close ImageJ if it is open and then start it again.
  • Go to the menu: Plugins > Macros > Startup Macros. Go to the bottom of the text window and copy and paste the following text there. This is a macro for ImageJ to run repeated steps without you having to manually implement them. This is the basic macro for running the plugin. Depending on data type, there will be other kinds of macros [see below]:

macro "ROIanalyse...[k]" {

run("ROI subregions");

run("ROI Export");

run("Draw", "slice");

run("Next Slice [>]");

run("Select None");

}

  • In the text window, go to File > Save to save the StartupMacros.txt. Close ImageJ and then restart it (macros only come into effect when you re-start it). Go to Edit > Options > Input/Output. Tick the box 'Use JFileChooser to open/save'. Press OK.
  • Create a folder on your C: called "C:/Output". For a Mac, click on your hard-drive icon and create a new folder called "Output". If you cannot see your hard-drive icon in Finder on your Mac, see here.
  • Now to set up the ROIanalyser plugin. Go to ImageJ menu: Plugins > IVDisk > "ROI Plug-in Settings" (Third option). Insert the following settings

Sub-region Rows: 1

Sub-region Columns: 5

Root Directory: c:/Output (note: for a Mac, use /Output)

Results Sub-directory: NAMEOFYOURDIR_Results [this is an example, this is the directory name where the output text files with the measurements will be stored]

Roi results directory: NAMEOFYOURDIR_ROIs

Visualise Sub-regions: 0 [if set to 1, this will generate a new image for you to visualise the segmentation]

ROI to read: [no need to change this one. Only used when reloading ROIs into ImageJ for reanalysis]

Stack path: [no need change this one. Only used when reloading ROIs into ImageJ for reanalysis]

Rotation: 0 [0=uses all pixels to rotate the ROI to the horizontal, 1=top row of pixels, 2=bottom row of pixels, 4=no rotation

Erode ROIs: 0 [1 or more erodes one or more layer(s) of pixels from the outside of the ROI before conducting the analysis

Print Widths: 1 [0 means the widths of the individual subregions are not included in the results]

PolyFit: 0 [0 means there is no polynomial fitting to flatten the ROI. 1, 2, 3, 4... means a line, 2nd order polynomial (quadratic), 3rd order polynomial (cubic), 4th order polynomial is fitted to the ROI to flatten the ROI. Note: the ROI is flattened such that the topmost end of the ROI (in the image) ends up at the left side of the flatted ROI]

  • To load a dataset: drag and drop the folder with one dataset onto the main ImageJ window. When it asks to "Open all .. images .. as a stack", click Yes. f you are working with DIXON data, you will need to go to File > Open, navigate to the directory where the data are, press Ctrl+A to select all (or Apple+A I think on a mac) and then open all the images. Then, go to Image > Stack > Images to Stack, set your stack name, and then press OK.
  • Trace and ROI as described on the later slides. Press the letter "k" on the keyboard. If you want to visualise the output, change the setting for "Visualise Sub-regions" to "1"
  • All Results and ROIs are saved to the hard-drive to the sub-directories specified in Results Sub-directory and Roi results directory respectively.
  • The Results also get displayed in ImageJ's Results window.
  • You may now want to develop a method (e.g. in Excel) for copying and pasting the data from the Results window to enable sorting of your data (e.g. so you know which structure you are measuring).

Settings for analysis of different structures

  • Measuring muscles on axial scans: When analysing muscle on axial scans, usually you don't need the subregion data, so to ensure the plugin runs without generating too much data, the only setting that I would tweak is:

Sub-region Columns: 2

  • Measuring the lateral abdominals: For measuring the lateral abdominals, such as on the image here...

... we have implemented in the plugin a process that takes the region of interest traced and fits a polynomial to "flatten it" (the following image is a flattened internal oblique):

... and then the plugin pulls out the data of interest. The settings to tweak are:

Sub-region Rows: 1

Sub-region Columns: 3

Rotation: [no need to change this as when PolyFit is not 0, this is automatically set as setting "4", for no rotation]

PolyFit: 4 [this means a 4th order polynomial is fitted. A 3rd order probably suffices, a 2nd order generally won't]

For the data that gets outputted here, the "width" data will give you how long the muscle is (from left to right on the "flattened" image above; i.e. so if want to look at shortening) and the "height" data will give you the thickness of the muscle.

  • PLACEHOLDER: For measuring ...

...

Macros for different image types

  • When analysing muscle on axial DIXON scans, it is usually easiest to see the muscle borders on the "out of phase" image. My DIXON data for muscle are typically organised in the following order: Out of Phase Image, Water Image, In Phase Image, Fat Image. This macro (to be saved in Plugins > Macros > Startup Macros), assumes this order. The keyboard short cut is then j in this case:

// DIXON Analyser Macro (for muscle)

macro "DIXON_Muscle_ROIanalyse... [j]" {

run("ROI subregions");

run("ROI Export");

run("Draw", "slice");

run("Next Slice [>]");

run("ROI subregions");

run("ROI Export");

run("Next Slice [>]");

run("ROI subregions");

run("ROI Export");

run("Next Slice [>]");

run("ROI subregions");

run("ROI Export");

run("Next Slice [>]");

run("Select None");

}

  • If the "out of phase" image is the 4th image, you can use this:

// DIXON Analyser VB Axial DIXON. start with 04O

macro "DIXON_AxVB_start with 04O.. [j]" {

run("ROI subregions");

run("ROI Export");

run("Draw", "slice");

run("Previous Slice [<]");

run("ROI subregions");

run("ROI Export");

run("Previous Slice [<]");

run("ROI subregions");

run("ROI Export");

run("Previous Slice [<]");

run("ROI subregions");

run("ROI Export");

run("Next Slice [>]");

run("Next Slice [>]");

run("Next Slice [>]");

run("Next Slice [>]");

run("Next Slice [>]");

run("Next Slice [>]");

run("Next Slice [>]");

run("Select None");

}

Batch re-processing of DICOM images using existing ROIs

  • If you have already got a set of ROIs that you want to re-run over the DICOM images, you can run this as a macro in ImageJ.
  • The comments after the "//" in the macro will help you work out what is what.
  • You will need to need to tweak it for each kind of dataset you are working with.
  • The code assumes you have your DICOMs stored in a per-subject folder (e.g. S001_DIXON) under a base DICOM directory (e.g. MyDirName). A similar organisation without further subdirectories is assumed.
  • Save the macro to your computer and run it from ImageJ. It should be as simple as "File > Open". You an also paste it into a new macro "Plugins > New > Macro" and run it from there. Refer to https://imagej.nih.gov/ij/developer/macro/macros.html
  • The code is here