Skip to content

Commit

Permalink
Not all GE DWI with b>0 bvec=0 are trace (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Nov 9, 2018
1 parent 9cf128d commit 99f37fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions console/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion console/nii_dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 99f37fa

Please sign in to comment.