[Paraview-developers] Reading NIFTI RGB(A) and unsigned int types

Philip A Cook cookpa at mail.med.upenn.edu
Tue Feb 14 11:24:30 EST 2012


Hi,

With a few simple changes to Plugins/AnalyzeNIfTIReaderWriter/vtkNIfTIReader.cxx, I was able to make Paraview read NIFTI RGB and RGBA images, and also NIFTI unsigned short and int data types. 

I tried to register for git access a week or two ago, but I haven't heard back. I've tested the patch on 3.12 and 3.14 RC2 (commit 1635f2e9eb4edabaa61a97f59d8f2febf20b5f1c). RGBA was a bit strange on 3.12 (zero alpha would be opaque sometimes) but it seems to work OK now.


Phil

diff --git a/Plugins/AnalyzeNIfTIReaderWriter/vtkNIfTIReader.cxx b/Plugins/AnalyzeNIfTIReaderWriter/vtkNIfTIReader.cxx
index def6645..21fc3b3 100644
--- a/Plugins/AnalyzeNIfTIReaderWriter/vtkNIfTIReader.cxx
+++ b/Plugins/AnalyzeNIfTIReaderWriter/vtkNIfTIReader.cxx
@@ -258,23 +258,37 @@ void vtkNIfTIReader::ExecuteInformation()
     this->SetDataScalarTypeToShort();
     dataTypeSize = 2;
       break;
+    case DT_UINT16: 
+    this->SetDataScalarTypeToUnsignedShort();
+    dataTypeSize = 2;
+      break;
     case DT_SIGNED_INT:
     this->SetDataScalarTypeToInt();
     dataTypeSize = 4;
       break;
+    case DT_UINT32:
+    this->SetDataScalarTypeToUnsignedInt();
+    dataTypeSize = 4;
+      break;
     case DT_FLOAT:
     this->SetDataScalarTypeToFloat();
     dataTypeSize = 4;
       break;
     case DT_DOUBLE:
-     this->SetDataScalarTypeToDouble();
+    this->SetDataScalarTypeToDouble();
     dataTypeSize = 8;
       break;
     case DT_RGB:
-      // DEBUG -- Assuming this is a triple, not quad
-      //image.setDataType( uiig::DATA_RGBQUAD );
+    this->SetDataScalarTypeToUnsignedChar();
+    numComponents = 3;
+    dataTypeSize=3;  
       break;
-    default:
+    case DT_RGBA32:
+    this->SetDataScalarTypeToUnsignedChar();
+    numComponents = 4;
+    dataTypeSize=4;
+      break;
+    default: // Error gets thrown by ExecuteData if type is not set
       break;
     }
   //



More information about the Paraview-developers mailing list