[OpenWalnut-Dev] Write file reader for WDataSetScalar

Frank Zisko frank.zisko at gmx.net
Mon May 21 16:29:36 CEST 2012


Am Montag, den 21.05.2012, 10:08 +0200 schrieb Sebastian Eichelbaum:
> Hi
> 
> The exception tells us that the data vector is not complete. This might have several reasons. Maybe, we mis-interpret some nifti HDR info and think there must be more?! 
> 
Next I'll try a random data set (in code) to create and load.

Here is the output of my stand alone file reader for the same file, just
the original:

File version: 4
dimX: 256
dimY: 256
dimZ: 192
   dimX * dimY * dimZ: 12582912
   Counted voxels: 12582912
   Counted voxels [0 255]: 12582912
   Random voxel [207][31][19]: 0
   Random voxel [236][147][184]: 0
   Random voxel [166][141][159]: 39
   Random voxel [210][190][63]: 121
   Random voxel [10][111][150]: 0
offsetX: 192
offsetY: 192
offsetZ: 192
cubeDim: 256
posInfoFlag: 1
coordSystem: 1
centerXfirst: -95.5
centerYfirst: -56
centerZfirst: -10.7952
centerXlast: 95.5
centerYlast: -56
centerZlast: -10.7952
sliceRowDirectionX: 0
sliceRowDirectionY: 1
sliceRowDirectionZ: 0
sliceColumnDirectionX: 0
sliceColumnDirectionY: 0
sliceColumnDirectionZ: -1
nrOfRows: 256
nrOfColumns: 256
extFoVRow (mm): 256
extFoVColumn (mm): 256
sliceThickness (mm): 1
gapThickness (mm): 0
nrOfSpatialTrans (>0?): 0
leftRightConvention: 1
refSpace: 1
voxelResolutionX: 1
voxelResolutionY: 1
voxelResolutionZ: 1
isVoxelResulutionVerified (bool): 1
isTalairachMM (bool): 0
minIntensity: 4
meanIntensity: 163
maxIntensity: 434
My last test byte: 1337
Missed bytes to end of file: 0



> One other questions: do you use a 32bit Ubuntu to develop your stuff? We currently have a severe issue with 32bit systems and the Nifti library.
I only use 64-bit versions and I have made ​​no issue with NIfTI lib.


> 
> Can someone who knows how to interpret the nifti header info help here? Maybe something wrong with the dimensions?
> The nifit_tool provides this header info:
> 
> 
> header file 'Downloads/output_05_OK.nii.gz', num_fields = 43
> 
> all fields:
> name                offset  nvals  values
> ------------------- ------  -----  ------
> sizeof_hdr             0      1    348
> data_type              4     10    
> db_name               14     18    
> extents               32      1    0
> session_error         36      1    0
> regular               38      1    r
> dim_info              39      1    57
> dim                   40      8    4 256 256 192 1 0 0 0
> intent_p1             56      1    0.0
> intent_p2             60      1    0.0
> intent_p3             64      1    0.0
> intent_code           68      1    0
> datatype              70      1    8
> bitpix                72      1    32
> slice_start           74      1    0
> pixdim                76      8    1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0
> vox_offset           108      1    352.0
> scl_slope            112      1    0.0
> scl_inter            116      1    0.0
> slice_end            120      1    0
> slice_code           122      1    0
> xyzt_units           123      1    0
> cal_max              124      1    0.0
> cal_min              128      1    0.0
> slice_duration       132      1    0.0
> toffset              136      1    0.0
> glmax                140      1    0
> glmin                144      1    0
> descrip              148     80    WDataSetSingle
> aux_file             228     24    
> qform_code           252      1    1
> sform_code           254      1    1
> quatern_b            256      1    0.0
> quatern_c            260      1    0.0
> quatern_d            264      1    0.0
> qoffset_x            268      1    0.0
> qoffset_y            272      1    0.0
> qoffset_z            276      1    0.0
> srow_x               280      4    1.0 0.0 0.0 0.0
> srow_y               296      4    0.0 1.0 0.0 0.0
> srow_z               312      4    0.0 0.0 1.0 0.0
> intent_name          328     16    
> magic                344      4    n+1
> 


Greetings

Frank


> On Sun, 20 May 2012, Frank Zisko wrote:
> 
> > I'm very sorry for my late reply. I was very busy in the last days.
> > 
> > 
> > > Please be a little bit more specific. What is the error in the histogramView? You verified that each value is between 0-255? Is it possible to send your most recent dataset you wrote with OW as nifti?
> > > 
> > I verified each value while reading and count them. The number is same as number of voxels.
> > 
> > The most recent set is in the dropboxfolder "output_05":
> > https://www.dropbox.com/sh/k4s36ih29d0r56d/9PsnCXgbTn/output_05_OK.nii.gz
> > from folder:
> > https://www.dropbox.com/sh/k4s36ih29d0r56d/zAdsTKRkrr
> > 
> > If needed I can send more code and example data sets. But unfortunately, only private.
> > 
> > The HistogramView error ist the following:
> > 
> > *INFO    [HistogramView] Recalculating histogram. 
> > Exception thrown! Callstack's backtrace:
> > trace: WException::WException(std::exception const&)	->
> > lib/libopenwalnut.so.1(_ZN10WExceptionC1ERKSt9exception+0x135)
> > [0x7f2596a9ad65]
> > trace: WThreadedRunner::threadMainSave()	->
> > lib/libopenwalnut.so.1(_ZN15WThreadedRunner14threadMainSaveEv+0xba)
> > [0x7f2596a9e23a]
> > trace: boost::detail::thread_data<boost::function<void ()> >::run()	->
> > lib/libopenwalnut.so.1(_ZN5boost6detail11thread_dataINS_8functionIFvvEEEE3runEv+0x1e) [0x7f2596aa10ae]
> > trace: thread_proxy()	->	/usr/lib/libboost_thread.so.1.46.1(thread_proxy
> > +0x69) [0x7f2592f36ce9]
> > trace: ()	->	/usr/lib/nvidia-current-updates/libGL.so.1(+0xa7b74)
> > [0x7f259012cb74]
> > 
> > *ERROR   [KernelRootContainer] Error in module "HistogramView".
> > Forwarding to nesting container. 
> > *INFO    [ModuleContainer (KernelRootContainer)] Disconnecting Data
> > Module:out from HistogramView:Input dataset #0 
> > *ERROR   [Module (HistogramView)] WException. Notifying. Message:
> > vector::_M_range_check 
> > 
> > Greetings 
> > 
> > Frank
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > 
> > > On Mon, 14 May 2012, Frank Zisko wrote:
> > > 
> > > > 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;
> > > > > }
> > > > 
> > > > 
> > > > _______________________________________________
> > > > OpenWalnut-Dev mailing list
> > > > OpenWalnut-Dev at lists.informatik.uni-leipzig.de
> > > > http://lists.informatik.uni-leipzig.de/mailman/listinfo/openwalnut-dev
> > > > 
> > > > Archive: http://lists.informatik.uni-leipzig.de/pipermail/openwalnut-dev/
> > > > 
> > > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > OpenWalnut-Dev mailing list
> > OpenWalnut-Dev at lists.informatik.uni-leipzig.de
> > http://lists.informatik.uni-leipzig.de/mailman/listinfo/openwalnut-dev
> > 
> > Archive: http://lists.informatik.uni-leipzig.de/pipermail/openwalnut-dev/
> > 
> 





More information about the OpenWalnut-Dev mailing list