Closed 54601 closed 6 months ago
I figured it out! If anyone's interested, it's: ij.py.from_java(ij.convert().convert(ij.ResultsTable.getResultsTable(), sj.jimport("org.scijava.table.Table")))
Is there any method to utilize roiManager() commends in python?
Try this
rois = ij.RoiManager.getRoiManager()
for roi_index in range(rois.getCount()):
rois.select(jimp, roi_index)
Try this
rois = ij.RoiManager.getRoiManager() for roi_index in range(rois.getCount()): rois.select(jimp, roi_index)
Thank you for this! It's most helpful indeed.
However, I still have a problem: adding 'add' to the Analyze particles command will crash the script:
run("Analyze Particles...", "size=2000-Infinity circularity=0.8-1.00 clear add composite slice");
Is there other way to add the results to RoiManger?
Hi @54601, sorry for the late response to this issue. Our team has been busy working on the SciJava ops project.
ij.py.from_java(ij.convert().convert(ij.ResultsTable.getResultsTable(), sj.jimport("org.scijava.table.Table")))
As you discovered, the way to get the ResultsTable
to something usable in Python as pandas
dataframe, you need to convert the ResultsTable
to a SciJava table. This is painful and I added a converter to make this easier here:
3bd99b858efd6758737eb8a1e6247b8f3e700988. I'm working to release a new version of pyimagej
soon.
Thank you for this! It's most helpful indeed. However, I still have a problem: adding 'add' to the Analyze particles command will crash the script: run("Analyze Particles...", "size=2000-Infinity circularity=0.8-1.00 clear add composite slice"); Is there other way to add the results to RoiManger?
That's weird! Is there an error output produced? Are you in headless
mode?
As you discovered, the way to get the
ResultsTable
to something usable in Python aspandas
dataframe, you need to convert theResultsTable
to a SciJava table. This is painful and I added a converter to make this easier here: 3bd99b8. I'm working to release a new version ofpyimagej
soon.
Thank you for your contribution to this project! This package has helped me tremendously.
Thank you for this! It's most helpful indeed. However, I still have a problem: adding 'add' to the Analyze particles command will crash the script: run("Analyze Particles...", "size=2000-Infinity circularity=0.8-1.00 clear add composite slice"); Is there other way to add the results to RoiManger?
That's weird! Is there an error output produced? Are you in
headless
mode?
That's a false alarm, sorry for that. I tried again this day and the problem couldn't be reproduced. Maybe it was a mistake on my side previously.
However, I really want to know how to get the boundaries for Rois, after I select them with rois.select(jimp, roi_index)
.
Thank you for your contribution to this project! This package has helped me tremendously.
Awesome! I'm glad that you've found pyimagej
helpful!
However, I really want to know how to get the boundaries for Rois, after I select them with rois.select(jimp, roi_index).
Once you have a ROI from the RoiManager
or the ImagePlus
itself you can print it's bounds with roi.getBounds().toString()
. Here's an example after loading the RoiManager
with a single free hand ROI:
# get the RoiManager
rm = ij.RoiManager.getRoiManager()
# get the first ROI
roi = rm.getRoi(0)
# print it's bounds
print(roi.getBounds().toString())
Which for my random blob I drew returned: java.awt.Rectangle[x=58,y=38,width=141,height=126]
Thank you for your contribution to this project! This package has helped me tremendously.
Awesome! I'm glad that you've found
pyimagej
helpful!However, I really want to know how to get the boundaries for Rois, after I select them with rois.select(jimp, roi_index).
Once you have a ROI from the
RoiManager
or theImagePlus
itself you can print it's bounds withroi.getBounds().toString()
. Here's an example after loading theRoiManager
with a single free hand ROI:# get the RoiManager rm = ij.RoiManager.getRoiManager() # get the first ROI roi = rm.getRoi(0) # print it's bounds print(roi.getBounds().toString())
Which for my random blob I drew returned:
java.awt.Rectangle[x=58,y=38,width=141,height=126]
Huge thanks! That totally works!
Great! I'm glad that was what you were looking for!
I want to get the list for the result of count particles. The document ended before hinting on how to acquire the results for further analysis.