imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
473 stars 82 forks source link

ZProjector for Stack Image #275

Closed chandrasekarnarayana closed 1 year ago

chandrasekarnarayana commented 1 year ago

I am trying to ZProject an stack in average mode for all the frame. I used the Fiji Macro to record and identify the command But the command is not found or accessable from Pyimagej Screenshot from 2023-07-05 17-49-25

imp = ij.IJ.openImage("/media/cs/LaCie/Annotation/data/D/D1.tif");
imp = ij.ZProjector.run(imp,"avg");
ij.IJ.run(imp, "Specify...", "width=600 height=600 x=0 y=0 oval");
ij.IJ.run("Camera setup", "offset=1.7 isemgain=false photons2adu=1.1 pixelsize=69.0");
ij.IJ.run(imp, "Run analysis", "filter=[Wavelet filter (B-Spline)] scale=2.0 order=3 detector=[Local maximum] connectivity=8-neighbourhood threshold=2*std(Wave.F1) estimator=[PSF: Integrated Gaussian] sigma=0.2 fitradius=4 method=[Weighted Least squares] full_image_fitting=false mfaenabled=false renderer=[No Renderer]");
ij.IJ.run("Export results", "filepath=/media/cs/LaCie/Annotation/E/duplicate_c_trail.csv fileformat=[CSV (comma separated)] sigma=true intensity=true chi2=true offset=true saveprotocol=false x=true y=true bkgstd=true id=true uncertainty=true frame=true");
imp.close();
ctrueden commented 1 year ago

@chandrasekarnarayana Try importing the ZProjector class first:

import scyjava
ZProjector = scyjava.jimport("ij.plugin.ZProjector")
zproj_imp = ZProjector.run(imp, "avg")
chandrasekarnarayana commented 1 year ago

The following worked out. Thanks @ctrueden

import imagej
import scyjava

plugins_dir = '/home/cs/Downloads/fiji-linux64/Fiji.app/plugins'
scyjava.config.add_option(f'-Dplugins.dir={plugins_dir}')
ZProjector = scyjava.jimport("ij.plugin.ZProjector")
ij = imagej.init('/home/cs/Downloads/fiji-linux64/Fiji.app')