Dear Samuel,

 

the code you sent us look almost correct. Only problem I see in the moment is 
the import of the 3D images into the 4D image.

Instead of the line:

 

image4D->SetImportVolume(image, i, 0, mitk::Image::ReferenceMemory);

 

please try the following: 

 

mitkIpPicDescriptor* currentVolume = 
image->GetVolumeData(0)->GetPicDescriptor();

image4D->SetPicVolume( currentVolume , myTimeStep);

 

This is because the SetImportVolume function expects a void* of data, if you 
give it a SmartPointer it will not work correctly.

 

I hope this can help you,

 

Best regards,

Tobias

 

 

------------------------------------------------------------

Tobias Schwarz
DKFZ
German Cancer Research Center (Deutsches Krebsforschungszentrum) 
Member of the Helmholtz Association
Division of Medical & Biological Informatics E130
Im Neuenheimer Feld 280
D-69120 Heidelberg

Phone: 49-(0)6221-42-2353
Fax: 49-(0)6221-42-2345
E-Mail: [email protected]
Web: www.dkfz.de <http://www.dkfz.de/> 

Confidentiality Note: This message is intended only for the use of the named 
recipient(s) and may obtain confidential and/or privileged information. If you 
are not the intended recipient, please contact the sender and delete the 
message. Any unauthorized use of the information contained in this message is 
prohibited.

 

 

Von: Samuel Silva [mailto:[email protected]] 
Gesendet: Montag, 21. September 2009 13:35
An: [email protected]
Betreff: [mitk-users] Creating 4D image from 3D images

 

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&reg; 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&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to