xtk

Unable to display nifti image


I have a tensor_fa nifti image with values [0,1] of data type FLOAT32. Originally tried to load in a local script using the xtk edge library. This showed a blank canvas. I've also tried increasing the range (multiply by 100 to range [0,100]) and changing this multiplied image to a INT32. When trying in slicedrop, the original image "loads", but any attempt at thresholding brings up the "drop files anywhere" message. Same for the image multiplied by 100. The INT32 image allows thresholding, but still displays no image. I've verified all three images in fslview and mricron (nifti viewers).

Additionally, I've tried setting volume min/max to 0/1 and lower/upper Thresholds to 0/1.

Basic nifti header info:

data_type      FLOAT32 or INT32
dim1           121
dim2           145
dim3           121
dim4           1
datatype       16 or 8
pixdim1        1.5000000000
pixdim2        1.5000000000
pixdim3        1.5000000000
pixdim4        0.0000000000
cal_max        0.0000
cal_min        0.0000
file_type      NIFTI-1+
scl_slope      1.000000
scl_inter      0.000000

The images are:

http://wagners.homeip.net/work/wrtensor_fa_orig.nii.gz (Original image)

http://wagners.homeip.net/work/wrtensor_fa.mul100.nii.gz (Multiplied by 100)

The image as int is named wrtensor_fa.nii.gz. Stackoverflow won't let me post a third link.

Any suggestions appreciated.

Further followup:

It appears the data is not truly [0,1]. It contains NaNs. When I convert the NaNs to a true value, for example -1, then the image can be displayed. However, I need to work with an unmodified image. One would think that volume.lowerThreshold and upperThreshold would do the trick.

Further followup #2:

I've been muddling through Chrome's javascript tools. On the page I'm working with, the first of three images (INT16) I can do a volume.filedata and recieve an ArrayBuffer. The second and third (both FLOAT32) return a NULL.


Solution

  • What about using isNan() inside arrayMinMax?

    X.parser.prototype.arrayMinMax = function(data) {
    
      var _min = Infinity;
      var _max = -Infinity;
    
      // buffer the length
      var _datasize = data.length;
    
      var i = 0;
      for (i = 0; i < _datasize; i++) {
    
        if(!isNaN(data[i])) {
    
          var _value = data[i];
          _min = Math.min(_min, _value);
         _max = Math.max(_max, _value);
    
        }
    
      }
    
      return [ _min, _max ];
    
    };
    

    I like this solution better than having a specific check in each file parser. Does it sound good to you?

    Thanks