Hi Sascha,

sorry for replying so late - I was on vacation and after that had some trouble 
generating the stack traces you need. Since the program mostly does not crash, 
but merely throws an exception, the stack trace is not very informative. 

I discovered several problems with loading and saving DICOM data and will 
describe them in detail. They only occur with the manually compiled 
mitkWorkbench - everything is fine with the pre-compiled binary for OS X as 
well as running the code on its own without MITK.

1. Loading large DICOM datasets

The datasets from http://www.osirix-viewer.com/datasets/ produce the following 
errors:

1a: When loading using the "Open" button from the toolbar, and when using the 
following code:

mitk::DataNodeFactory::Pointer reader = mitk::DataNodeFactory::New();
try
{
        
reader->SetFileName(m_imageData.getFileNames()[0].toStdString().c_str());
        reader->Update();
        // Add the node to the DataStorage
        mitk::DataNode::Pointer node = reader->GetOutput();
        node->SetProperty( "name", mitk::StringProperty::New( 
QString("DICOM").toStdString().c_str() ));
        //node->SetData( reader->GetOutput() );
        GetDataStorage()->Add( node);

        // show the newly created image

        mitk::BaseData::Pointer basedata = node->GetData();
        
mitk::RenderingManager::GetInstance()->InitializeViews(basedata->GetTimeSlicedGeometry(),
 mitk::RenderingManager::REQUEST_UPDATE_ALL, true );
}
catch (...)
{
        MITK_INFO << "Mitk: Could not open file " << 
m_imageData.getFileNames()[0];
        return;
}


The following error occurs:

[19.786] DataNodeFactory: Loading DICOM series 0: Series UID 
1.3.12.2.1107.5.1.4.51964.4.0.3816613618801152
[19.787]   1559 'CT' files (CT Image Storage) loaded into 1 mitk::Image
[19.787]   multi-frame: No
[19.787]   reader support: Supported
[19.787]   pixel spacing type: In Patient
[19.787]   gantry tilt corrected: No
[19.787]   3D+t: No
[19.787] 
--------------------------------------------------------------------------------
#20.914# ERROR: Error encountered when loading DICOM series:std::exception
#20.914# ERROR: DataNodeFactory: Skipping series 0 due to some unspecified 
error...
Das Programm ist abgestürzt.


And the following stack trace is reported:

Process:         mitkWorkbench [14398]
Path:            /Users/USER/*/mitkWorkbench.app/Contents/MacOS/mitkWorkbench
Identifier:      ???
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  Qt Creator [7949]
User ID:         501

Date/Time:       2013-09-23 10:55:08.174 +0200
OS Version:      Mac OS X 10.8.5 (12F37)
Report Version:  10

Interval Since Last Report:          63214 sec
Crashes Since Last Report:           36
Per-App Interval Since Last Report:  5731 sec
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      4B7B1138-FD68-8E77-97ED-802190EFDA80

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000000c8

VM Regions Near 0xc8:
--> 
    __TEXT                 0000000102aa2000-0000000102acf000 [  180K] r-x/rwx 
SM=COW  /Users/USER/*/mitkWorkbench.app/Contents/MacOS/mitkWorkbench

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libMitk.dylib                       0x0000000102daba6c 
itk::SmartPointer<mitk::TimeSlicedGeometry>::GetPointer() const + 12 
(itkSmartPointer.h:94)
1   libMitk.dylib                       0x0000000102da8b1c 
mitk::BaseData::GetTimeSlicedGeometry() + 28 (mitkBaseData.h:67)
2   liborg_mitk_gui_qt_tenslices.dylib  0x0000000119fb56d2 
QmitkTenSlicesView::OnLoadButton_pressed() + 1282 (QmitkTenSlicesView.cpp:178)
[…]


1b: When using ITK and GDCM to open the same datasets with the following code:

typedef itk::Image<ItkPixelType, 3> ItkInputImageType;
typedef itk::ImageSeriesReader<ItkInputImageType> ItkReaderType;

m_gdcmIO = itk::GDCMImageIO::New();
ItkReaderType::Pointer reader = ItkReaderType::New();

reader->SetImageIO(m_gdcmIO);
reader->SetFileNames(filenames);

try
{
        reader->Update();
}
catch(itk::ExceptionObject &excp)
{
        qDebug() << "Exception thrown while reading DICOM series\n" << 
excp.GetDescription();
        return false;
}


I get the following exception:

Exception thrown while reading DICOM series
itk::ERROR: GDCMImageIO(0x7fdb7cb48880): Failed to get the buffer! 



2. Saving any DICOM images

2a. Right-click on a dataset  in the DataManager and click save, then save it 
as DICOM in the dialog, the following error message is displayed:

error saving file: 
/Users/peter/Forschung/code/MITK-2013.06.0-src/Core/Code/IO/mitkIOUtil.cpp:206:
An exception occured during writing the file /Users/peter/Desktop/test/bla_. 
Exception says std::bad_cast

2b. Using ITK and GDCM, the same std::bad_cast exception is thrown. I used the 
code from the ITK DICOM resampling example
>> http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM

which runs fine when compiled on its own, and integrated it into MITK. The 
important code is the following:

OutputNamesGeneratorType::Pointer outputNames = OutputNamesGeneratorType::New();
std::string seriesFormat("/Users/peter/Desktop/test");
seriesFormat = seriesFormat + "/" + "IM%d.dcm";
outputNames->SetSeriesFormat (seriesFormat.c_str());
outputNames->SetStartIndex (1);
outputNames->SetEndIndex (outputSize[2]);

SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
seriesWriter->SetInput( shiftScale->GetOutput() );
seriesWriter->SetImageIO( gdcmIO );
seriesWriter->SetFileNames( outputNames->GetFileNames() );
seriesWriter->SetMetaDataDictionaryArray( &outputArray );
try
{
        seriesWriter->Update();
}
catch( itk::ExceptionObject & excp )
{
        std::cerr << "Exception thrown while writing the series " << std::endl;
        std::cerr << excp.what() << std::endl;
        return;
}
catch (std::bad_cast &excp)
{
        std::cerr << "Bad Cast: " << excp.what() << std::endl;
        void *array[50];
        size_t size;
        size = backtrace(array, 50);
        backtrace_symbols_fd(array, size, STDERR_FILENO);
        return;
}

The following exception is thrown:

Bad Cast: std::bad_cast

And the stack trace is not very helpful since the program does not crash:

0   liborg_mitk_gui_qt_resample.dylib   0x000000012a9a21f0 
_ZN17QmitkResampleView17DoImageProcessingEv + 10784
1   liborg_mitk_gui_qt_resample.dylib   0x000000012aa05c32 
_ZN17QmitkResampleView18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv + 
130
2   QtCore                              0x000000011301f09e 
_ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 1566
3   QtGui                               0x00000001128e9ef1 
_ZN15QAbstractButton7clickedEb + 49
[…]


I'm not sure whether this is a problem with MITK, ITK, GDCM or OS X since the 
"std::bad_cast" exception is quite mysterious. Also, the loading error of the 
mentioned large datasets is very strange. 

Again, here is my coding environment:
>> 
>> Mac OS X 10.8.4 / 10.8.5
>> MITK 2013.06 Superbuild,
>> ITK 4.3.2,
>> VTK 5.10.1,
>> Boost 1.45,
>> GDCM 2.2.1,
>> DCMTK 3.6.1
>> Qt 4.8.4
>> 
>> (I built all these libraries myself and pointed the superbuild towards them)

This is the only configuration where I got MITK to run on OS X, newer versions 
of ITK and GDCM deliver compiler errors that are another story. 

I hope that you can reproduce the error and that you have some insight what 
could be the cause. I am trying to implement a very important project for 
clinical researchers in Leipzig, and right now I'm pretty much stuck because of 
these errors. Also, if these errors do not occur on other platforms (Windows or 
Linux), I would consider switching platforms since MITK and OS X 10.8 do not 
seem to like each other very much.

Kind regards,

Peter Salz


Am 16.08.2013 um 15:37 schrieb Sascha Zelzer <[email protected]>:

> Hi Peter,
> 
> how do you exactly save the image? Are using the context menu in the 
> datamanger or are you calling some code yourself?
> 
> Could you please also provide a full stack trace and the complete error 
> message, ideally attached to a bug report at bugs.mitk.org?
> 
> Thanks,
> 
> Sascha
> 
> On 08/13/2013 10:09 PM, Peter Salz wrote:
>> Hi,
>> 
>> it's me again. I encountered another severe bug with the custom-build MITK 
>> on Mac OS X 10.8. When trying to save a volume into a series of DICOM 
>> images, a std::bad_cast exception is thrown. This happens when you load a 
>> DICOM dataset with MITK and try to save it again (with the following error 
>> message):
>> 
>> Could not save image.
>> Error:
>> .../MITK-2013.06.0-src/Core/Code/IO/mitkIOUtil.cpp:206:
>> An exception occurred during writing the file …. Exception says std::bad_cast
>> 
>> It also happens when I try to save a DICOM volume that I loaded myself with 
>> ITK - I use an itk::ImageSeriesWriter, and I even imported the code for the 
>> ITK DICOM Resampling Example into a MITK plugin because this code works when 
>> compiled separately.
>> But when executed from the MITK as a plugin, the same std::bad_cast error 
>> happens (note that MITK is not involved at all - I just press the "Do 
>> something" button from the generic plugin and execute the code as presented 
>> here:
>> 
>> http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM
>> 
>> 
>> 
>> Here is my coding environment:
>> 
>> Mac OS X 10.8.4
>> MITK 2013.06 Superbuild,
>> ITK 4.3.2,
>> VTK 5.10.1,
>> Boost 1.45,
>> GDCM 2.2.1,
>> DCMTK 3.6.1
>> Qt 4.8.4
>> 
>> (I built all these libraries myself and pointed the superbuild towards them)
>> 
>> 
>> Hope anyone can help with this because this is a very severe bug and I 
>> wonder whether it is OS X 10.8 specific.
>> 
>> 
>> Best regards,
>> 
>> Peter Salz
>> 
>> TU Kaiserslautern, Germany
>> ------------------------------------------------------------------------------
>> Get 100% visibility into Java/.NET code with AppDynamics Lite!
>> It's a free troubleshooting tool designed for production.
>> Get down to code-level detail for bottlenecks, with <2% overhead.
>> Download for free and get started troubleshooting in minutes.
>> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
>> _______________________________________________
>> mitk-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mitk-users
> 

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to