Hi,
We are trying to use ImageJ from Kepler Project. It allows to run macros. It seems that ImageJ return control to Kepler program immediately and independentlty of data processing. We need to implement a procedure with a lot of steps where every step is dependent on the data from previous one. It works good when the commands are in one macro, but it seems that ImageJ starts macro in separate thread and returns control. And if we are trying to put some parts of the proccess in a separate macros and satrt them one by one we get a mess. Is it possible to control this? Or in other words is it possible in any way to know that data processing in ImageJ is not finished yet? Or hang it until processing is finished? Thank you, Andrey. |
Hi Andrey,
I have similar ideas to use a combination of ImageJ macros and plugins to solve some image processing problems in another application. I already started to write most of the plugins and tested those on respective data files, however did not yet try to run those from the intended application and had not expected the behaviour of ImageJ you report (but I can reproduce your findings). Himm, this will add quite an inconvenience to my intended application. Clearly, one could work with some kind of "lock files", but I would find this rather clumsy, the application as is cannot check for those files and I would need to add another command including looping in the batch that runs the ImageJ macro..... If there is no trick yet (especially under Windows, maybe under Linux you can use some fancy process control script), could there be added another "batch" option that does not return control to the command line before ImageJ has finished processing? Joachim Wesner Andrii Savchenko <Andrii.Savchenko @KI.SE> An Gesendet von: [hidden email] ImageJ Interest Kopie Group <[hidden email]. Thema GOV> Macros in sequence. 19.10.2009 12:58 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> Hi, We are trying to use ImageJ from Kepler Project. It allows to run macros. It seems that ImageJ return control to Kepler program immediately and independentlty of data processing. We need to implement a procedure with a lot of steps where every step is dependent on the data from previous one. It works good when the commands are in one macro, but it seems that ImageJ starts macro in separate thread and returns control. And if we are trying to put some parts of the proccess in a separate macros and satrt them one by one we get a mess. Is it possible to control this? Or in other words is it possible in any way to know that data processing in ImageJ is not finished yet? Or hang it until processing is finished? Thank you, Andrey. ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Hi again,
I just reckon that this likely is not a "problem" of the imagej core ij.jar, but could/should be better "fixed" in the launcher ImageJ.exe (under Windows) and similar. Where do I find the source of this? I would like to take a look and try to add some fix (doing this I probably also could address another problem I mentioned some time ago that adding a "regular" woindows file path as an automatically generated argument from a BAT file fails because the backslashes are interpreted as control characters and removed, because they would need to be doubled) Sincerely Joachim Joachim Wesner <Joachim.Wesner@L EICA-MICROSYSTEMS An .COM> [hidden email] Gesendet von: Kopie ImageJ Interest Group Thema <[hidden email]. Antwort: Macros in sequence. GOV> 19.10.2009 15:28 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> Hi Andrey, I have similar ideas to use a combination of ImageJ macros and plugins to solve some image processing problems in another application. I already started to write most of the plugins and tested those on respective data files, however did not yet try to run those from the intended application and had not expected the behaviour of ImageJ you report (but I can reproduce your findings). Himm, this will add quite an inconvenience to my intended application. Clearly, one could work with some kind of "lock files", but I would find this rather clumsy, the application as is cannot check for those files and I would need to add another command including looping in the batch that runs the ImageJ macro..... If there is no trick yet (especially under Windows, maybe under Linux you can use some fancy process control script), could there be added another "batch" option that does not return control to the command line before ImageJ has finished processing? Joachim Wesner ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Joachim Wesner
With Linux, I use a bash script to run my ImageJ macro followed by a R
script on the results. It's nothing fancy but it works very well. Bash is also the shell used in the MacOSX console so it should work on a Mac too. The trick is to save the results in a .txt (not .xls) file that can be parsed from any other language I know of. Gabriel Lapointe, MSc. Laboratoire de Luc DesGroseillers, PhD. Pavillon Roger-Gaudry Local A-538 Département de biochimie Faculté de Médecine de l'Université de Montréal 2900 boul. Édouard-Montpetit, Montréal, Qc, H3T 1J4 Tel : (514) 343-6111 postes 5187, 5152, 5162 ou 1048 Fax : (514) 343-2210 [hidden email] Joachim Wesner wrote: > Hi Andrey, > > I have similar ideas to use a combination of ImageJ macros and plugins to > solve some > image processing problems in another application. I already started to > write most of the plugins > and tested those on respective data files, however did not yet try to run > those from the intended > application and had not expected the behaviour of ImageJ you report (but I > can reproduce your findings). > > Himm, this will add quite an inconvenience to my intended application. > Clearly, one could work > with some kind of "lock files", but I would find this rather clumsy, the > application as is cannot check for those > files and I would need to add another command including looping in the > batch that runs the ImageJ macro..... > > If there is no trick yet (especially under Windows, maybe under Linux you > can use some fancy process control script), > could there be added another "batch" option that does not return control to > the command line before ImageJ > has finished processing? > > > Joachim Wesner > > > > > Andrii Savchenko > <Andrii.Savchenko > @KI.SE> An > Gesendet von: [hidden email] > ImageJ Interest Kopie > Group > <[hidden email]. Thema > GOV> Macros in sequence. > > > 19.10.2009 12:58 > > > Bitte antworten > an > ImageJ Interest > Group > <[hidden email]. > GOV> > > > > > > > Hi, > > We are trying to use ImageJ from Kepler Project. It allows to run macros. > It seems that ImageJ return control to Kepler program immediately and > independentlty of data processing. We need to implement a procedure with a > lot of steps where every step is dependent on the data from previous one. > It works good when the commands are in one macro, but it seems that ImageJ > starts macro in separate thread and returns control. And if we are trying > to put some parts of the proccess in a separate macros and satrt them one > by one we get a mess. > Is it possible to control this? Or in other words is it possible in any > way to know that data processing in ImageJ is not finished yet? Or hang it > until processing is finished? > > Thank you, > > Andrey. > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > |
Hi,
On Mon, 19 Oct 2009, Gabriel Lapointe wrote: > With Linux, I use a bash script to run my ImageJ macro followed by a R > script on the results. It's nothing fancy but it works very well. Bash > is also the shell used in the MacOSX console so it should work on a Mac > too. The trick is to save the results in a .txt (not .xls) file that can > be parsed from any other language I know of. The .xls files ImageJ saves are nothing else than .csv files (actually, they are tab-separated, not comma-separated, if I remember correctly). Hth, Dscho |
Hi,
somehow I fear the original intention of this thread got lost.... The point IMHO is/was not to convert the input/output data to a suitable form that can be understood outside of ImageJ, but as Andrii already pointed out, a simple script that writes input data, starts ImageJ and tries to read back output data will likely fail, because ImageJ seems to get started as an independent process and depending on timing and processing speed, the shell script will already continue with the reader script before ImageJ has finished processing. (In Andrii case he even wanted to do several ImageJ processing steps in a row) So the question, is how to get ImageJ synchronized with a script (besides moving the responsability to the script itself, i.e. it would need to loop till the output is ready or some "lock file" is deleted or created.) Sincerely Joachim Johannes Schindelin <Johannes.Schinde An [hidden email]> [hidden email] Gesendet von: Kopie ImageJ Interest Group Thema <[hidden email]. Re: Antwort: Macros in sequence. GOV> 20.10.2009 03:35 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> Hi, On Mon, 19 Oct 2009, Gabriel Lapointe wrote: > With Linux, I use a bash script to run my ImageJ macro followed by a R > script on the results. It's nothing fancy but it works very well. Bash > is also the shell used in the MacOSX console so it should work on a Mac > too. The trick is to save the results in a .txt (not .xls) file that can > be parsed from any other language I know of. The .xls files ImageJ saves are nothing else than .csv files (actually, they are tab-separated, not comma-separated, if I remember correctly). Hth, Dscho ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Hi,
In my hand, ImageJ doesn't start as an independant process. Therefore I have to put a "run("Quit")" at the end of my macros to make it go on. I included one of my ImageJ launching script that read all the directories I want to process from a text file, perform a ImageJ macro il all of them, then when it is over a R script is launched and everything finishes by the computer sending me an email to tell me that everything is done or something crashed. Of course, in my case it's a serial process, I don't have enough RAM to be concerned by multi-threading the limiting, but embarrassingly parallel, ImageJ step. To do this someone would have to multi-thread the loop containing the ImageJ command. I admit that bash is probably not the best language to do this, as I'm unfamilliar with bash multi-threading capabilities. But someone could probably do it in python or java. As for my .txt instead of the .xls comment from my previous post, it's just that I had a problem once with a software that didn't recognized a tab separated text file with an .xls extention, it was always reading it as a corrupted MS Excel file. Renaming the files to .csv or .txt was solving the problem. Since then, I always change ImageJ default to .csv and never had any problem. Here is my script #!/bin/bash ## This is the master script. ## Edit accordingly # The base directory: dire=$(pwd) echo "The base directory is :" pwd # Amount of memory to use mem=6048 # ImageJ Variable to use macro="$dire/macro.imj" imagej=/media/Data/ImageJ/bin/ij.jar java=/usr/lib/jvm/java-6-sun/jre/bin/java javarun=/usr/lib/jvm/java-6-sun/lib/tools.jar plugins="$HOME/.ImageJ/plugins" # Reading the directories from a text files and creating a temporary list finfo="directory.txt" lines=$(cat $finfo | wc -l) cat $finfo > .tempa dinfo=$(head .tempa -n 1) # Loop ImageJ while there are unprocessed directories while [ -n "$dinfo" ] do cd $dinfo echo "processing: $(pwd)" xvfb-run -a $java -Dplugins.dir=$plugins -Xmx"$mem"m -cp $imagej:$javarun ij.ImageJ -run "Granule counter" cd $dire # remove the directory we just process from the temporary list lines=$(cat .tempa | wc -l) file=$(tail -n $(expr $lines - 1) .tempa) echo "$file" > .tempa dinfo=$(head .tempa -n 1) done rm .tempa # Start R R CMD BATCH StatsAndGraph.R # Send an email cat log | mail -s "Colocalisation test in $dire done" $USER #END OF CODE Gabriel Lapointe, MSc. Laboratoire de Luc DesGroseillers, PhD. Pavillon Roger-Gaudry Local A-538 Département de biochimie Faculté de Médecine de l'Université de Montréal 2900 boul. Édouard-Montpetit, Montréal, Qc, H3T 1J4 Tel : (514) 343-6111 postes 5187, 5152, 5162 ou 1048 Fax : (514) 343-2210 [hidden email] Joachim Wesner wrote: > Hi, > > somehow I fear the original intention of this thread got lost.... > > The point IMHO is/was not to convert the input/output data to a suitable > form that can be understood outside of ImageJ, > but as Andrii already pointed out, a simple script that writes input data, > starts ImageJ and tries to read back output data > will likely fail, because ImageJ seems to get started as an independent > process and depending on timing and processing > speed, the shell script will already continue with the reader script before > ImageJ has finished processing. > (In Andrii case he even wanted to do several ImageJ processing steps in a > row) > > So the question, is how to get ImageJ synchronized with a script (besides > moving the responsability to the script itself, i.e. it > would need to loop till the output is ready or some "lock file" is deleted > or created.) > > Sincerely > > Joachim > > > > > > Johannes > Schindelin > <Johannes.Schinde An > [hidden email]> [hidden email] > Gesendet von: Kopie > ImageJ Interest > Group Thema > <[hidden email]. Re: Antwort: Macros in sequence. > GOV> > > > 20.10.2009 03:35 > > > Bitte antworten > an > ImageJ Interest > Group > <[hidden email]. > GOV> > > > > > > > Hi, > > On Mon, 19 Oct 2009, Gabriel Lapointe wrote: > > >> With Linux, I use a bash script to run my ImageJ macro followed by a R >> script on the results. It's nothing fancy but it works very well. Bash >> is also the shell used in the MacOSX console so it should work on a Mac >> too. The trick is to save the results in a .txt (not .xls) file that can >> be parsed from any other language I know of. >> > > The .xls files ImageJ saves are nothing else than .csv files (actually, > they are tab-separated, not comma-separated, if I remember correctly). > > Hth, > Dscho > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > |
Free forum by Nabble | Edit this page |