tinevez / TrackMate-extras

Some extra modules for TrackMate
GNU General Public License v3.0
1 stars 4 forks source link

Add exporting of spots to ellipse ROIs #4

Open stelfrich opened 6 years ago

stelfrich commented 6 years ago

This PR adds functionality to export Spots to ellipse ROIs to the ROI Manager. ROIs are not assigned to any channel if the input was a hyperstack.

stelfrich commented 6 years ago

@tinevez I fixed the handling of calibrated images!

stelfrich commented 6 years ago

Also fixed a weird issue with adding ROIs to the ROI Manager (see http://forum.imagej.net/t/incorrect-positioning-of-roi-when-adding-to-roi-manger-via-script/9647) thanks to @lacan!

stelfrich commented 6 years ago

Check if my hack works for you as well.

The current position of the active ImagePlus also overrides a position set with roi.setPosition(pos). So I guess the hack doesn't really work, if that's the issue you wanted to solve. The root cause for this is how Rois are added to the RoiManager. If you want to add them to an Overlay, roi.setPosition(...) works perfectly fine.

How should we proceed?

tinevez commented 6 years ago

Arrrh it's not so cool. I would like to have a way to create ROIs properly set to the right t,z,c position without relying on an ImagePlus. Any chance you could contact Wayne about this?

stelfrich commented 6 years ago

I would like to have a way to create ROIs properly set to the right t,z,c position without relying on an ImagePlus.

I have investigated a little more. There is a method roiManager.add( ImagePlus, Roi, int ); that does not set the position according to the active ImagePlus and uses the Rois position instead. The issue here, however, is the last argument n that is used to determine the name of the Roi when added to the RoiManager. You can do roiManager.add( null, roi, -1 ); which will generate names based on the Roi's x and y position ("YYYY-XXXX"). That, however, are usually not the names that you get with a (hyper)stack because the names are prefixed with the stack position ("PPPP-YYYY-XXXX"). In order to compute a stack position you need the ImagePlus for its dimensions...

TL;DR: I could use roiManager.add( null, roi, -1 ); but that will generate names of the form "YYYY-XXXX". What do you think?