Code covered by the BSD License  

Highlights from
Import ImageJ ROIs

5.0

5.0 | 1 rating Rate this file 15 Downloads (last 30 days) File Size: 4.7 KB File ID: #32479
image thumbnail

Import ImageJ ROIs

by Dylan Muir

 

09 Aug 2011 (Updated 03 Jul 2012)

Read ROIs and ROI sets saved from ImageJ into MATLAB, without java.

| Watch this File

File Information
Description

ReadImageJROI - FUNCTION Read an ImageJ ROI into a MATLAB structure

Usage:
[sROI] = ReadImageJROI(strFilename)
[cvsROIs] = ReadImageJROI(cstrFilenames)
[cvsROIs] = ReadImageJROI(strROIArchiveFilename)

This function reads the ImageJ binary ROI file format.

'strFilename' is the full path to a '.roi' file. A list of ROI files can be passed as a cell array of filenames, in 'cstrFilenames'. An ImageJ ROI archive can be access by providing a '.zip' filename in 'strROIArchiveFilename'. Single ROIs are returned as matlab structures, with variable fields depending on the ROI type. Multiple ROIs are returned as a cell array of ROI structures.

The field '.strName' is guaranteed to exist, and contains the ROI name (the filename minus '.roi').

The field '.strType' is guaranteed to exist, and defines the ROI type: {'Rectangle', 'Oval', Line', 'Polygon', 'Freehand', 'Traced', 'PolyLine', 'FreeLine', 'Angle', 'Point', 'NoROI'}.

The field '.vnRectBounds' is guaranteed to exist, and defines the rectangular bounds of the ROI: ['nTop', 'nLeft', 'nBottom', 'nRight'].

The field '.nVersion' is guaranteed to exist, and defines the version number of the ROI format.

Other structure fields are described in the function help text.

Hint:
ROIs returned by this function can be converted into useful regions using the bwconncomp function, but this requires some extra work to draw each ROI into a matrix.

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File  
Everyone's Tags
data import(2), image processing, imagej
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
26 Apr 2013 Zachary

Nevermind! Figured out the problem. I altered slightly how the transformation was done in respect to vnRectBounds and it seems to work flawlessly now!

Thanks for the script!

14 Mar 2013 lobster soup

Can you let me know how I can access the xy coordinates of the roi so I can draw it?
when I say
[roilist] = ReadImageJROI(roiDirectoryCell)

I get a struct within a cell. The only information i can find to reconstruct the roi is vnRectBounds, and I don't understand how to make use of it.
The roi I'm trying to draw is of type 'oval'. could you please explain this in some more detail?
thanks!

10 Aug 2011 Dylan Muir

Thanks for the comment; I must have that warning switched off! I'll fix it next version.

10 Aug 2011 Jean-Yves Tinevez

Does what it says, and does it right. The function is well documented and cover all ROI types well.
There is just a minor warning coming from line 157, because of the capitalized FILESEP...

10 Aug 2011 Jean-Yves Tinevez  
Updates
16 Aug 2011

Fixed the warning about capitalised FILESEP.

16 Aug 2011

Updated screenshot

29 Aug 2011

Fixed a bug reported by Benjamin Ricca

07 Nov 2011

Updated description

29 Jun 2012

ROI order is now preserved

03 Jul 2012

Different way of reading zip file contents guarantees that the order of ROIs is always preserved

Contact us