# NRRD file support

**URL:** https://discourse.paraview.org/t/nrrd-file-support/5233
**Category:** ParaView Support
**Created:** [September 1, 2020, 12:04pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233 "2020-09-01T12:04:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![neurolabusc](https://discourse.paraview.org/user_avatar/discourse.paraview.org/neurolabusc/32/4798_2.png) [@neurolabusc](https://discourse.paraview.org/u/neurolabusc)
#### Post date: [September 1, 2020, 12:04pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/1 "2020-09-01T12:04:06Z")

</div>

The [NRRD format specification](http://teem.sourceforge.net/nrrd/format.html#general.2) requires  
that `extra whitespace after the field descriptor and before the line termination is ignored`. However, the function [ParseVector vtkNrrdReader.cxx](https://github.com/Kitware/VTK/blob/master/IO/Image/vtkNrrdReader.cxx) trims the input string, but does not ignore white space within a string.

Therefore, Paraview will parse the vectors:

```
space directions: (2.9356703758239746,0,0) (0,2.949852466583252,0) (0,0,2.9361956119537354)
space origin: (-75.762535095214844,-110.76253509521484,-71.762535095214844)

```

But fail to parse the vectors:

```
space directions: (2.9356703758239746, 0, 0) (0, 2.949852466583252, 0) (0, 0, 2.9361956119537354)
space origin: (-75.762535095214844, -110.76253509521484, -71.762535095214844)

```

The user is provided with no feedback regarding an error, but no image is displayed. Careful inspection of the image properties will reveal that the spatial “Bounds” all have a delta of zero (e.g. all voxels collapsed to single point).

Here is a small [example](https://drive.google.com/open?id=1aQ9Q50-eowiVtuR-2OHWE8XtLao3ElbJ) illustrating this issue.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 1, 2020, 12:15pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/2 "2020-09-01T12:15:52Z")

</div>

Looks like a bug and shouldn’t be too hard to fix. Do you think you could submit an [issue](https://gitlab.kitware.com/paraview/paraview/-/issues) and work on a fix ?

---

<div class="post-metadata">

### Author: ![neurolabusc](https://discourse.paraview.org/user_avatar/discourse.paraview.org/neurolabusc/32/4798_2.png) [@neurolabusc](https://discourse.paraview.org/u/neurolabusc)
#### Post date: [September 1, 2020, 12:24pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/3 "2020-09-01T12:24:18Z")

</div>

I have created an [issue](https://gitlab.kitware.com/paraview/paraview/-/issues/20172). I would think a fix would change the code

```
std::string value = s.substr(0, i);
result.push_back(atof(value.c_str()));

```

to trim each value:

```
std::string value = s.substr(0, i);
value = trim(value);
result.push_back(atof(value.c_str()));
```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 1, 2020, 12:24pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/4 "2020-09-01T12:24:55Z")

</div>

Could you push this in a MR ?

---

<div class="post-metadata">

### Author: ![neurolabusc](https://discourse.paraview.org/user_avatar/discourse.paraview.org/neurolabusc/32/4798_2.png) [@neurolabusc](https://discourse.paraview.org/u/neurolabusc)
#### Post date: [September 1, 2020, 2:22pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/5 "2020-09-01T14:22:11Z")

</div>

Happy to do so. Can you test the fix on your system to make sure it works? If so, I can submit a MR without compiling on my systems.

The issue is observed on the latest stable ParaView 5.8.1. It sounds like some [NRRD changes were made to nightly](https://gitlab.kitware.com/paraview/paraview/-/issues/17737), but nightly builds are not provided for macOS and the nightly builds for Linux do not include the client viewer. I would rather not work out all the compile dependencies for what seems like a small fix.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 1, 2020, 2:29pm UTC](https://discourse.paraview.org/t/nrrd-file-support/5233/6 "2020-09-01T14:29:23Z")

</div>

Fair enough. The buildbots will take care of building and testing the fix.
