When saving an image in "text" format, how are Locale settings determined? Are they inherited
from the local machine's global settings? Or, is it possible to manipulate them within ImageJ? My question is motivated by collaborations involving USA and German participants. Occasionally, I need to run ImageJ on a USA-centric machine, but would prefer to generate German style output. The specific issue is the difference between '.' and ',' in the formatting of floating point pixel values. When I write Java plugins, I set the Locale directly, and can control this - but I'd prefer to use the Save As/text facility, if possible. I'd like to do this without switching the Locale for every other application running on my laptop! I suppose I could just write my own SaveAsGermanText plugin - but that seems like overkill. A small side question: I just found SaveAs/text. While not my first choice of image representation, I can see how it can be useful in some contexts, and I'd like to understand what can be done with it. In particular, how do I read back a .txt file and get an image? [and then, of course...can I deal with multiple formats - the '.' vs ',' issue, again] -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kenneth,
both the File>Import Text Image and File>Save As>Text Image always use decimal points (not commas), irrespective of the locale. The code is in ij.plugin.TextReader and ij.io.TextEncoder, respectively. ImageJ also uses decimal points to save numbers in tables, and commas (not semicolons) as separators in CSV files, irrespective of the locale. I consider this quite fortunate since most scientific software does it like this. [Many people in the European scientific community, including me, use the English version of the operating system and software to avoid such problems. This also avoids badly translated text in menus etc...] In any case, changing all of ImageJ to consistently format and accept numbers according to the current locale would be impossible. The macro language must have decimal points (for compatibility with existing code). Then e.g. a curve fit equation (macro language) would have decimal points in numbers, but the fit parameters would have commas? It would be a mess, and many macros and plugins would not work any more. But I am aware that it can be a problem for importing .sv or txt files into programs like Excel etc. - some programs use their own settings for the number format, others the system-wide settings of the decimal point/comma. Some versions of Excel let you decide whether to use the system decimal separator or a custom one in the advanced options. If your collaboration partners really need decimal commas, you need some conversion, e.g. https://stackoverflow.com/questions/39954541/how-to-replace-dots-with-commas-in-multiple-csv-files Michael ________________________________________________________________ On 18/10/18 19:38, Kenneth Sloan wrote: > When saving an image in "text" format, how are Locale settings determined? Are they inherited > from the local machine's global settings? Or, is it possible to manipulate them within ImageJ? > > My question is motivated by collaborations involving USA and German participants. Occasionally, > I need to run ImageJ on a USA-centric machine, but would prefer to generate German style output. > > The specific issue is the difference between '.' and ',' in the formatting of floating point > pixel values. > > When I write Java plugins, I set the Locale directly, and can control this - but I'd prefer to > use the Save As/text facility, if possible. I'd like to do this without switching the Locale for > every other application running on my laptop! > > I suppose I could just write my own SaveAsGermanText plugin - but that seems like overkill. > > A small side question: I just found SaveAs/text. While not my first choice of image representation, > I can see how it can be useful in some contexts, and I'd like to understand what can be done with it. > In particular, how do I read back a .txt file and get an image? > [and then, of course...can I deal with multiple formats - the '.' vs ',' issue, again] > > -- > Kenneth Sloan > [hidden email] > Vision is the art of seeing what is invisible to others. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks for the authoritative reply.
It is, of course, not a problem to write a custom export version. I just wanted to make sure I wasn't missing something obvious that had already been done. I agree that it's too much work to make ImageJ Locale-compliant across the board. I'll probably try to convince my colleagues to accept the format produced by File>Save As>Text Image. In practice, I haven't had too much pushback when using the USA Locale, but recently I started to see problems with .csv files - so I have started to pay attention to Locale in my new plugin development. The main issue with .csv files is the conflict between ',' as a field separator and as a decimal separator. Come to think of it, most of my recent problems have been with .csv files produced with German formatting *and* a German character set. Why can't everyone just use American English, as God intended? -- Kenneth Sloan [hidden email] Vision is the art of seeing what is invisible to others. > On 19 Oct 2018, at 04:39 , Michael Schmid <[hidden email]> wrote: > > Hi Kenneth, > > both the File>Import Text Image and File>Save As>Text Image always use decimal points (not commas), irrespective of the locale. > The code is in ij.plugin.TextReader and ij.io.TextEncoder, respectively. > > ImageJ also uses decimal points to save numbers in tables, and commas (not semicolons) as separators in CSV files, irrespective of the locale. > > I consider this quite fortunate since most scientific software does it like this. > > [Many people in the European scientific community, including me, use the English version of the operating system and software to avoid such problems. This also avoids badly translated text in menus etc...] > > In any case, changing all of ImageJ to consistently format and accept numbers according to the current locale would be impossible. The macro language must have decimal points (for compatibility with existing code). Then e.g. a curve fit equation (macro language) would have decimal points in numbers, but the fit parameters would have commas? It would be a mess, and many macros and plugins would not work any more. > > > But I am aware that it can be a problem for importing .sv or txt files into programs like Excel etc. - some programs use their own settings for the number format, others the system-wide settings of the decimal point/comma. Some versions of Excel let you decide whether to use the system decimal separator or a custom one in the advanced options. > > If your collaboration partners really need decimal commas, you need some conversion, e.g. > https://stackoverflow.com/questions/39954541/how-to-replace-dots-with-commas-in-multiple-csv-files > > > Michael > ________________________________________________________________ > On 18/10/18 19:38, Kenneth Sloan wrote: >> When saving an image in "text" format, how are Locale settings determined? Are they inherited >> from the local machine's global settings? Or, is it possible to manipulate them within ImageJ? >> My question is motivated by collaborations involving USA and German participants. Occasionally, >> I need to run ImageJ on a USA-centric machine, but would prefer to generate German style output. >> The specific issue is the difference between '.' and ',' in the formatting of floating point >> pixel values. >> When I write Java plugins, I set the Locale directly, and can control this - but I'd prefer to >> use the Save As/text facility, if possible. I'd like to do this without switching the Locale for >> every other application running on my laptop! >> I suppose I could just write my own SaveAsGermanText plugin - but that seems like overkill. >> A small side question: I just found SaveAs/text. While not my first choice of image representation, >> I can see how it can be useful in some contexts, and I'd like to understand what can be done with it. >> In particular, how do I read back a .txt file and get an image? >> [and then, of course...can I deal with multiple formats - the '.' vs ',' issue, again] >> -- >> Kenneth Sloan >> [hidden email] >> Vision is the art of seeing what is invisible to others. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |