From 99f37fa1c021c4e30a719fff557e97fb568b3972 Mon Sep 17 00:00:00 2001 From: Chris Rorden Date: Thu, 8 Nov 2018 19:06:17 -0500 Subject: [PATCH] Not all GE DWI with b>0 bvec=0 are trace (https://github.com/rordenlab/dcm2niix/issues/245) --- console/nii_dicom.cpp | 4 ++-- console/nii_dicom.h | 2 +- console/nii_dicom_batch.cpp | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/console/nii_dicom.cpp b/console/nii_dicom.cpp index 09c15a12..b37763ab 100644 --- a/console/nii_dicom.cpp +++ b/console/nii_dicom.cpp @@ -5868,7 +5868,7 @@ if (d.isHasPhase) pow(d.patientPosition[2]-d.patientPositionLast[2],2)+ pow(d.patientPosition[3]-d.patientPositionLast[3],2)); dx = dx / (maxInStackPositionNumber - 1); - if (dx > 0.0) + if ((dx > 0.0) && (!isSameFloatGE(dx, d.xyzMM[3])) ) //patientPosition has some rounding error d.xyzMM[3] = dx; } //d.zSpacing <= 0.0: Bruker does not populate 0018,0088 https://github.com/rordenlab/dcm2niix/issues/241 } //if numDimensionIndexValues > 1 : enhanced DICOM @@ -5935,7 +5935,7 @@ if (d.isHasPhase) #ifndef myLoadWholeFileToReadHeader fclose(file); #endif - //printf("%g\t\t%g\t%g\t%g\n", d.CSA.dtiV[0], d.CSA.dtiV[1], d.CSA.dtiV[2], d.CSA.dtiV[3]); + //printf("%g\t\t%g\t%g\t%g\t%s\n", d.CSA.dtiV[0], d.CSA.dtiV[1], d.CSA.dtiV[2], d.CSA.dtiV[3], fname); //printMessage("buffer usage %d %d %d\n",d.imageStart, lPos+lFileOffset, MaxBufferSz); return d; } // readDICOM() diff --git a/console/nii_dicom.h b/console/nii_dicom.h index 094d0732..678db596 100644 --- a/console/nii_dicom.h +++ b/console/nii_dicom.h @@ -43,7 +43,7 @@ extern "C" { #define kCCsuf " CompilerNA" //unknown compiler! #endif -#define kDCMvers "v1.0.20181107 " kJP2suf kLSsuf kCCsuf +#define kDCMvers "v1.0.20181108 " kJP2suf kLSsuf kCCsuf static const int kMaxEPI3D = 1024; //maximum number of EPI images in Siemens Mosaic static const int kMaxDTI4D = 18000; //maximum number of DTI directions for 4D (Philips) images, also maximum number of 3D slices for Philips 3D and 4D images diff --git a/console/nii_dicom_batch.cpp b/console/nii_dicom_batch.cpp index ed457faf..24f3fbab 100644 --- a/console/nii_dicom_batch.cpp +++ b/console/nii_dicom_batch.cpp @@ -233,8 +233,11 @@ void geCorrectBvecs(struct TDICOMdata *d, int sliceDir, struct TDTI *vx){ float bVal = vx[i].V[0] * (vLen * vLen); printMessage("GE BVal scaled %g -> %g\n", vx[i].V[0], bVal); vx[i].V[0] = bVal; + vx[i].V[1] = vx[i].V[1]/vLen; + vx[i].V[2] = vx[i].V[2]/vLen; + vx[i].V[3] = vx[i].V[3]/vLen; } - if (!col) { //rows need to be swizzled + if (!col) { //rows need to be swizzled //see Stanford dataset Ax_DWI_Tetrahedral_7 unable to resolve between possible solutions // http://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Diffusion_Tensor_Imaging float swap = vx[i].V[1]; @@ -1316,18 +1319,26 @@ int * nii_SaveDTI(char pathoutname[],int nConvert, struct TDCMsort dcmSort[],str float kADCval = maxB0 + 1; //mark as unusual *numADC = 0; bvals = (float *) malloc(numDti * sizeof(float)); + int numGEwarn = 0; for (int i = 0; i < numDti; i++) { bvals[i] = vx[i].V[0]; //printMessage("---bxyz %g %g %g %g\n",vx[i].V[0],vx[i].V[1],vx[i].V[2],vx[i].V[3]); //Philips includes derived isotropic images - if (((dcmList[indx0].manufacturer == kMANUFACTURER_GE) || (dcmList[indx0].manufacturer == kMANUFACTURER_PHILIPS)) && (isADCnotDTI(vx[i]))) { + //if (((dcmList[indx0].manufacturer == kMANUFACTURER_GE) || (dcmList[indx0].manufacturer == kMANUFACTURER_PHILIPS)) && (isADCnotDTI(vx[i]))) { + if (((dcmList[indx0].manufacturer == kMANUFACTURER_GE)) && (isADCnotDTI(vx[i]))) { + numGEwarn += 1; + vx[i].V[0] = 0; + } //see issue 245 + if (((dcmList[indx0].manufacturer == kMANUFACTURER_PHILIPS)) && (isADCnotDTI(vx[i]))) { *numADC = *numADC + 1; bvals[i] = kADCval; //printMessage("+++bxyz %d\n",i); } bvals[i] = bvals[i] + (0.5 * i/numDti); //add a small bias so ties are kept in sequential order } - if (*numADC == numDti ) { + if (numGEwarn > 0) + printWarning("Some images had bval>0 but bvec=0 (either Trace or b=0, see issue 245)\n"); + if ((*numADC == numDti) || (numGEwarn == numDti)) { //all isotropic/ADC images - no valid bvecs *numADC = 0; free(bvals);