[vtkusers] how to change image order

Mathieu Malaterre mathieu.malaterre at gmail.com
Tue Dec 22 04:53:12 EST 2009


On Mon, Dec 21, 2009 at 8:47 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> On Mon, Dec 21, 2009 at 12:05 PM, Lic. José M. Rodriguez Bacallao
> <jmrbcu at gmail.com> wrote:
>>> There is no filter to reorganize the vtkImageData
>>> slices with strides and such.  I had to read in the data
>>> slice-by-slice (i.e. a different reader for each slice) and use
>>> vtkImageAppend to put it together in the right order.
>>
>> how do U do that? could U send me an example code?
>
> The English second-person pronoun is "you."  I've never met this "U" person.
>
> Actually, I just remembered that doing ImageAppend isn't necessary in
> VTK anymore.  It's possible for vtkImageReader2 to sort the slices in
> whatever order you want, so as long as vtkGDCMReader inherits from
> vtkImageReader2, then it should be able to do this too.  Here is what
> to do:
>
> In VTK, there is a class called vtkStringArray, that is a list of
> strings.  You can use it to store all of the slice filenames of the
> DICOM series that you want to read, just make sure that all the
> filenames in the vtkStringArray are in the right order.
>
> vtkStringArray *sliceList = vtkStringArray::New();
> sliceList->InsertNextValue("slice1.dcm");;
> sliceList->InsertNextValue("slice2.dcm");
> etc.
>
> Then you do the following:
>
> reader->SetFileNames(sliceList);
>
> Mathieu might know whether this will work with the GDCM reader.  There
> are also classes to help create a vtkStringArray from a directory of
> files: vtkGlobFileNames and vtkSortFileNames.

Yes, this is the reason #1 why I fight over on this mailing list. My
vtkGDCMImageReader will never do sorting. This leave the user with
full control of the sorting, in this case appearntly sorting by
Instance Number.

But I am thinking that Jose is looking for a solution to the 4d
problem. Should I show a 3D volume over time, or should I show a movie
of a specific 2D slice over time. Since I did not see the actual
problem described, but only a question "how do I implement that", I
cannot help very much.

2cts
-- 
Mathieu



More information about the vtkusers mailing list