Login  Register

Re: Calling Pairwise Stitch plugin from a script

Posted by Alex-2 on Jun 10, 2020; 6:42pm
URL: http://imagej.273.s1.nabble.com/Calling-Pairwise-Stitch-plugin-from-a-script-tp5023466p5023478.html

 

Fred, 
Thanks ... 

From what I can tell the IJ.run takes a string that is a command (https://imagej.nih.gov/ij/developer/api/ij/IJ.html#run-ij.ImagePlus-java.lang.String-java.lang.String-), where IJ.runPlugIn takes a string that is a className (https://imagej.nih.gov/ij/developer/api/ij/IJ.html#runPlugIn-ij.ImagePlus-java.lang.String-java.lang.String-.  
I'll give the string formatting a try per your suggestion.  What name do you suggest using other than the title for the imp objects?
Alex




    On Wednesday, June 10, 2020, 11:30:29 AM PDT, Fred Damen <[hidden email]> wrote:  
 
 Greetings,

I do not use Python but...

You refer to the name of the plugin slightly differently in each case, the
name needs to pass a comparison to be considered found.

String in the argument parameter need to be enclosed in [], especially if
they include spaces.

I suspect that the image titles are not the variable names. Usually some
form of the file name.

Fred



On Wed, June 10, 2020 1:05 pm, Alex wrote:

>  I'm getting closer but still not there yet ... 
> In the FIJI script editor I can do 
>
> from ij import IJ
>
> import ij.plugin
>
> imp1 = IJ.openImage('/path/to/composite0.tif')
>
> imp2 = IJ.openImage('/path/to/composite1.tif')
>
> imp3 = IJ.createImage("Stitched","RGB",1,1,1)
>
> IJ.run(imp3, "Pairwise stitching", "first_image=" + imp1.getTitle() + "
> second_image=" + imp2.getTitle() + " fusion_method=[Linear Blending]
> fused_image=result.tif check_peaks=20 ignore display_fusion
> compute_overlap subpixel_accuracy x=-1056.3646 y=-5.4877
> registration_channel_image_1=[Only channel 1]
> registration_channel_image_2=[Only channel 1]")
>
> That works.  However, in my IDE IJ.run returns
>
> Unrecognized command: "Pairwise stitching"
>
> So I'm trying 
> from ij import IJ
> import ij.plugin
>
> imp1 =
> IJ.openImage('/Users/alex/Desktop/test_files/D12/merged/composite0.tif')
>
>
> imp2 =
> IJ.openImage('/Users/alex/Desktop/test_files/D12/merged/composite1.tif')
>
>
> imp3 = IJ.createImage("Stitched","RGB",1,1,1)
> IJ.runPlugIn('plugin.Stitching_Pairwise', imp3.getTitle(),
>              'first_image=' + imp1.getTitle() +
>              ' second_image=' + imp2.getTitle() +
>              ' fusion_method=[Linear Blending]' +
>              ' fused_image=result.tif' +
>              ' check_peaks=20' +
>              ' ignore display_fusion' +
>              ' compute_overlap' +
>              ' subpixel_accuracy' +
>              ' x=-1056.3646 y=-5.4877' +
>              ' registration_channel_image_1=[Only channel 1]' +
>              ' registration_channel_image_2=[Only channel 1]')
>
> This seems to execute but the result is not in imp3.
> Any thoughts would be greatly appreciated.
>
>
>
>
>
>
>
>    On Wednesday, June 10, 2020, 01:04:28 AM PDT, Alex
> <[hidden email]> wrote:
>
>  I'm trying to figure out the syntax for calling the Pairwise Stitch
> plugin from a Python Script.
> I can get the plugin to react but I can't figure out the syntax for the
> input arguments.  I tired the macro recorder but its hints don't seem to
> be helpful.
> I've tried: 
> imp1 = IJ.openImage('/path/to/image1.tif')
> imp2 =
> IJ.openImage('/path/to/image2.tif')IJ.runPlugIn('plugin.Stitching_Pairwise',
> 'imp1', 'imp2')
> That doesn't complain about argument 1 not being a string or less than 2
> images being open, but I can't figure out how to pass the additional input
> arguments to setup the plugin, or how to return the result.
> Any help would be greatly appreciated.
> ThanksAlex
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
 

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html