420
420
int imgNum = dcmImg->ImageNumber();
422
// The acquisition number can come directly from the header or
422
// The qcquisition number can be provided by the user or
423
423
// If the number of slices greater than 1, use them to compute it.
424
424
// Else, if the echo number is greater than 0 use that (+1)
425
// Finally it can be computed from the parameter given by the user
425
// Finally it can come directly from the header
428
428
if ( opts.numSlices > 0 )
531
530
// do not increment the iterator here as this has to be handled conditionally at the end
532
531
for (SERIESMAP::iterator series = seriesMap.begin(); series != seriesMap.end(); )
533
SeriesInfo si = series->second;
535
// Loop through images in each list and verify if number of images is
536
// consistent, otherwise we need to split them in more lists
538
std::map<int, bool> fixMap;
540
for ( IMAGEMAP::iterator timeIter = si.imageMap.begin(); timeIter != si.imageMap.end(); ++timeIter )
544
int acqNum = timeIter->first;
545
IMAGELIST *timePointList = timeIter->second;
546
fixMap[acqNum] = timePointList->size() != timePointList->front().NumSlices();
550
for ( std::map<int, bool>::iterator fixIter = fixMap.begin(); fixIter != fixMap.end(); ++fixIter )
552
if ( fixIter->second )
554
// We need to fix this list. Use echo number to augment list size.
556
IMAGELIST *timePointList = si.imageMap[fixIter->first];
557
int baseAcqNum = fixIter->first;
559
for ( IMAGELIST::iterator timeIter = timePointList->begin(); timeIter != timePointList->end(); )
561
// Acquisition numbers start from 1, while echo start from 0
562
int thisAcqNum = timeIter->ACQEchoNumber();
564
if ( ++thisAcqNum != baseAcqNum )
566
// This has to go in a new list, see if we need to create it.
568
IMAGELIST *timePoint = si.imageMap[thisAcqNum];
569
if ( timePoint == NULL )
571
si.imageMap[thisAcqNum] = timePoint = new IMAGELIST;
572
if ( thisAcqNum > si.maxAcqNum ) si.maxAcqNum = thisAcqNum;
574
timePoint->push_back(*timeIter);
575
timePointList->erase(timeIter++);
534
584
// For each series, check the number of groups (first image in first
535
585
// time point is sufficient)
537
SeriesInfo si = series->second;
538
587
IMAGEMAP fullImageMap = si.imageMap;
539
588
IMAGEMAP::iterator fimIter = fullImageMap.begin();
540
589
IMAGELIST *firstTimePoint = fimIter->second;