Converting ImageJ ROI to R spatstat data doesn't work

549 Views Asked by At

I tried to use the RImageJROI package from David C Sterratt to transfer multiple ROIs into R and convert them to Spatstat.

This is a minimal example of my R-code

library(RImageJROI)
ROI = read.ijzip("path/ROI.zip")
spat.ROI = ij2spatstat(ROI)

Reading the zip-file works well but when I run the converting command I get the following error:

Error in conv.fun(k, window = window, unitname = unitname, scale = scale, : object 'out' not found

Attached there is a file for creating a ROI.zip -file which causes the error after processing it in ImageJ with:

    run("Analyze Particles...", "add");
roiManager("Save", "Path\\Roi.zip");

Simple picture producing 2 ROIs

Is there a way to get RImageJROI working, am I missing something obvious, or does anyone know another solution for my project?

2

There are 2 best solutions below

0
On

You can use Bio7 for that with has special methods to transfer different ImageJ ROI's and image data to R.

Some methods where especially designed for spatstat after a great spatstat tutorial on the R conference in 2015.

Here a link to some ImageJ spatstat notes and simple scripts:

http://bio7.org/?p=2618

https://github.com/Bio7/Bio7_Workshop

Here some video tutorials to transfer ROI data:

3D Point Pattern: https://youtu.be/DmfSASgJa_g

Line Segments: https://youtu.be/EPan7kibYpo

Polygons: https://youtu.be/bS_2ejOt7Tg

Point Patterns: https://youtu.be/7t5V2o8jFJw

Particle Measurments: https://youtu.be/7t5V2o8jFJw

Georeferenced Polygons (which can be converted to spatstat objects):

https://youtu.be/P2NflfBB2Tg

1
On

I got the same error message. I found this to work after looking inside the ij2spatstat function.

library(RImageJROI)
library(spatstat)

roi <- read.ijroi("RoiSet/0071-0081.roi") # path to single ROI
poly <- list(x = roi$coords[,2], y = roi$coords[,1])
out <- owin(poly = poly)

plot(out)

You can put this inside a loop to transform every ROI in a directory.