[OpenWalnut-Dev] Write file reader for WDataSetScalar

Sebastian Eichelbaum eichelbaum at informatik.uni-leipzig.de
Mon May 14 17:03:39 CEST 2012


Tip: do not rely on the orthogonal slices when checking your data. Depending on the data type use use they simply might be black because you have one outlier value which is enormously large or small -> scaling in the colormaps is wrong.

Use the histogramView to check data.

Bye
Sebastian

On Mon, 14 May 2012, Frank Zisko wrote:

> Hi Alex, hi Mario,
> 
> thanks for looking on my problem.
> 
> Am Montag, den 14.05.2012, 16:21 +0200 schrieb Alexander Wiebel:
> > On 05/14/2012 04:19 PM, Mario Hlawitschka wrote:
> > > Hi Frank, Alex,
> > > 
> > > This looks more like flipped axes when creating the file. Can you verify that the X-Y-Z dimensions are correct and you are not reading the data as, e.g., Z-Y-X?
> > This is what I meant with order of values. Thank you for clarifying it.
> I also think that it looks like that.
> 
> 
> In file description is written:
> "Each data element (intensity value) is represented in 1 byte. The data
> is organized in three loops:
> 
> DimZ
> 
> DimY
> 
> DimX"
> 
> I ordered X-Y-Z. So I'll change X and Z. But I wonder, FSL see an image
> and OW not.
> 
> Greetings
> 
> Frank
> 
> > 
> > Alex
> > 
> > > 	Mario
> > > 
> > > On May 14, 2012, at 4:13 PM, Alexander Wiebel wrote:
> > > 
> > >> Hi Frank,
> > >> Mario might be right about endianness related problems. It looks like
> > >> something is wrong with the order of the bits or the values themselves.
> > >> So you might want to look at endianness or at the order in which you
> > >> have the values in the value set.
> > >>
> > >> See my attached snapshots that I created using Amira.
> > >>
> > >> Cheers,
> > >> Alex
> > >>
> > >> On 05/14/2012 12:12 PM, Frank Zisko wrote:
> > >>> Hi Alex,
> > >>>
> > >>> here is a file exported from OW. 
> > >>>
> > >>> https://www.dropbox.com/s/xnrgvnsqxryayco/out.nii
> > >>>
> > >>> Greetings
> > >>>
> > >>> Frank
> > >>>
> > >>>
> > >>> Am Donnerstag, den 10.05.2012, 23:46 +0200 schrieb Alexander Wiebel:
> > >>>> Hi Frank,
> > >>>> I can not see the problem immediately. So let us approach it iteratively:
> > >>>> - Can you save the loaded dataset in NIfTI (.nii) format and send it to
> > >>>> me so I can check the data you actually loaded?
> > >>>>
> > >>>> Cheers Alex
> > >>>>
> > >>>> On 05/10/2012 05:58 PM, Frank Zisko wrote:
> > >>>>>
> > >>>>>
> > >>>>> Hey guys,
> > >>>>>
> > >>>>> I've a problem in writing a file reader.
> > >>>>> (ROOT/src/modules/data/io/WReaderMy.cpp  .h)
> > >>>>> It is a anatomic file. Including a header, voxels (intensity values) and
> > >>>>> postheader.
> > >>>>>
> > >>>>> I try to use a WDataSetScalar. Constructor want: WDataSetScalar aDataSet
> > >>>>> = new (WValueSetBase,WGrid). But something is wrong in my code. I write
> > >>>>> all values in WValueSet and create a WGrid. The 3D viewer shows a black
> > >>>>> dataset, the histogram viewer give me errors (see below). The tmp
> > >>>>> variable in the loop has right values. But I don't know why it doesn't
> > >>>>> works.
> > >>>>>
> > >>>>> Has anybody an idea what can i do?
> > >>>>>
> > >>>>>
> > >>>>> HEADER
> > >>>>>
> > >>>>> [...]
> > >>>>> protected:
> > >>>>>
> > >>>>>    boost::shared_ptr< std::ifstream > m_ifs;
> > >>>>> [...]
> > >>>>>
> > >>>>>
> > >>>>> 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;
> > >>>>>    for (int i = 0; i < voxelCount; i++)
> > >>>>>    {
> > >>>>>        //m_ifs->read( reinterpret_cast<char*>(&myData->at(i) ),  1);
> > >>>>>        m_ifs->read( reinterpret_cast<char*>(&tmp),  1); // Read 1 byte.
> > >>>>>        (*myData)[i] = 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;
> > >>>>> }
> > >>>>>
> > >>>>>
> > >>>>> Histogram output in bash:
> > >>>>>
> > >>>>> [...]
> > >>>>> *INFO    [ModuleContainer (KernelRootContainer)] Connecting Data
> > >>>>> Module:out with HistogramView:Input dataset #0
> > >>>>> *INFO    [HistogramView] Recalculating histogram.
> > >>>>> Exception thrown! Callstack's backtrace:
> > >>>>> trace: WException::WException(std::exception const&)    ->   
> > >>>>> lib/libopenwalnut.so.1(_ZN10WExceptionC1ERKSt9exception+0x135)
> > >>>>> [0x7ff3457e6715]
> > >>>>> trace: WThreadedRunner::threadMainSave()    ->   
> > >>>>> lib/libopenwalnut.so.1(_ZN15WThreadedRunner14threadMainSaveEv+0xba)
> > >>>>> [0x7ff34581b00a]
> > >>>>> trace: boost::detail::thread_data<boost::function<void ()> >::run()   
> > >>>>> ->   
> > >>>>> lib/libopenwalnut.so.1(_ZN5boost6detail11thread_dataINS_8functionIFvvEEEE3runEv+0x1e)
> > >>>>> [0x7ff34581d98e]
> > >>>>> trace: thread_proxy()    ->   
> > >>>>> /usr/lib/libboost_thread.so.1.46.1(thread_proxy+0x69) [0x7ff341f19ba9]
> > >>>>> trace: ()    ->    /usr/lib/nvidia-current-updates/libGL.so.1(+0xa7354)
> > >>>>> [0x7ff33f197354]
> > >>>>>
> > >>>>> *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
> > >>>>>
> > >>>>>
> > >>>>> _______________________________________________
> > >>>>> 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/
> > >>>
> > >>>
> > >>> _______________________________________________
> > >>> 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/
> > >>
> > >> <snapshot.jpg><snapshot2.jpg>_______________________________________________
> > >> 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/
> > 
> 
> 
> _______________________________________________
> 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/
> 

-- 
Dipl.-Inf. Sebastian Eichelbaum
Universität Leipzig
Institut für Informatik
Abteilung Bild- und Signalverarbeitung
PF 100920
D-04009 Leipzig


More information about the OpenWalnut-Dev mailing list