10 m_NumThreads = itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads();
15 m_ComputationMask = NULL;
18 m_ExplainedRatio = 0.9;
19 m_NumEigenValuesPCA = 6;
25 delete m_DataLTImages;
33 m_ComputationMask = anima::readImage <MaskImageType> (cMask);
41 if (!m_ComputationMask)
42 itkExceptionMacro(
"No computation mask... Exiting...");
45 for (
unsigned int i = 0;i < MaskImageType::GetImageDimension();++i)
46 tmpInd[i] = m_NbSplits;
51 std::vector < ImageSplitterLTType::TInputIndexType > splitIndexesToProcess;
53 if (specificSplitToDo != -1)
55 tmpInd[0] = (
unsigned int)floor((
double)(specificSplitToDo/(m_NbSplits*m_NbSplits)));
56 unsigned int tmpVal = specificSplitToDo - tmpInd[0]*m_NbSplits*m_NbSplits;
57 tmpInd[1] = (
unsigned int)floor((
double)(tmpVal/m_NbSplits));
58 tmpInd[2] = tmpVal - tmpInd[1]*m_NbSplits;
61 splitIndexesToProcess.push_back(tmpInd);
65 for (
unsigned int i = 0;i < m_NbSplits;++i)
68 for (
unsigned int j = 0;j < m_NbSplits;++j)
71 for (
unsigned int k = 0;k < m_NbSplits;++k)
76 splitIndexesToProcess.push_back(tmpInd);
82 for (
unsigned int i = 0;i < splitIndexesToProcess.size();++i)
84 std::cout <<
"Processing block : " << splitIndexesToProcess[i][0] <<
" " 85 << splitIndexesToProcess[i][1] <<
" " << splitIndexesToProcess[i][2] << std::endl;
95 for (
unsigned int j = 0;j < m_DataLTImages->
GetNbImages();++j)
96 mainFilter->AddDatabaseInput(m_DataLTImages->
GetOutput(j));
99 mainFilter->SetNumberOfWorkUnits(m_NumThreads);
101 mainFilter->SetInput(0,m_TestLTImage->
GetOutput(0));
103 mainFilter->SetStatisticalTestType(m_StatisticalTestType);
104 mainFilter->SetExplainedRatio(m_ExplainedRatio);
105 mainFilter->SetNumEigenValuesPCA(m_NumEigenValuesPCA);
107 mainFilter->Update();
109 std::cout <<
"Results computed... Writing output parcel..." << std::endl;
112 sprintf(numSplit,
"_%ld_%ld_%ld.nrrd",splitIndexesToProcess[i][0],splitIndexesToProcess[i][1],splitIndexesToProcess[i][2]);
115 std::string outputName = m_OutputName + numSplit;
116 std::string outputPValName = m_OutputPValName + numSplit;
121 if (genOutputDescriptionData)
123 std::string tmpOutName = m_OutputName +
".txt";
124 std::ofstream tmpFileOut(tmpOutName.c_str());
126 std::string tmpOutPValName = m_OutputPValName +
".txt";
127 std::ofstream tmpFilePValOut(tmpOutPValName.c_str());
129 for (
unsigned int i = 0;i < m_NbSplits;++i)
132 for (
unsigned int j = 0;j < m_NbSplits;++j)
135 for (
unsigned int k = 0;k < m_NbSplits;++k)
143 sprintf(numSplit,
"_%ld_%ld_%ld.nrrd",tmpInd[0],tmpInd[1],tmpInd[2]);
145 tmpFileOut <<
"<BLOCK>" << std::endl;
146 tmpFileOut <<
"BLOCK_FILE=" << m_OutputName + numSplit << std::endl;
147 tmpFileOut <<
"STARTING_INDEX=" << tmpBlRegion.GetIndex()[0] <<
" " 148 << tmpBlRegion.GetIndex()[1] <<
" " << tmpBlRegion.GetIndex()[2] << std::endl;
149 tmpFileOut <<
"</BLOCK>" << std::endl;
151 tmpFilePValOut <<
"<BLOCK>" << std::endl;
152 tmpFilePValOut <<
"BLOCK_FILE=" << m_OutputPValName + numSplit << std::endl;
153 tmpFilePValOut <<
"STARTING_INDEX=" << tmpBlRegion.GetIndex()[0] <<
" " 154 << tmpBlRegion.GetIndex()[1] <<
" " << tmpBlRegion.GetIndex()[2] << std::endl;
155 tmpFilePValOut <<
"</BLOCK>" << std::endl;
162 tmpFilePValOut.close();
167 OutputImageType::RegionType finalROI)
169 OutputImageType::RegionType tmpRegion = finalROI;
170 for (
unsigned int i = 0;i < OutputImageType::GetImageDimension();++i)
171 tmpRegion.SetIndex(i,0);
173 OutputImageType::Pointer tmpRes = OutputImageType::New();
174 tmpRes->Initialize();
176 tmpRes->SetOrigin(m_ComputationMask->GetOrigin());
177 tmpRes->SetRegions(tmpRegion);
178 tmpRes->SetDirection(m_ComputationMask->GetDirection());
179 tmpRes->SetSpacing(m_ComputationMask->GetSpacing());
183 itk::ImageRegionIterator <OutputImageType> tmpImIt (tmpIm,finalROI);
184 itk::ImageRegionIterator <OutputImageType> tmpResIt (tmpRes,tmpRegion);
186 while (!tmpImIt.IsAtEnd())
188 tmpResIt.Set(tmpImIt.Get());
194 anima::writeImage <OutputImageType> (resName,tmpRes);
itk::SmartPointer< Self > Pointer
TInputRegionType GetBlockRegionInsideMargin()
unsigned int GetNbImages()
MaskImageType * GetSmallMaskWithMargin()
LowMemoryPatientToGroupComparisonBridge()
void SetComputationMask(MaskImageType::Pointer &maskIm)
PatientToGroupComparisonImageFilter< double >::OutputImageType OutputImageType
~LowMemoryPatientToGroupComparisonBridge()
void SetBlockIndex(TInputIndexType &bIndex)
void BuildAndWrite(OutputImageType *tmpIm, std::string resName, OutputImageType::RegionType finalROI)
void SetNumberOfBlocks(TInputIndexType &bNumBlocks)
void Update(int specificSplitToDo=-1, bool genOutputDescriptionData=false)
TInputImage * GetOutput(unsigned int i)
TInputRegionType GetSpecificBlockRegion(TInputIndexType &block)
bool EmptyMask(TInputIndexType &bIndex)
void SetComputationMask(std::string &cMask)
anima::ImageDataSplitter< InputImageType > ImageSplitterLTType
TInputImage::IndexType TInputIndexType