[OpenWalnut-Dev] Write file reader for WDataSetScalar
Alexander Wiebel
wiebel_openwalnut at dergrosse.de
Mon May 14 16:09:52 CEST 2012
Mathias,
are you sure you downloaded the file and not the html page? I did this
first and had the problems you describe. Now I have the file itself and
I am able to load the data set. I will start to analyze it in a second.
Alex
On 05/14/2012 01:00 PM, Mathias Goldau wrote:
> This file is possibly broken: fslview as well as nifti_tool segfault on it. OW
> loader module crashes.
>
> math at voltaire# /tmp >nifti_tool -disp_hdr -in out.nii
> header file 'out.nii', num_fields = 43
>
> all fields:
> name offset nvals values
> ------------------- ------ ----- ------
> sizeof_hdr 0 1 1329865020
> data_type 4 10 CTYPE html
> db_name 14 18 ><html lang="en" x
> extents 32 1 1815768173
> session_error 36 1 28257
> regular 38 1 g
> dim_info 39 1 61
> dim 40 8 25890 8814 25376 24940 29555 8765 8226
> 28024
> intent_p1 56 1 0.059431
> *** buffer overflow detected ***: nifti_tool terminated
> ======= Backtrace: =========
> /lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7fb0ef544007]
>
> FSL is a bit more specific on whats the issue here:
>
> math at voltaire# /tmp >nifti_tool -disp_hdr -in out.nii
> [...]
> ** ERROR: nifti_convert_nhdr2nim: bad dim[0]
> ** ERROR (nifti_image_read): cannot create nifti image from header
> '/tmp/out.nii'
> ** ERROR: nifti_image_open(/tmp/out): bad header info
> Error: failed to open file /tmp/out
> Mutex destroy failure: Device or resource busy
> Failed to open file /tmp/out
> [...]
> E: Child terminated by signal ‘Segmentation fault’
>
> Mathias
>
> On 14.05.2012 12:12, 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/
>>
>
>
More information about the OpenWalnut-Dev
mailing list