BRAINSia / BRAINSTools

A suite of tools for medical image processing focused on brain analysis
http://brainsia.github.io/BRAINSTools/
Apache License 2.0
114 stars 96 forks source link

Psuedo-code for converting from 4DVolume to 3DVectorVolume #324

Closed hjmjohnson closed 2 years ago

hjmjohnson commented 7 years ago

Hui,

Something similar to the following needs to be part of your solution. It provides conversion from 4DVolume to a 3DVectorVolume.

Hans

include

include

include

typedef itk::VectorImage<unsigned short, 3> VectorVolumeType; VectorVolumeType::Pointer Convert4DVolumeTo3DVectorVolume(Volume4DType::Pointer inputVol) { typedef itk::Image<unsigned short,3> Volume3DType; //Used for a single 3D volume component // convert from image series to vector voxels Volume4DType::SpacingType inputSpacing = inputVol->GetSpacing(); Volume4DType::SizeType inputSize = inputVol->GetLargestPossibleRegion().GetSize(); Volume4DType::IndexType inputIndex = inputVol->GetLargestPossibleRegion().GetIndex(); //////// // "inputVol" is read as a 4D image. Here we convert that to a VectorImageType: // typedef itk::ExtractImageFilter< Volume4DType, Volume3DType > ExtractFilterType;

typedef itk::ComposeImageFilter<Volume3DType, VectorVolumeType> ComposeImageFilterType; ComposeImageFilterType::Pointer composer= ComposeImageFilterType::New();

for( size_t componentNumber = 0; componentNumber < inputSize[3]; ++componentNumber ) { Volume4DType::SizeType extractSize = inputSize; extractSize[3] = 0; Volume4DType::IndexType extractIndex = inputIndex; extractIndex[3] = componentNumber; Volume4DType::RegionType extractRegion(extractIndex, extractSize);

ExtractFilterType::Pointer extracter = ExtractFilterType::New();
extracter->SetExtractionRegion( extractRegion );
extracter->SetInput( inputVol );
extracter->SetDirectionCollapseToIdentity();
extracter->Update();

composer->SetInput(componentNumber,extracter->GetOutput());

} composer->Update(); VectorVolumeType::Pointer nrrdVolume = composer->GetOutput(); return nrrdVolume; }

Hui-Xie commented 7 years ago

Cancel the Convert task as the it involves huge changes in DWI infrastructure and test infrastructure.

hjmjohnson commented 7 years ago

This task still needs to be completed.

hjmjohnson commented 2 years ago

This project is losing interest.