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 |
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 |
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 |
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 |
Greetings Alex,
I do not seem to have this plugin, although, how I would proceed to resolve your issue is... Plugins>Utilities>Find Command... Allows you to find what ImageJ thinks the command string is. Generally I cheat and turn on recording Plugins>Macros>Record... and run the command that I intend to put in my java plugin. There is a selection for the language on the top of the recording window, albeit no Python. The Java code that will process your IJ.run or IJ.runPlugIn is available online, I usually google 'imagej java classname' (in this case IJ for classname) and the documentation and color coded source code is generally found. From a cursory look it seems as though your trying to use: /** Runs the specified plugin using the specified image. */ public static Object runPlugIn(ImagePlus imp, String className, String arg) so I assume that something like IJ.runPlugIn(imp3, 'plugin.Stitching_Pairwise', arguments); is what you are looking for. I suspect that you should be able to call the Stitching_Pairwise.run or its other methods directly, n.b., google imagej java Stitching_Pairwise. Enjoy, Fred On Wed, June 10, 2020 1:42 pm, Alex wrote: > > > 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 > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |