Use ilastik as a Fiji plugin and OMERO¶
In this section, we will show how to use the ilastik user interface to
perform segmentations on multi-z images stored in OMERO. The connection
between OMERO and ilastik is facilitated via Fiji, for which both OMERO
and ilastik have plugins. The segmentation steps in this part are
recorded and saved in the form of an
ilp file in ilastik (ilastik
ilp file is used later for the scripting workflow.
We will show:
How to manually open images from OMERO in ilastik using the Fiji plugin for OMERO and Fiji plugin for ilastik.
How to segment the multi-z images in ilastik and produce an ilastik Project (
ilpfile) recording the steps.
How to save the results of the segmentation (ROIs and Probability maps) in OMERO, using the manual workflow and Fiji.
How to run a script in Fiji, consuming the
ilpfile and running the segmentation of the images coming from an OMERO Dataset, saving the ROIs on the original images in OMERO.
How to manually classify images.
ilastik has been installed on the local machine. See https://www.ilastik.org/ for details.
ilastik plugin for Fiji installation instructions
Start Fiji. Update it (
Help > Update ImageJ).
Manage Update Sitescheck the checkbox next to the “ilastik” site.
After the update was successful, restart your Fiji.
The new ilastik menu item should be under Plugins menu.
Note: The ilastik menu item might be the last in the Plugins dropdown, not necessarily alphabetically ordered.
OMERO plugin for Fiji installation instructions
For installation instructions, go to Fiji installation.
Images from IDR idr0062.
Manual training of z-stack segmentation in ilastik¶
Open Fiji, go to
Plugins > OMERO > Connectto OMERO and connect to OMERO.server provided using the credentials provided.
Find the idr0062 Project, the Blastocysts Dataset, open the first image in Fiji.
After image has opened in Fiji, go to
Plugins > ilastik > Export HDF5. The ilastik menu item might be the last in the Plugins dropdown, not necessarily alphabetically ordered.
Select a local directory to export to and save the image locally as an
Repeat this step with several images from the Blastocysts Dataset of idr0062.
Save a new Project in ilastik.
Still in ilastik, open the image you saved as
.h5in previous steps above (central pane,
Three views will open,
yz. You can explore the orthogonal views by clicking onto the checkbox in bottom right corner.
In Left-hand pane, click
Feature Selection. Select all available features.
You can explore the features at the bottom left corner, but this takes time.
Click on the
Trainingharmonica in the Left-hand pane.
The training UI comes in left-hand pane with two labels already pre-defined by default.
Select the first label, and by drawing LINES into the images, select a couple of cells in all three views.
Select the second label, and again drawing lines, select some background (also select the narrow
channelsbetween two almost adjacent cells as
bckgr(draw a line through them).
Click on the
Live Updatebutton - this will take time, as the image has a large number of planes.
Add new lines on cells which are too dim to be selected.
Live Update.... Repeat.
Suggest Featuresbutton (to the left of
A new UI window will open.
Run Feature Selectionin the left-hand pane of this new window. This will take time.
Select Feature Setbutton in the bottom middle of the window.
Suggest Featureswindow will close on this and you are back in the main ilastik window.
Toggle the images produced visible or not using the
eyeicons and the rendering settings of the particular images in the list in bottom-left corner. Below is an example of viewing the
Segmentation Label 1and
Segmentation Label 2layers viewable, the other layers (e.g.
Raw data) are toggled invisible.
Add new lines if some segmentation still does not look right.
Click on the
Prediction Exportharmonica tab. In this tab, we will prepare the parameters of the exported images only, and will do the exporting itself later using the
Prediction Exportharmonica, select the features to be exported in the
Sourcedropdown menu in the left-hand pane. Export sequentially
Simple Segmentationfor all three images you opened from OMERO via Fiji, using the
Batch processingharmonica tab, see below.
First, start with selecting
simple Segmentationin the
Choose Export Image Settings, select the
Convert to data Typeparameter to be
floating 32 bit. The files will be exported into the folder where the original images were, unless you choose otherwise.By default, the export format is HDF5 (file extension
Now, select in the left-hand pane the harmonica
Batch processing. In the centre top row of the view, click on
Select Raw Data Files.... Select all the three raw
.h5files on your local machine, including the one you have just trained your pixel classification on.
Click onto the
Process all data filesbutton in the left-hand pane.
This will create three
.h5files in the folder you have chosen in the
Choose Export Image Settingswindow (by default, these files will be placed in the folder where your raw data exports from OMERO are), the files will be named
Prediction Exportharmonica, select the
Probabilitiesparameter in the
Sourcedropdown. Go to the
Batch processingharmonica and click onto the
Process all data filesbutton in the left-hand pane. This will create another three
.h5files in the local folder, named
Manual creation of ROIs in Fiji based on segmentations from ilastik and saving the ROIs to OMERO¶
Go to Fiji,
Plugins > Ilastik > Import...
Browse to one of the “…_Simple Segmentation.h5” files which was created in ilastik in previous step and set the “Axis Order” to tzyxc (this might be the default for you). Do not check the checkbox
Apply LUT. Click
The 3D image will open in Fiji. Select
Image > Adjust > Brightness and Contrast. Adjust the
maxslider to the left, until you see the image grow grey (it is probably black just after opening).
Note: Because in ilastik, the
Simple Segmentatio` images have the values of 2 where there is an object and 1 for Background, we need to invert the image for Object Analysis in Fiji. The object analysis (done by the ``Analyze particlesplugin) is done in order to create ROIs which can be saved to OMERO.
Image > 8 bit. This will convert the values in the image into either 0 (cells) or 255 (background).
Edit > Invert. This is needed for the subsequent
Analyze particlesplugin - white objects on black background.
Analysis > Analyze Particles.
OKand in the next dialog answer
Plugins > OMERO > Save image(s)to OMERO. In the importer dialog, select the target Project and Dataset in OMERO or choose a new one.
This will import the
Simple segmentationimage into OMERO with the ROIs from Fiji on it and the contents of the Results table will be attached to this new image.
In order to have the ROIs from Fiji also on the original, raw image in OMERO.
Do not close the ROI Manager and the Results table.
Open the original raw image from OMERO into Fiji.
Click on the opened image.
Plugins > OMERO > Save ROI(s)to OMERO (alternatively, you can re-run the analysis in Fiji by clicking on
Measurein the ROI manager of Fiji to produce a new Results table).
In the new dialog, select a name for your results table which will be attached now to the original image.
ROIs and results will be now added to the original, raw image in OMERO
Repeat this workflow with the
...Probabilities.hfiles. Also, attach the ilastik project itself to the Dataset containing original data in OMERO.
Manual workflow of Object classification on z-stacks in ilastik¶
Start ilastik, choose the
Object classification with Prediction mapsoption and create a new Project and save it.
Select in the
Raw datatab the raw image stored locally and in the
Prediction mapstab the prediction map which you saved from the
Pixel classificationmodule for this image previously.
Threshold and Size filterharmonica in the left-hand pane. This step discerns the objects form background by means of thresholding (note that the “Prediction maps” values are between 0 and 1, where 1 is 100% probability that the pixel is a cell, 0 is a 100% probability that the pixel is backgr.) The other parameter to specify the object except threshold in this tab is size of the object.
0.5(if the probability of a pixel is higher than 0.5, then it is deemed to be a cell)
Leave the rest of the parameters at default and click
A new image will be added to the stack at bottom left called
Final output. The objects are displayed on it in color coding. Again, you can toggle the images visible and change intensities in bottom left corner.
Object Feature Selectionharmonica and click on the button
In the new window, click on
All excl. Locationbutton to select almost all features.
Click on the
Label classesharmonica, click on the yellow label (Label 1) and select all the cells in all three orthogonal views images.
Object information exportharmonica.
Sourcedropdown menu, export sequentially
Configure Feature Table Exportbutton in the left-hand pane and configure the location of the exported Also, changing the export format of the table in the
Formatdropdown menu, export sequentially the table as HDF as well as CSV format.
Featuresharmonica, click the
Allbutton to export all features.
Back in the main ilastik interface, click
Export All(repeat as necessary to export all formats of the images and the two formats of the export table).
Save the Project.
Import the CSV to OMERO, as well as the Probabilities.
Make an OMERO.table out of the CSV and attach it on the Project in OMERO. This can be done using populate_metadata.py plugin or from scratch using the extended groovy script from Fiji.