Decimal separator in TPC

Background

Blood and regional PET data in Turku PET Centre are saved in ASCII file format (file format DFT or the format used by PMOD), containing decimal numbers. The decimal separator is a symbol used to mark the boundary between the integral and the fractional parts of a decimal numeral. Terms implying the symbol used are decimal point and decimal comma. Both representations are accepted by SI, depending on the country.

Finland, Italy, Germany and France belong to the comma countries. United Kingdom, United States and Japan belong to the dot countries, and the programming tools and software for PET scanners and other devices have largely been developed there. Therefore, software in the PET field commonly assumes that decimal point is used, although modern software can be adapted to use the local separator. Since PET data can be sent across borders we can not assume that the data to be analyzed follows the local country settings.

Convention in TPC

At the present moment, most data analysis software in TPC writes decimal numbers with decimal point. Increasingly, “in-house” software can read data files using either comma or dot separator; dot separator is always accepted.

Problems

1. Files are produced with Windows software with comma separator

Problem is introduced, when Windows software (for example Excel), by default, uses local separator, which is comma in Finland. When these files are saved and used by analysis tools that assume decimal points, only the integer part of the decimal number may actually be read and the fractional part may be (silently) discarded, or, if you are lucky, program execution stops with an error.

Solution

Change the decimal separator setting in Windows from the control panel, or you can override the Windows decimal separator setting only in Excel, if you like. Note that in hospital network you may need to do this change again once a while!

2. Data with period as decimal separator are not imported correctly in Excel

Windows software is, by default, assuming that data files that you try to import are using local separator, which is comma in Finland. Our data files normally have dot separators, therefore the data is not imported correctly.

Solution #1

Change the decimal separator setting in Windows from the control panel, or you can override the Windows decimal separator setting only in Excel, if you like.

Solution #2

Use the latest versions of tacformat, parformat, dft2html, or res2html to convert data files into XML or XHTML table format and import those in Excel. Or, use tacformat with appropriate command-line option to convert data into CSV format for importing into Excel.

3. bash printf error

Linux scripts are usually written assuming that decimal separator is dot. When these scripts are executed on bash shell on Windows, the default locale setting may default to comma as decimal separator. In that case, for example, command

printf "Pi %f\n" 3.14
would lead to “invalid number” error, and 0,000000 would be printed.

Solution #1

Change the decimal separator setting permanently in Windows from the control panel, or in the shell by adding

LC_NUMERIC="en_US.UTF-8"
in to ~/.bashrc or ~/.bash_profile.

Solution #2

In case of bash script, add LC_NUMERIC=C to the script to use dot as decimal separator during execution of the script. It may be safe to start all bash scripts with

#!/bin/bash
LC_NUMERIC=C


See also:



Tags: , , , , ,


Created at: 2007-01-12
Updated at: 2018-11-11
Written by: Vesa Oikonen