Skip to content

Commit

Permalink
Kludge for Philips random instance numbers (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jul 29, 2021
1 parent 358fb90 commit f1ef09f
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4345,7 +4345,8 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
//#define kNumberOfLocationsPhilips 0x2001+(0x1015 << 16 ) //SS
//#define kStackSliceNumber 0x2001+(0x1035 << 16 )//? Potential way to determine slice order for Philips?
#define kNumberOfDynamicScans 0x2001 + (0x1081 << 16) //'2001' '1081' 'IS' 'NumberOfDynamicScans'
#define kMRAcquisitionTypePhilips 0x2005 + (0x106F << 16)
#define kMRfMRIStatusIndicationPhilips 0x2005 + (0x1063 << 16)
#define kMRAcquisitionTypePhilips 0x2005 + (0x106F << 16) //SS
#define kAngulationAP 0x2005 + (0x1071 << 16) //'2005' '1071' 'FL' 'MRStackAngulationAP'
#define kAngulationFH 0x2005 + (0x1072 << 16) //'2005' '1072' 'FL' 'MRStackAngulationFH'
#define kAngulationRL 0x2005 + (0x1073 << 16) //'2005' '1073' 'FL' 'MRStackAngulationRL'
Expand Down Expand Up @@ -4415,6 +4416,7 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
int imagesInAcquisition = 0;
//int sumSliceNumberMrPhilips = 0;
int sliceNumberMrPhilips = 0;
int volumeNumberMrPhilips = 0;
int numberOfFrames = 0;
//int MRImageGradientOrientationNumber = 0;
//int minGradNum = kMaxDTI4D + 1;
Expand Down Expand Up @@ -6110,6 +6112,11 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
dcmStr(lLength, &buffer[lPos], d.sequenceName);
break;
}
case kMRfMRIStatusIndicationPhilips: //fmri volume number
if (d.manufacturer != kMANUFACTURER_PHILIPS)
break; //see GE dataset in dcm_qa_nih
volumeNumberMrPhilips = dcmInt(lLength, &buffer[lPos], d.isLittleEndian);
break;
case kMRAcquisitionTypePhilips: //kMRAcquisitionType
if (lLength > 1)
d.is3DAcq = (buffer[lPos] == '3') && (toupper(buffer[lPos + 1]) == 'D');
Expand Down Expand Up @@ -6238,9 +6245,6 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
set_orientation0018_9089(&volDiffusion, lLength, &buffer[lPos], d.isLittleEndian);
}
break;
//case kSliceNumberMrPhilips :
// sliceNumberMrPhilips3D = dcmStrInt(lLength, &buffer[lPos]);
// break;
case kImagingFrequency2:
d.imagingFrequency = dcmFloatDouble(lLength, &buffer[lPos], d.isLittleEndian);
break;
Expand Down Expand Up @@ -7026,6 +7030,18 @@ struct TDICOMdata readDICOMx(char *fname, struct TDCMprefs *prefs, struct TDTI4D
exit(kEXIT_CORRUPT_FILE_FOUND);
#endif
}
if ((numDimensionIndexValues == 0) && (sliceNumberMrPhilips > 0) && (volumeNumberMrPhilips > 0) && (locationsInAcquisitionPhilips > 0)) {//issue529
int instanceNum = ((volumeNumberMrPhilips-1) * locationsInAcquisitionPhilips) + sliceNumberMrPhilips;
if ((d.imageNum != instanceNum) && (isVerbose))
printWarning("Philips instance number (%d) does not make sense: slice %d of %d, volume %d\n", d.imageNum, sliceNumberMrPhilips, locationsInAcquisitionPhilips, volumeNumberMrPhilips);
d.imageNum = instanceNum;
}
if ((numDimensionIndexValues == 0) && (sliceNumberMrPhilips > 0) && (volumeNumberMrPhilips > 0) && (locationsInAcquisitionPhilips > 0)) {//issue529
int instanceNum = ((volumeNumberMrPhilips-1) * locationsInAcquisitionPhilips) + sliceNumberMrPhilips;
if ((d.imageNum != instanceNum) && (isVerbose))
printWarning("Philips instance number (%d) does not make sense: slice %d of %d, volume %d\n", d.imageNum, sliceNumberMrPhilips, locationsInAcquisitionPhilips, volumeNumberMrPhilips);
d.imageNum = instanceNum;
}
if ((numberOfFrames > 1) && (numDimensionIndexValues == 0) && (numberOfFrames == nSliceMM)) { //issue 372
fidx *objects = (fidx *)malloc(sizeof(struct fidx) * numberOfFrames);
for (int i = 0; i < numberOfFrames; i++) {
Expand Down

0 comments on commit f1ef09f

Please sign in to comment.