The collapse of the dimension using extractFilter does not make sense


(esme) #1

Dear all,

I want to do 3d segmentation of an especific vessel but i am having a lot of problems with memory with the 3d filters as this vessels has no contrast at all and i do not have any prior info only intensities and I have decided to do it in 2d. I read a series of dicoms and I am trying to collapse the x dimension because it is the view where i can see much better the vessel. I check the dimensions and they are correct [numberslice,589,180] and i copy the result in a 2d dicom and I see that the result doesn´t show what it is expect. It is as if the image was twisted when it reads the series and then when i read the matrix (volume) through x, the results does not have anything to do with the view i want to see.

Any help?. Thanks

//  Find input image size
	InputImageType::RegionType inputRegion =
	reader->GetOutput()->GetLargestPossibleRegion();
	InputImageType::SizeType size = inputRegion.GetSize();
	const unsigned int collapseDim = 0;
	InputImageType::SizeType::SizeValueType numSlices = size[collapseDim];
	size[collapseDim] = 0;   // collapse dimension ( 3D->2D )


							 //  Set region for 2D extraction
	InputImageType::IndexType start = inputRegion.GetIndex();
	InputImageType::RegionType desiredRegion;
	desiredRegion.SetSize(size);

//  Extract 2D slices, perform processing
	for (unsigned int sliceNumber = 0; sliceNumber<numSlices; sliceNumber++)
	{
		start[collapseDim] = sliceNumber;
		desiredRegion.SetIndex(start);

		extractFilter->SetExtractionRegion(desiredRegion);

		
		using PixelType = short;
		constexpr unsigned int Dimension = 2;
		using ImageType = itk::Image< PixelType, Dimension >;

		using WriterType = itk::ImageFileWriter< ImageType >;

		WriterType::Pointer writer = WriterType::New();



		std::string index = std::to_string(sliceNumber);
		std::string  fileoutput = "results" + index + ".dcm";



		writer->SetFileName(fileoutput);
		writer->SetInput(extractFilter->GetOutput());

		try
		{
			writer->Update();
		}
		catch (itk::ExceptionObject & err)
		{
			std::cerr << "ExceptionObject caught !" << std::endl;
			std::cerr << err << std::endl;
			return EXIT_FAILURE;
		}

		

	
	}

(Dženan Zukić) #2

The question is not entirely clear to me. Can you provide some images/screenshots?


(Pablo Hernandez-Cerdan) #3

Not tested but:

size[collapseDim] = 0; 

Try with 1:

size[collapseDim] = 1; 

And let us know!


(esme) #4

Hello, i think the collapseDim is correct because i want the sagital view but it is the result what i find weird. I realized that the slice was upside down because i created a dicom for each slice to see the result, and it is not

the same as the sagittal view of the 3d slicer when i load the dicom series and it is there where i can see much better the vessels. And the slices i extract are upside down.

Thank you