[vtkusers] Why vtkDICOMFileSorter only find one series

chenjianyyzz chenjianyyzz at 163.com
Wed Mar 1 20:49:02 EST 2017


Hello David,


thank you for your great help, the solution you provided above solved my question.


Best Regards
James



At 2017-03-01 23:57:41, "David Gobbi" <david.gobbi at gmail.com> wrote:

And I'd better fix my typo in the code.  The last line should be this:


fileArray->GetValue(filesInStack->GetValue(fileNumber)).c_str()



On Wed, Mar 1, 2017 at 8:55 AM, David Gobbi <david.gobbi at gmail.com> wrote:

Yes, there is a roundabout way that you can do this, because the reader can sort the files into stacks.


  vtkSmartPointer<vtkDICOMReader> reader = vtkSmartPointer<vtkDICOMReader>::New();
  reader->SetFileNames(fileArray);
  reader->UpdateInformation();


  vtkStringArray *stacks = reader->GetStackIDs();
  int numberOfStacks = stacks->GetNumberOfValues();
  int stackNumber = 1;  // for example


  reader->SetDesiredStackID(stacks->GetValue(stackNumber));
  reader->UpdateInformation();


  vtkIntArray *filesInStack = reader->GetFileIndexArray();
  for (int fileNumber = 0; fileNumber < filesInStack->GetNumberOfValues(); fileNumber++)
  {
    std::cout << fileArray->GetValue(filesInStack->GetValue(jj)).c_str() << std::endl;
  }


So this code will use the FileIndexArray() to get a sorted list of the files in the stack.  Once you have the files you want, you can throw away the reader.  Note that I only call UpdateInformation() on the reader, so it is only reading the file headers.


 - David




On Wed, Mar 1, 2017 at 7:54 AM, chenjianyyzz <chenjianyyzz at 163.com> wrote:

Hello David, 


greak, thank you very much. further question: in the attached files there are 2 stacks, and now I want to find which DICOM files belongs to stack0, and which belongs stack1, how can I find it?
is there any function that I can get the files list for stack0, just like how I get the file list for somes series?
     vtkStringArray *seriesFilenames = sorter->GetFileNamesForSeries(i);




Best Regards
James






At 2017-03-01 21:45:47, "David Gobbi" <david.gobbi at gmail.com> wrote:

Hi James,


All of the images in that zip file have the same SeriesInstanceUID.  So this is, in fact, a single series that contains two stacks. This is fairly common.


The vtkDICOMReader can be used to find the number of stacks:


  vtkSmartPointer<vtkDICOMReader> reader = vtkSmartPointer<vtkDICOMReader>::New();
  reader->SetFileNames(sorter->GetFileNamesForSeries(0));
  reader->UpdateInformation();
  vtkStringArray *stacks = reader->GetStackIDs();
  int numberOfStacks = stacks->GetNumberOfValues();


The reader can also be told which stack to read:


  reader->SetDesiredStackID(stacks->GetValue(0));
  reader->Update();


With the "Enhanced MR Image IOD" and the "Enhanced CT Image IOD", it is even possible for a single _file_ to contain multiple stacks.


 - David










  


On Wed, Mar 1, 2017 at 3:50 AM, chenjianyyzz <chenjianyyzz at 163.com> wrote:

Hello David,


I have a set  of images (it includes 2 series), but the vtkDICOMFileSorter can only 1 series? 
I don't know what's the problem, will any body help me out?


attached please find the data, and below is the code:
========================================================
vtkSmartPointer<vtkStringArray> filenames = vtkSmartPointer<vtkStringArray>::New();
filenames->InsertNextValue("A_10_0001_0325.dcm"); 
filenames->InsertNextValue("A_10_0001_0326.dcm"); 
filenames->InsertNextValue("A_10_0001_0327.dcm"); 
filenames->InsertNextValue("A_10_0001_0328.dcm"); 
filenames->InsertNextValue("A_10_0001_0329.dcm"); 
filenames->InsertNextValue("A_10_0001_0330.dcm"); 
filenames->InsertNextValue("A_10_0001_0331.dcm"); 
filenames->InsertNextValue("A_10_0001_0332.dcm"); 
filenames->InsertNextValue("A_10_0001_0333.dcm"); 
filenames->InsertNextValue("A_10_0001_0334.dcm"); 
filenames->InsertNextValue("A_10_0001_0335.dcm"); 
vtkSmartPointer <vtkDICOMFileSorter> sorter = vtkSmartPointer <vtkDICOMFileSorter>::New();
sorter->SetInputFileNames(filenames);
sorter->Update();


// Get number of series 
int numSeries = sorter->GetNumberOfSeries();//==> here I expect to get 2, but only 1 got
========================================================


actually "A_10_0001_0325.dcm" should be seperate into another series, will any body help me out?
thanks in advance




 







 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170302/fd511cf8/attachment.html>


More information about the vtkusers mailing list