Hi.
I’ve got several mha files, each is the subvolume of the big 3d volume. These subvolumes go in coronal direction. So, I need to combine them into one big file, but I don’t have enough memory to create whole image to perform simple copy into it, thus, I have to use stream writing. Unfortunately, I’ve not found how to set coronal direction for stream writing.
Dimension of each part is 1152x260x1152. Number of parts is 3.
This code
using SeriesReaderType = itk::ImageSeriesReader< OutputImageType > ;
SeriesReaderType::Pointer reader = SeriesReaderType::New();
reader->SetFileNames(nameGenerator->GetFileNames());
reader->UpdateOutputInformation();
std::cout << reader->GetOutput()->GetLargestPossibleRegion();
using ImageWriterType = itk::ImageFileWriter<OutputImageType>;
ImageWriterType::Pointer writer = ImageWriterType::New();
writer->SetFileName("WholeVolume.mha");
writer->SetNumberOfStreamDivisions(10);
writer->SetInput(reader->GetOutput());
writer->Update();
outputs
ImageRegion (0x7f215ca7c898)
Dimension: 3
Index: [0, 0, 0]
Size: [1152, 260, 3]
and the program exits with error
itk::ERROR: ImageSeriesReader(0x7f215ca371e0): Size mismatch! The size of /home/user/dev/t4all/release/bin/part0.mha is [1152, 260, 1152] and does not match the required size [1152, 260, 1] from file /home/user/dev/t4all/release/bin/part0.mha
It looks like the input files for ImageSeriesReader should be 2-dimensional image. I created lots of 2-dim parts, each corresponds to one coronal slice, but the code above put them in axial direction. Then I did little trick - I created coronal slice but in 3d image with dimension [1152, 1, 1152] and it outputs (where 780 is the number of slices)
ImageRegion (0x7f5c54ab7f78)
Dimension: 3
Index: [0, 0, 0]
Size: [1152, 780, 1152]
! The exact dimension I need, but content is distorted. (https://imgur.com/a/XpANGVm lower pic must be the same as upper)
The only way I got it worked is to create axial slices by iterate over subvolumes opening/closing them multiple times. But this solution is very slow and over headed.
Could anyone direct me where I should look to optimize my problem ?