10 m_NumThreads = itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads();
15 m_ComputationMask = NULL;
18 m_ExplainedRatio = 0.9;
19 m_NumEigenValuesPCA = 6;
21 m_SampleDirections.clear();
27 delete m_DataODFImages;
30 delete m_TestODFImage;
35 m_ComputationMask = anima::readImage <MaskImageType> (cMask);
43 if (!m_ComputationMask)
44 itkExceptionMacro(
"No computation mask... Exiting...");
47 for (
unsigned int i = 0;i < MaskImageType::GetImageDimension();++i)
48 tmpInd[i] = m_NbSplits;
53 std::vector < ImageSplitterODFType::TInputIndexType > splitIndexesToProcess;
55 if (specificSplitToDo != -1)
57 tmpInd[0] = (
unsigned int)floor((
double)(specificSplitToDo/(m_NbSplits*m_NbSplits)));
58 unsigned int tmpVal = specificSplitToDo - tmpInd[0]*m_NbSplits*m_NbSplits;
59 tmpInd[1] = (
unsigned int)floor((
double)(tmpVal/m_NbSplits));
60 tmpInd[2] = tmpVal - tmpInd[1]*m_NbSplits;
63 splitIndexesToProcess.push_back(tmpInd);
67 for (
unsigned int i = 0;i < m_NbSplits;++i)
70 for (
unsigned int j = 0;j < m_NbSplits;++j)
73 for (
unsigned int k = 0;k < m_NbSplits;++k)
78 splitIndexesToProcess.push_back(tmpInd);
84 for (
unsigned int i = 0;i < splitIndexesToProcess.size();++i)
86 std::cout <<
"Processing block : " << splitIndexesToProcess[i][0] <<
" " 87 << splitIndexesToProcess[i][1] <<
" " << splitIndexesToProcess[i][2] << std::endl;
97 for (
unsigned int j = 0;j < m_DataODFImages->
GetNbImages();++j)
98 mainFilter->AddDatabaseInput(m_DataODFImages->
GetOutput(j));
101 mainFilter->SetNumberOfWorkUnits(m_NumThreads);
103 mainFilter->SetStatisticalTestType(m_StatisticalTestType);
104 mainFilter->SetExplainedRatio(m_ExplainedRatio);
105 mainFilter->SetNumEigenValuesPCA(m_NumEigenValuesPCA);
107 mainFilter->SetSampleDirections(m_SampleDirections);
109 mainFilter->SetInput(0,m_TestODFImage->
GetOutput(0));
111 mainFilter->Update();
113 std::cout <<
"Results computed... Writing output parcel..." << std::endl;
116 sprintf(numSplit,
"_%ld_%ld_%ld.nrrd",splitIndexesToProcess[i][0],splitIndexesToProcess[i][1],splitIndexesToProcess[i][2]);
119 std::string outputName = m_OutputName + numSplit;
120 std::string outputPValName = m_OutputPValName + numSplit;
125 if (genOutputDescriptionData)
127 std::string tmpOutName = m_OutputName +
".txt";
128 std::ofstream tmpFileOut(tmpOutName.c_str());
130 std::string tmpOutPValName = m_OutputPValName +
".txt";
131 std::ofstream tmpFilePValOut(tmpOutPValName.c_str());
133 for (
unsigned int i = 0;i < m_NbSplits;++i)
136 for (
unsigned int j = 0;j < m_NbSplits;++j)
139 for (
unsigned int k = 0;k < m_NbSplits;++k)
147 sprintf(numSplit,
"_%ld_%ld_%ld.nrrd",tmpInd[0],tmpInd[1],tmpInd[2]);
149 tmpFileOut <<
"<BLOCK>" << std::endl;
150 tmpFileOut <<
"BLOCK_FILE=" << m_OutputName + numSplit << std::endl;
151 tmpFileOut <<
"STARTING_INDEX=" << tmpBlRegion.GetIndex()[0] <<
" " 152 << tmpBlRegion.GetIndex()[1] <<
" " << tmpBlRegion.GetIndex()[2] << std::endl;
153 tmpFileOut <<
"</BLOCK>" << std::endl;
155 tmpFilePValOut <<
"<BLOCK>" << std::endl;
156 tmpFilePValOut <<
"BLOCK_FILE=" << m_OutputPValName + numSplit << std::endl;
157 tmpFilePValOut <<
"STARTING_INDEX=" << tmpBlRegion.GetIndex()[0] <<
" " 158 << tmpBlRegion.GetIndex()[1] <<
" " << tmpBlRegion.GetIndex()[2] << std::endl;
159 tmpFilePValOut <<
"</BLOCK>" << std::endl;
166 tmpFilePValOut.close();
171 OutputImageType::RegionType finalROI)
173 OutputImageType::RegionType tmpRegion = finalROI;
174 for (
unsigned int i = 0;i < OutputImageType::GetImageDimension();++i)
175 tmpRegion.SetIndex(i,0);
177 OutputImageType::Pointer tmpRes = OutputImageType::New();
178 tmpRes->Initialize();
180 tmpRes->SetOrigin(m_ComputationMask->GetOrigin());
181 tmpRes->SetRegions(tmpRegion);
182 tmpRes->SetDirection(m_ComputationMask->GetDirection());
183 tmpRes->SetSpacing(m_ComputationMask->GetSpacing());
187 itk::ImageRegionIterator <OutputImageType> tmpImIt (tmpIm,finalROI);
188 itk::ImageRegionIterator <OutputImageType> tmpResIt (tmpRes,tmpRegion);
190 while (!tmpImIt.IsAtEnd())
192 tmpResIt.Set(tmpImIt.Get());
198 anima::writeImage <OutputImageType> (resName,tmpRes);
void Update(int specificSplitToDo=-1, bool genOutputDescriptionData=false)
void SetComputationMask(std::string &cMask)
TInputRegionType GetBlockRegionInsideMargin()
unsigned int GetNbImages()
MaskImageType * GetSmallMaskWithMargin()
PatientToGroupODFComparisonImageFilter< double >::OutputImageType OutputImageType
void SetComputationMask(MaskImageType::Pointer &maskIm)
LowMemoryPatientToGroupODFComparisonBridge()
void SetBlockIndex(TInputIndexType &bIndex)
itk::SmartPointer< Self > Pointer
void SetNumberOfBlocks(TInputIndexType &bNumBlocks)
~LowMemoryPatientToGroupODFComparisonBridge()
TInputImage * GetOutput(unsigned int i)
TInputRegionType GetSpecificBlockRegion(TInputIndexType &block)
bool EmptyMask(TInputIndexType &bIndex)
anima::ImageDataSplitter< InputImageType > ImageSplitterODFType
void BuildAndWrite(OutputImageType *tmpIm, std::string resName, OutputImageType::RegionType finalROI)
TInputImage::IndexType TInputIndexType