-
-
Notifications
You must be signed in to change notification settings - Fork 715
Open
Labels
type:BugInconsistencies or issues which will cause an incorrect result under some or all circumstancesInconsistencies or issues which will cause an incorrect result under some or all circumstances
Description
Description
We discovered funny issue, when system locale is set to one where decimal numbers are wrote with comma "," instead of "." then the written NRRD file has broken space direction matrix, corrupting header.
Steps to Reproduce
- Change system locale to for example Polish (maybe env flag LC_NUMERIC can do the trick)
- Create any volume where spacing is fractional (e.g. 0.3 mm ) and write it as NRRD file
- Volume does not open in Slicer and header is obviously malformed when inspected. The loading fails with error
Expected behavior
Conform to NRRD file format specification (it uses comma for separating values therefore you cannot use the same character for decimals).
Always write correctly parsable space directions (and other numeric fields if applicable).
Actual behavior
When opening a written nrrd file:
>>> reader.SetFileName('foobar.nrrd')
>>> sitk_image = reader.Execute()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/miniconda3/envs/fooy/lib/python3.8/site-packages/SimpleITK/SimpleITK.py", line 5779, in Execute
return _SimpleITK.ImageFileReader_Execute(self)
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK-build/ITK/Modules/IO/NRRD/src/itkNrrdImageIO.cxx:290:
itk::ERROR: NrrdImageIO(0x55b8a4e482f0): ReadImageInformation: Error reading foobar.nrrd:
[nrrd] nrrdLoad: trouble reading "foobar.nrrd"
[nrrd] nrrdRead: trouble
[nrrd] _nrrdRead: trouble reading NRRD file
[nrrd] _nrrdFormatNRRD_read: trouble parsing space directions info |(0,29999999999999999,0,0) (0,0,29999999999999999,0) (0,0,0,29999999999999999)|
[nrrd] _nrrdReadNrrdParse_space_directions: trouble getting space vector 1 of 3
[nrrd] _nrrdSpaceVectorParse: space dimension is 3, but seem to have 4 coefficients
Reproducibility
100% on systems with locale set to one using comma as decimal delimiter
Versions
5.2.1
Environment
Python 3.8, ITK==5.2.1pre1, SimpleITK==2.0.2
Additional Information
N/A
issakomi
Metadata
Metadata
Assignees
Labels
type:BugInconsistencies or issues which will cause an incorrect result under some or all circumstancesInconsistencies or issues which will cause an incorrect result under some or all circumstances