~ubuntu-branches/ubuntu/wily/dicomnifti/wily

« back to all changes in this revision

Viewing changes to src/dinifti.cc

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-10-24 11:08:54 UTC
  • mfrom: (1.1.11) (3.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20111024110854-uq0uzu32wyv9t94z
Tags: 2.29.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define VERSION "2.28.15"
 
1
#define VERSION "2.29.1"
2
2
 
3
3
//****************************************************************************
4
4
//
419
419
 
420
420
                        int imgNum = dcmImg->ImageNumber();
421
421
 
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
426
426
                        
427
427
                        int acqNum = 0;
428
428
                        if ( opts.numSlices > 0 )
442
442
 
443
443
                        // Try to determine if the acquisition number makes sense
444
444
 
445
 
                        
446
445
                        IMAGELIST *timePoint = si.imageMap[acqNum];
447
446
                        if (timePoint == NULL)
448
447
                        {
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
532
        {
 
533
                SeriesInfo si = series->second;
 
534
 
 
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
 
537
 
 
538
                std::map<int, bool> fixMap;
 
539
                
 
540
                for ( IMAGEMAP::iterator timeIter = si.imageMap.begin(); timeIter != si.imageMap.end(); ++timeIter )
 
541
                {
 
542
                        if ( ! si.mosaic )
 
543
                        {
 
544
                                int acqNum = timeIter->first;
 
545
                                IMAGELIST *timePointList = timeIter->second;
 
546
                                fixMap[acqNum] = timePointList->size() != timePointList->front().NumSlices();
 
547
                        }
 
548
                }
 
549
 
 
550
                for ( std::map<int, bool>::iterator fixIter = fixMap.begin(); fixIter != fixMap.end(); ++fixIter )
 
551
                {
 
552
                        if ( fixIter->second )
 
553
                        {
 
554
                                // We need to fix this list. Use echo number to augment list size.
 
555
 
 
556
                                IMAGELIST *timePointList = si.imageMap[fixIter->first];
 
557
                                int baseAcqNum = fixIter->first;
 
558
                                
 
559
                                for ( IMAGELIST::iterator timeIter = timePointList->begin(); timeIter != timePointList->end(); )
 
560
                                {
 
561
                                        // Acquisition numbers start from 1, while echo start from 0
 
562
                                        int thisAcqNum = timeIter->ACQEchoNumber();
 
563
                                        
 
564
                                        if ( ++thisAcqNum != baseAcqNum )
 
565
                                        {
 
566
                                                // This has to go in a new list, see if we need to create it.
 
567
 
 
568
                                                IMAGELIST *timePoint = si.imageMap[thisAcqNum];
 
569
                                                if ( timePoint == NULL )
 
570
                                                {
 
571
                                                        si.imageMap[thisAcqNum] = timePoint = new IMAGELIST;
 
572
                                                        if ( thisAcqNum > si.maxAcqNum ) si.maxAcqNum = thisAcqNum;
 
573
                                                }
 
574
                                                timePoint->push_back(*timeIter);
 
575
                                                timePointList->erase(timeIter++);
 
576
                                        }
 
577
                                        else
 
578
                                                ++timeIter;
 
579
                                }
 
580
                                series->second = si;
 
581
                        }
 
582
                }
 
583
                
534
584
                // For each series, check the number of groups (first image in first
535
585
                // time point is sufficient)
536
586
 
537
 
                SeriesInfo si = series->second;
538
587
                IMAGEMAP fullImageMap = si.imageMap;
539
588
                IMAGEMAP::iterator fimIter = fullImageMap.begin();
540
589
                IMAGELIST *firstTimePoint = fimIter->second;