Hello!
I posted a question regarding this subject a while ago and since I got
no answer I'll get back to it (as I still haven't solved the problem)
with a slightly different scenario.
Well, I have a 4D DICOM set which I successfully manage to load
(separating the different timepoints and creating a node for each) just
by using MITK's code. I can visualize all the loaded 3D images
(timepoints) without any problem.
What I now wanted to do (for the sake of better data organization in my
app, as I want to load several 4D sets) is to build a 4D MITK image from
the 3D images. This way I would only have one item in the DataTree for
each 4D set and manage visualization setting the timepoint.
I did something like this:
===============================================================================
void MyApp::fileOpenGetFactoryOutput( mitk::DataTreeNodeFactory &
factory, mitk::DataTreeNode::Pointer parentNode)
{
mitk::DataTreePreOrderIterator it(m_Tree);
mitk::Image::Pointer image;
mitk::Image::Pointer firstImage;
bool dataFound = false;
mitk::DataTreeNode::Pointer newNode4D = mitk::DataTreeNode::New();
mitk::Image::Pointer image4D = mitk::Image::New();
mitk::TimeSlicedGeometry::Pointer geom = mitk::TimeSlicedGeometry::New();
for ( unsigned int i = 0 ; i < factory.GetNumberOfOutputs( ); ++i )
{
mitk::DataTreeNode::Pointer node = factory.GetOutput( i );
tmpNodeList.push_back(node); // this is just to get an alternative
node list...
if ( node.IsNotNull( ) )
{
image = dynamic_cast<mitk::Image*>(node->GetData());
if ( image.IsNotNull() && firstImage.IsNull() )
{
firstImage = image;
firstNode = newNode4D;
geom->InitializeEvenlyTimed(image->GetGeometry(),
factory.GetNumberOfOutputs( ));
image4D->Initialize ( image->GetPixelType(), *geom);
}
if ( node->GetData() != NULL )
{
dataFound = true;
image4D->SetImportVolume(image, i, 0, mitk::Image::ReferenceMemory);
}
}
}
newNode4D->SetData( image4D ); //crashes here!!!
mitk::DataStorage::GetInstance()->Add( newNode4D, parentNode );
m_ToolReferenceDataSelectionBox->UpdateDataDisplay();
m_ToolWorkingDataSelectionBox->UpdateDataDisplay();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
standardViewsInitialized =
mitk::RenderingManager::GetInstance()->InitializeViews( &it );
}
==============================================================
Things work OK until newNode4D->SetData( image4D ) where it crashes.
By debugging "inside" the SetData I managed to know that the error
occurs in mitk::_ComputeExtremaInItkImage(..), more precisely when
inside the while cycle which computes max and min values for the image.
At some early point the itkdefaultpixelaccessorfunctor cannot retrieve a
pixel value. What can be the reason?
Does the code I present above have any error?
Has anyone tried to do something like this with success?
As far as I could tell, just before the SetData line, image4D has the
pointers for all the volumes in m_Volumes set correctly. All other
pointer lists (m_Slices, m_Channels) have no pointers in them. I suppose
this is normal, since I am setting volumes?
Any idea on what is happening? Things I can do to perform further debugging?
Thanks in advance for all the help!
Samuel
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users