~ubuntu-branches/ubuntu/oneiric/mricron/oneiric

« back to all changes in this revision

Viewing changes to dcm2nii/parconvert.pas

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-04-14 15:51:33 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110414155133-sd2umdatjqjlkhzt
Tags: 0.20110413.1~dfsg.1-1
* New upstream version. FSL BET related patches are no obsolete
  and have been removed. Mricron now performs autodetection of FSL.
  Additionally it supports a system-wide configuration file at
  /etc/mricron/mricron.ini
* Patch for older lazarus versions no longer applies to the lazarus
  version in unstable. Moved this patch into backport patch series files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        lDicomData.DateTime := StudyDateTime(lDicomData.StudyDate,lDicomData.StudyTime);
32
32
end;
33
33
 
34
 
procedure ShellSortItems (first, last: integer; var lPositionRA, lIndexRA: LongintP; var lRepeatedValues: boolean);
 
34
procedure ShellSortItems (first, last: integer; var lPositionRA: longintp; lIndexRA: int64P; var lRepeatedValues: boolean);
35
35
{Shell sort chuck uses this- see 'Numerical Recipes in C' for similar sorts.}
36
36
label
37
37
     555;
379
379
var lErrorStr,lInStr,lUpCaseStr,lReportedTRStr{,lUpcase20Str}: string;
380
380
   lAPFOV,lFHFOV,lRLFOV,
381
381
   lScanResX,lScanResY,lAngleA,lAngleB,lAngleC,lOffset1,lOffset2,lOffset3{,lXFOV,lYFOV}: double;
382
 
   lSliceIndexRAx,lSliceSequenceRA,lSortedSliceSequence: LongintP;
 
382
   lSliceIndexRAx,lSliceSequenceRA,lSortedSliceSequence: int64P;
383
383
   //lSliceIndexRA: array [1..kMaxnSlices] of longint;
384
384
   //lSSx,lRSx,lRIx: array [1..kMaxnSlices] of single;
385
385
   lSlopeRAx,lInterceptRAx: array [1..kMaxnSlices] of single;
441
441
  lIsParVers41 := false;
442
442
  lIsParVers42 := false;
443
443
  lSliceInfoCount := 0;
444
 
  getmem(lSliceIndexRAx, kMaxnSLices* sizeof(longint));
 
444
  getmem(lSliceIndexRAx, kMaxnSLices* sizeof(int64));
445
445
 
446
446
  for lInc := kXdim to kIndex do //initialize all values: important as PAR3 will not explicitly report all
447
447
          MinMaxTRange(lRangeRA[lInc],0);
458
458
  Reset(fp, 1);
459
459
  lFileSz := FileSize(fp);
460
460
  GetMem( lCharRA, lFileSz+1 ); //note: must free dynamic memory: goto 333 if any error
461
 
  GetMem (lSliceSequenceRA, kMaxnSLices*sizeof(longint));  //note: must free dynamic memory: goto 333 if any error
 
461
  GetMem (lSliceSequenceRA, kMaxnSLices*sizeof(int64));  //note: must free dynamic memory: goto 333 if any error
462
462
  BlockRead(fp, lCharRA^, lFileSz, lInpos);
463
463
  if lInPos <> lFileSz then begin
464
464
     Msg('read_PAR2NII: Disk error, unable to read full input file.');
642
642
                        end; //PAR41
643
643
                 end; //PAR4
644
644
                 if lSliceInfoCount < kMaxnSlices then begin
645
 
                        lSliceSequenceRA^[lSliceInfoCount] := ( (round(lRangeRA[kSequence].val)+round(lRangeRA[kType].val)+round(lRangeRA[kCardiac].val+lRangeRA[kEcho].val)) shl 24)+(round(lRangeRA[kDyn].val) shl 10)+round(lRangeRA[kSlice].val);
 
645
                        lSliceSequenceRA^[lSliceInfoCount] :=  (round(lRangeRA[kSequence].val) shl 48)+(round(lRangeRA[kType].val) shl 40)+(round(lRangeRA[kCardiac].val) shl 32)+(round(lRangeRA[kEcho].val) shl 24)+(round(lRangeRA[kDyn].val) shl 10)+round(lRangeRA[kSlice].val);
646
646
                        (*lRSx [lSliceInfoCount] := lRangeRA[kRS].Val;
647
647
                        lRIx [lSliceInfoCount] := lRangeRA[kRI].val;
648
648
                        lSSx [lSliceInfoCount] := lRangeRA[kSS].Val;
649
649
                        *)
650
 
 
 
650
                        // fx( lRangeRA[kType].val ,lRangeRA[kEcho].val);
651
651
                        PhilipsPrecise (lRangeRA[kRS].Val, lRangeRA[kRI].val,lRangeRA[kSS].Val,lSlopeRAx[lSliceInfoCount],lInterceptRAx[lSliceInfoCount],lPrecise);
652
652
                        lSliceIndexRAx^[lSliceInfoCount]:= round(lRangeRA[kIndex].val);
653
653
                 end;
716
716
                          +floattostrf(lDicomData.XYZmm[2],ffFixed,8,2)+'/'+floattostrf(lDicomData.XYZmm[3],ffFixed,8,2)
717
717
                          +kCR+'TR: '+floattostrf(lDicomData.TR,ffFixed,8,2)
718
718
              +kCR+lReportedTRStr+kCR+lDynStr;
 
719
 
719
720
  //if we get here, the header is fine, next steps will see if image format is readable...
720
721
  lHdrOK := true;
721
722
  if lSliceInfoCount < 1 then begin
765
766
       //Next sort image indexes here...
766
767
  if (lSliceInfoCount > 1) and(lSlicesNotInSequence) and ( lReadOffsetTables) then begin //sort image order...
767
768
     //ShellSort (first, last: integer; var lPositionRA, lIndexLoRA,lIndexHiRA: LongintP; var lRepeatedValues: boolean)
768
 
     GetMem (lOffset_pos_table, lSliceInfoCount*sizeof(longint));
 
769
     GetMem (lOffset_pos_table, lSliceInfoCount*sizeof(int64));
769
770
     for lInc := 1 to  lSliceInfoCount do
770
771
         lOffset_pos_table^[lInc] := lInc;
771
772
         ShellSortItems (1, lSliceInfoCount,lOffset_pos_table,lSliceSequenceRA, lRepeatedValues);
772
 
     if lRepeatedValues then begin
 
773
    (* if lRepeatedValues then begin
773
774
         Msg('read_PAR2NII: fatal error, slices do not appear to have unique indexes [multiple copies of same slice]');
774
775
         FreeMem (lOffset_pos_table);
775
776
         goto 333;
776
 
     end;
 
777
     end; *)
777
778
     lOffsetTableEntries := lSliceInfoCount;
778
779
  end; //sort image order...
779
780