I have loaded a DICOM series into a vtkDICOMReader, and to represent the data into a vtkVolume, I transfer it vtkDICOMReader into a vtkImageExtractComponents. On this vtkImageExtractComponents object I have done some segmentation. Now, I want to transfer data back from vtkImageExtractComponents to vtkDICOMReader, in order to export it as DICOM series. Is there possible this ? If it is, how to transfer data from vtkImageExtractComponents to vtkDICOMReader ?
I think vtkDICOMReader accept files as input only… but what if I want to load a vtkImageData ?
I have found on vtkImageExtractComponents a method: m_pImageExtractor->GetImageDataInput(0)
which return a vtkImageData … but how can I load this vtkImageData into vtkDICOMReader ?
I have tried:
vtkDICOMReader* pDICOMReader = vtkDICOMReader::New();
vtkImageData* pImageData = m_pImageExtractor->GetImageDataInput(0);
pDICOMReader->GetOutput()->CopyStructure(pImageData);
pDICOMReader->GetOutput()->GetPointData()->PassData(pImageData->GetPointData());
but I got:
> ERROR: In D:\VTK\vtk-dicom-master\Source\vtkDICOMReader.cxx, line 2403
> vtkDICOMReader (0000016D942CACE0): ERROR: In D:\VTK\vtk-dicom-master\Source\vtkDICOMParser.cxx, line 1903
> vtkDICOMParser (0000016D943D14B0): ReadFile: Can't open the file .0
Obviously I have done something wrong, but what ?
You cannot take data out of a reader, modify it, and then put it back into the reader. VTK doesn’t work like that.
Then I guess I get in the trouble. I have read DICOM CBCT series with excellent class vtkDICOMReader. In order to visualize this data as vtkVolume, I put this vtkDICOMReader into a vtkImageExtractComponents, just like that:
// use m_pImageExtractor for volume because the series could have more components inside
m_pImageExtractor->SetInputConnection(m_pDICOMReader->GetOutputPort());
m_pImageExtractor->SetComponents(0);
m_pImageExtractor->Update();
Then, I exported this m_pImageExtractor into a vtkImageExport on ITK (SimpleITK), made some segmentation, and put back data into m_pImageExtractor through vtkImageImport. Fine by here.
The issue is that I need to export this data as DICOM series through vtkDICOMWriter. How much is possible that ?
You should put the data from vtkImageImport into vtkDICOMWriter.
Putting the data from vtkImageImport back into m_pImageExtractor makes no sense.
Sound logical and after I implemented this approach, work great ! Thank you !