Login  Register

Re: Fiji/ImageJ Headless if not in path?

Posted by ctrueden on Apr 23, 2015; 10:16pm
URL: http://imagej.273.s1.nabble.com/Fiji-ImageJ-Headless-if-not-in-path-tp5012586p5012590.html

Hi Adam,

> Is there a version of fiji on MAC that would install itself to the
> system path?

Sorry, I don't understand the question. Even if you include the ImageJ
launcher's directory on the system path, it still wouldn't be enough, since
the executable file name differs across OSes.

Given a path to a Fiji.app directory, your Python code could synthesize the
correct launcher to use, similar to the shell script I linked -- but in
Python, of course.

Another option would be to make it an installation requirement for users to
symlink "fiji" somewhere on their path, so that your Python code doesn't
need to worry about it.

> is everyone using this workaround or am I using the wrong version of
> fiji or something?

I don't think many people call ImageJ from Python. Usually it is the other
way around: call Python (or Jython) from ImageJ:

* http://imagej.net/Python
* https://github.com/scijava/scripting-cpython
* https://github.com/scijava/scripting-jython

Someone else did just ask about this on StackOverflow, though:
* http://stackoverflow.com/q/29749687/1207769

Regards,
Curtis


On Thu, Apr 23, 2015 at 4:11 PM, Adam Hughes <[hidden email]> wrote:

> Thanks.  Is there a version of fiji on MAC that would install itself to the
> system path?  I mean, is everyone using this workaround or am I using the
> wrong version of fiji or something?
>
> On Thu, Apr 23, 2015 at 4:44 PM, Curtis Rueden <[hidden email]> wrote:
>
> > Hi Adam,
> >
> > > Does anyone know how to configure a Mac and/or Ubuntu system path so
> > > that we could just run fiji from any terminal?
> >
> > The issue is complicated by the fact that the launcher executable is
> named
> > differently for every platform.
> >
> > Personally, I work around it via the following shell script:
> > *
> >
> >
> https://github.com/imagej/imagej-omero/blob/imagej-omero-0.2.1/bin/run-class
> >
> > Alternately, the ImageJ.sh script (
> > https://github.com/imagej/imagej/blob/imagej-2.0.0-rc-29/bin/ImageJ.sh)
> > tries very hard to launch ImageJ without using any launcher executable.
> In
> > that way, you can run ImageJ on platforms for which no launcher has been
> > compiled, such as the Raspberry Pi.
> >
> > HTH,
> > Curtis
> >
> > On Thu, Apr 23, 2015 at 3:32 PM, Adam Hughes <[hidden email]>
> > wrote:
> >
> > > Hi,
> > >
> > > I'm trying to run a fiji macro in headless mode through python.  I'm on
> > > ubuntu, but also need to do this on a Mac.  I've downloaded fiji from
> > > source, and can doubleclick the icon to launch the application fine.
> The
> > > icon refers to the file:
> > >
> > > ~/Fiji.app/ImageJ2.desktop
> > >
> > > However, to use Fiji in headless mode, the guides imply that I want to
> do
> > > this:
> > >
> > >  ImageJ --headless -macro path-to-Macro.ijm
> > >
> > > Or
> > >
> > >  fiji --headless -macro path-to-Macro.ijm
> > >
> > > However, fiji and ImageJ are not in python.  So this command doesn't
> > work.
> > > Does anyone know how to configure a Mac and/or Ubuntu system path so
> that
> > > we could just run fiji from any terminal?  At the end of the day, my
> > python
> > > function looks like this (currently not working):
> > >
> > > def IJwatershed(bw_image):
> > >     imsave('fooing', bw_image)
> > >     macro_file = 'Watershed.imj'
> > >    * path_to_fiji* = '/home/glue/Desktop/Fiji.app/ImageJ2.desktop'
> > >     command = "%s --headless %s" % (path_to_fiji, macro_file)
> > >     with open('foo', 'w') as dnull:
> > >         p = subprocess.call(command, shell=False)#
> > stderr=subprocess.PIPE)
> > >
> > > And it seems to not work because of my *path_to_fiji *not being
> > understood.
> > >
> > > --
> > > 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