From ad0e1c8fc0bc1160045184d412ba0109526db7f2 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Mon, 27 Apr 2020 10:45:52 -0400 Subject: [PATCH] Discrepant uses for TriggerTime (https://github.com/rordenlab/dcm2niix/issues/395) --- Philips/README.md | 2 +- console/nii_dicom.cpp | 16 ++++++++++++---- console/nii_dicom.h | 2 +- console/nii_dicom_batch.cpp | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Philips/README.md b/Philips/README.md index eaae15ff..6813e9b6 100644 --- a/Philips/README.md +++ b/Philips/README.md @@ -90,7 +90,7 @@ MyCustomDirections ``` -## Missing Information. +## Missing Information Philips DICOMs do not contain all the information desired by many neuroscientists. Due to this, the [BIDS](http://bids.neuroimaging.io/) files created by dcm2niix are impoverished relative to data from other vendors. This reflects a limitation in the Philips DICOMs, not dcm2niix. diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 9be99df9..3fbd5edc 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -4354,6 +4354,8 @@ uint32_t kItemTag = 0xFFFE +(0xE000 << 16 ); uint32_t kItemDelimitationTag = 0xFFFE +(0xE00D << 16 ); uint32_t kSequenceDelimitationItemTag = 0xFFFE +(0xE0DD << 16 ); double TE = 0.0; //most recent echo time recorded +float MRImageDynamicScanBeginTime = 0.0; + bool is2005140FSQ = false; bool isDICOMANON = false; //issue383 bool isMATLAB = false; //issue383 @@ -4580,7 +4582,10 @@ double TE = 0.0; //most recent echo time recorded dcmDim[numDimensionIndexValues].intenScalePhilips = d.intenScalePhilips; dcmDim[numDimensionIndexValues].RWVScale = d.RWVScale; dcmDim[numDimensionIndexValues].RWVIntercept = d.RWVIntercept; - dcmDim[numDimensionIndexValues].triggerDelayTime = d.triggerDelayTime; + if (isSameFloat(MRImageDynamicScanBeginTime * 1000.0, d.triggerDelayTime)) + dcmDim[numDimensionIndexValues].triggerDelayTime = 0.0; //issue395 + else + dcmDim[numDimensionIndexValues].triggerDelayTime = d.triggerDelayTime; dcmDim[numDimensionIndexValues].V[0] = -1.0; #ifdef MY_DEBUG if (numDimensionIndexValues < 19) { @@ -5657,9 +5662,9 @@ double TE = 0.0; //most recent echo time recorded case kMRImageDynamicScanBeginTime: { //FL if (lLength != 4) break; - float dyn = dcmFloat(lLength, &buffer[lPos],d.isLittleEndian); - if (dyn < minDynamicScanBeginTime) minDynamicScanBeginTime = dyn; - if (dyn > maxDynamicScanBeginTime) maxDynamicScanBeginTime = dyn; + MRImageDynamicScanBeginTime = dcmFloat(lLength, &buffer[lPos],d.isLittleEndian); + if (MRImageDynamicScanBeginTime < minDynamicScanBeginTime) minDynamicScanBeginTime = MRImageDynamicScanBeginTime; + if (MRImageDynamicScanBeginTime > maxDynamicScanBeginTime) maxDynamicScanBeginTime = MRImageDynamicScanBeginTime; break; } case kIntercept : @@ -6739,6 +6744,9 @@ if (d.isHasPhase) strcpy(d.seriesInstanceUID, d.studyInstanceUID); d.seriesUidCrc = mz_crc32X((unsigned char*) &d.protocolName, strlen(d.protocolName)); } + if (isSameFloat(MRImageDynamicScanBeginTime * 1000.0, d.triggerDelayTime)) //issue395 + d.triggerDelayTime = 0.0; + //printf("%d\t%g\t%g\t%g\n", d.imageNum, d.acquisitionTime, d.triggerDelayTime, MRImageDynamicScanBeginTime); if ((d.manufacturer == kMANUFACTURER_SIEMENS) && (strlen(seriesTimeTxt) > 1) && (d.isXA10A) && (d.xyzDim[3] == 1) && (d.xyzDim[4] < 2)) { //printWarning("Ignoring series number of XA data saved as classic DICOM (issue 394)\n"); d.isStackableSeries = true; diff --git a/console/nii_dicom.h b/console/nii_dicom.h index 31931558..d3fd435b 100644 --- a/console/nii_dicom.h +++ b/console/nii_dicom.h @@ -43,7 +43,7 @@ extern "C" { #define kCCsuf " CompilerNA" //unknown compiler! #endif -#define kDCMdate "v1.0.20200420" +#define kDCMdate "v1.0.20200427" #define kDCMvers kDCMdate " " kJP2suf kLSsuf kCCsuf static const int kMaxEPI3D = 1024; //maximum number of EPI images in Siemens Mosaic diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index 092d07c6..9068bff5 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -4851,7 +4851,10 @@ int saveDcm2NiiCore(int nConvert, struct TDCMsort dcmSort[],struct TDICOMdata dc #endif int imageNumRange = 1 + abs( dcmList[dcmSort[nConvert-1].indx].imageNum - dcmList[dcmSort[0].indx].imageNum); if ((imageNumRange > 1) && (imageNumRange != nConvert)) { - printWarning("Missing images? Expected %d images, but instance number (0020,0013) ranges from %d to %d\n", nConvert, dcmList[dcmSort[0].indx].imageNum, dcmList[dcmSort[nConvert-1].indx].imageNum); + if ((dcmList[dcmSort[0].indx].locationsInAcquisition > 0) && ((nConvert % dcmList[dcmSort[0].indx].locationsInAcquisition) != 0) ) + printError("Missing images. Found %d images, expected %d slices per volume and instance number (0020,0013) ranges from %d to %d\n", nConvert, dcmList[dcmSort[0].indx].locationsInAcquisition, dcmList[dcmSort[0].indx].imageNum, dcmList[dcmSort[nConvert-1].indx].imageNum); + else + printWarning("Missing images? Expected %d images, but instance number (0020,0013) ranges from %d to %d\n", nConvert, dcmList[dcmSort[0].indx].imageNum, dcmList[dcmSort[nConvert-1].indx].imageNum); if (opts.isVerbose) { printMessage("instance=["); for (int i = 0; i < nConvert; i++) {