xp1632 / VPE_IP

0 stars 0 forks source link

Commandline_of calling ImageJ_keeping one background process #60

Open xp1632 opened 5 months ago

xp1632 commented 5 months ago

Marco file

!ImageJ --headless --console -macro path_to_your_macro.ijm

This command runs ImageJ in headless mode (without a GUI), opens the console for input and output, and runs a macro from a file. Replace path_to_your_macro.ijm with the path to your ImageJ macro file.

Please note that this requires ImageJ to be installed on your system and the ImageJ command to be available in your system's PATH.


Sole function, the ones that supports headless mode are supported

If you want to call ImageJ functions directly from the command line without using a macro, you can use the --run option followed by the name of the function and its arguments. Here's an example:

!ImageJ --headless --console --run "YourFunction arg1 arg2"

Replace YourFunction with the name of the ImageJ function you want to run, and arg1 arg2 with the arguments to the function.

Please note that not all ImageJ functions may be available or work correctly from the command line, especially those that require a GUI.

xp1632 commented 5 months ago

To keep one ImageJ process running in background:

Running ImageJ from the command line typically starts a new instance of ImageJ each time, which is separate from any existing instances.

  1. Write a java program that creates an instance of Image and
  2. Start a socket sever for inter-process communication (IPC) that listens
    • for incoming connections and executes commands it recieves
  3. Runs this java in the background to start the imageJ instance and the IPC server
  4. In the Python code, connect to the IPC server and send commands to it.
    • These commands will be executed by the ImageJ instance


xp1632 commented 5 months ago

Final Solution