I’m new here, but been using macro programming for a while. I got an unexpected error while programatically creating a new text window [using run(“Text Window…”,"name=…] using .txt as name suffix. It looks like it creates an additional macro with .ijm suffix instead.
This issue relates to version 1.51n of ImageJ provided by Fiji. I’ve got no such issue using version 1.49v from NIH.
I’ve got a workaround by removing the .txt suffix from the window name which it is oddly renamed with the .txt suffix automatically appended as soon as you get it saved by using the [saveAs(“Text”,…] command within the macro. That was expected as it comes to the saved file name but NOT to the window name.
It looks like a less than desired behaviour to me. Wondering if someone else got the same kind of trouble and a more interesting workaround. Thanks for all.
Dear Herbie, thanks for your returns. I just followed your suggestions, and got interesting results.
By suppressing the remainder statements of the run command (name and so on), I surprisingly (in a negative sense) got the same issue under 1.51n, the only difference being I got a guide named “Untitled.ijm.ijm” instead - bad…
With 1.49v, I got a real text window named “Untitled.txt” under 1.49v (good anyway). Note that in this case, I did not save anything, only ran the run(“Text Window…”) command and still got the .txt suffix anyway which is not bad at all.
I also tried run(“Text Window”) instead of run(“Text Window…”) with the latter opening a dialog box asking me for the name, window size and a checkbox for menu (the former doesn’t ask for anything - just goes for it).
Right now, I can’t help but think ImageJ 1.49v is a charm, and 1.51n sucks - at least regarding this issue. Thanks again!
I think this might be “intended behavior”, as in Fiji, the legacy text editor (that doesn’t support syntax highlighting and only supports a limited subset of the available scripting languages) is supposed to be replaced by the more feature-rich script editor.
So it might rather be considered a bug that the “old” text window still opens when no extension is provided, because it leads to this unfortunate confusion you experienced.
Is there a reason why you still need the simple text window? I.e., is there anything you can’t do with the script editor that forces you to require the legacy text window? In this case, it would be good to know your use case, as the behavior of the script editor could be improved accordingly. (The development of open source software depends on community feedback, so thanks for bringing this up.)
I see your point about “intended behaviour”. I got stuck with the error message from my previously written macros, making them not compatible with Fiji.
It’s puzzling for me that they give rise to a double suffixed “Untitled.ijm.ijm” guide on the script editor instead of a fresh “Untitled.txt” window.
Back to the problem, I am most probably missing a proper way of putting text out using Fiji. My needs are rather simple: exporting measurements results to a spreadsheet. Not the regular results from the ROI manager; just strings and numbers (converted to string using “d2s”) generated within the macro.
After creating a fresh text window, I use several “print” commands to fill it with the desired output to be imported by the spreadsheet. It just didn’t work out with version 1.51n. Happily, it did OK with the non-Fiji version 1.51q (thanks, Wayne!)
Provided I discover a better way of overcoming this, I may give Fiji a second try. Thank you for the support!
Sorry to hear about your frustration. Rest assured that the ImageJ and Fiji developers try to be fully backwards-compatible, but it can still happen that some things break as they cannot be aware of all possible use cases.
Fiji (and with it, ImageJ2) has a lot of advantages over ImageJ 1.x, the updater and full scripting support being only two of them.
Yes, the double .ijm suffix can be a little annoying, it’s a separate issue that has been around for while, and none of the ImageJ developers has taken time to fix it, probably because of more important priorities. If you agree it should be fixed, and don’t want this issue to be forgotten by the developers, you can help by creating a new issue in the script-editor repository.
Yes, I also think that Notepad++ is an essential tool. Nevertheless, inside ImageJ I do prefer the script editor, as you can run your ImageJ scripts right from within the editor (without the need to save them as files first) while also having proper syntax highlighting for all the supported languages (IJ1 Macro and others).
I have no reason to doubt it - only resentful of my own lack of skills!..
I think it can be worthwhile!
I’ll definitely try it!
At this point of my work, ImageJ 1 macros have already proved to be useful enough to make me feel greatly indebted to them, thanks to the rich built-in functions library. Of course, it would be even greater if it could handle arrays with dimension greater than 1. Should ImageJ 2 be able of doing it?
I can’t be thankful enough for all your invaluable help. Regards,
I definitely got where I wanted by using your most valuable second advice (“using the print function to directly write to a file”). Better yet, I was able to merge results from multiple analysis (multiple executions) by using the command File.append instead of File.open (it works with a preexisting file that can even be an empty file previously created by Notepad, for instance). I am absolutely thankful.