Login  Register

Re: IJ.run command options defaults in plugin

Posted by Rasband, Wayne (NIH/NIMH) [E] on May 08, 2016; 5:13am
URL: http://imagej.273.s1.nabble.com/IJ-run-command-options-defaults-in-plugin-tp5016348p5016354.html

> On May 6, 2016, at 5:42 PM, jhonig2 <[hidden email]> wrote:
>
> Hello,
>
> I have written a plug-in (based on the Raw_File_Opener plug-in) that allows
> the user to open a *.raw file.
> In my case, I am trying to pre-populate the options image=unsigned 16-bit,
> width=1624, height=1234.
>
> In the plug-in, I have the statement
>
> IJ.run("Raw...", "open=[" + directory + fi.fileName + "] image=[16-bit
> Unsigned] width=1624 height=1234");
>
> When I run the plug-in, Import>Raw dialog box opens and the image type,
> width and height values are populated with whatever values had been entered
> manually, previously.
>
> However....when I click ok, my values are accepted (16-bit unsigned,
> width=1624, height=1234) and the plug-in works fine. Yet, when I run the
> plug-in again, those original, manually entered values appear in the
> Import>Raw dialog box.
>
> I would just like the Import>Raw dialog box to display the values that I
> think it should.

I do not know of a way to set the values displayed in the Import>Raw dialog but it’s not needed if the values are known. Here is a JavaScript example that opens a 1624x1234,16-bit unsigned raw file:

  width = 1624;
  height = 1234;
  od = new OpenDialog("Choose a Raw File", "");
  fi = new FileInfo();
  fi.directory = od.getDirectory();
  fi.fileName = od.getFileName();
  fi.fileFormat = fi.RAW;
  fi.fileType = FileInfo.GRAY16_UNSIGNED;
  fi.width = width;
  fi.height = height;
  fo = new FileOpener(fi);
  img = fo.open(false);
  if (img!=null)
     img.show();





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