[OpenWalnut-Dev] Write file reader for WDataSetScalar

Frank Zisko frank.zisko at gmx.net
Mon May 14 22:38:16 CEST 2012


Now I got the correct order. In imagej I can see the data set
output_04.nii.gz correctly. But OW is still black. When I re-read the
saved output.nii datas, too. The HistogrammView is also on error. I
don't get my misstake.
All values are int between 0 and 255;

Am Montag, den 14.05.2012, 21:36 +0200 schrieb Frank Zisko:
> Hi,
> 
> I changed the read mode. But ... I'm still confused.
> 
> I looked at file in imagej. It looks a super little bit better, but it's
> still wrong.
> 
> Here some data sets in a shared dropbox folder:
> https://www.dropbox.com/sh/u1iiga8nrs4vosv/gdsPaPSd7W
> ( see in comments what changes makes the datasets )
> 
> I'm not shure if the mode of reading the volume is the only one error I
> do. I can'T display the HistogrammView for any data set. 
> 
> 
> 
> 
> SOURCE
> 
> #include ...
> [...]
> boost::shared_ptr< WDataSet > WReaderMy::read()
> {
>      m_ifs = boost::shared_ptr< std::ifstream >( new std::ifstream() );
>      m_ifs->open( m_fname.c_str(), std::ifstream::in |
> std::ifstream::binary );
> [...]
>      wlog::info( "WReaderMy" ) << "Read array ...";
>      // My Data Array.
>      int voxelCount = dimX * dimY * dimZ;
>      int tensorDim = 1; // Scalar values.
>      int order = 0; // ?
>      boost::shared_ptr< std::vector< int > > myData =   
> boost::shared_ptr< std::vector< int > >( new std::vector< int >(  
> voxelCount ) );
> 
> // ##################################################
>     int tmp = 0;
>     int index = 0;
>     for( int x = 0; x < dimX; x++)
>     {
>         for(int y = 0; y < dimY; y++)
>         {
>             for(int z = 0; z < dimZ; z++)
>             {
>                 m_ifs->read( reinterpret_cast<char*>(&tmp),1 );
>                 //index = x*dimY*dimZ + y*dimZ + z; // output_01
>                 //index = (voxelCount-1) - (x*dimY*dimZ + y*dimZ +
> z); // output_02 reversed output_01
>                 //index = (dimX-1-x) + y*(dimX-1) +
> z*(dimX-1)*(dimY-1); // output_03
>                 index = z*dimY*dimX + y*dimX + x; // output_04
>                 (*vmrData)[index] = tmp;
>             }
>         }
>     }
>  // ###########################################
>      wlog::info( "WReaderMy" ) << "Read array ... Done.";
> 
>      boost::shared_ptr< WValueSetBase > myValueSet; // For creatiung  
> DataSetScalar ( WValueSetBase, WGrid).
>      myValueSet = boost::shared_ptr< WValueSetBase >( new WValueSet<  
> int >( order, tensorDim, myData) );
> 
> 
> [...]
>      boost::shared_ptr< WGrid > myGrid;
>      myGrid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D(
> dimX, dimY, dimZ, WGridTransformOrtho( getStandardTransform() ) ) );
>      boost::shared_ptr< WDataSet > myDataSet;
>      wlog::debug( "WReaderMy" ) << "Load as WDataSetScalar";
>      myDataSet = boost::shared_ptr< WDataSet >( new WDataSetScalar(  
> myValueSet, myGrid ) );
>      myDataSet->setFilename( m_fname );
>      m_ifs->close();
>      return myDataSet;
> }




More information about the OpenWalnut-Dev mailing list