Skip to content

Commit f1e0b61

Browse files
authored
Merge pull request #971 from mr-jaemin/development
bvec signs for GE DTI with Coronol + ROW (#970)
2 parents deed8f3 + 5820389 commit f1e0b61

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

console/nii_dicom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern "C" {
5757
#define kCPUsuf " " // unknown CPU
5858
#endif
5959

60-
#define kDCMdate "v1.0.20250626"
60+
#define kDCMdate "v1.0.20250827"
6161
#define kDCMvers kDCMdate " " kJP2suf kTurbosuf kLSsuf kCCsuf kCPUsuf
6262

6363
static const int kMaxEPI3D = 1024; // maximum number of EPI images in Siemens Mosaic

console/nii_dicom_batch.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ void geCorrectBvecs(struct TDICOMdata *d, int sliceDir, struct TDTI *vx, int isV
303303
if (abs(sliceDir) != 3)
304304
printWarning("Limited validation for non-Axial DTI: confirm gradient vector transformation.\n");
305305
// GE vectors from Xiangrui Li' dicm2nii, validated with datasets from https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Diffusion_Tensor_Imaging
306+
//
307+
// GE → FSL bvec (see issue 970) for unit vector
308+
// 1) Apply plane-dependent flip first
309+
// 2) Always negate Y
310+
// 3) ROW swap/flip (if !col)
311+
// 4) Negate all components (compatibility)
306312
ivec3 flp;
307313
if (abs(sliceDir) == 1)
308314
flp = setiVec3(1, 1, 0); // SAGITTAL
@@ -353,18 +359,19 @@ void geCorrectBvecs(struct TDICOMdata *d, int sliceDir, struct TDTI *vx, int isV
353359
vx[i].V[2] = vx[i].V[2] * bVecScale;
354360
vx[i].V[3] = vx[i].V[3] * bVecScale;
355361
}
362+
for (int v = 0; v < 3; v++)
363+
if (flp.v[v] == 1)
364+
vx[i].V[v + 1] = -vx[i].V[v + 1];
365+
vx[i].V[2] = -vx[i].V[2]; // we read out Y-direction opposite order as dicm2nii, see also opts.isFlipY
366+
// 3) ROW swap/flip (if !col) (see issue 970)
356367
if (!col) { // rows need to be swizzled
357368
// see Stanford dataset Ax_DWI_Tetrahedral_7 unable to resolve between possible solutions
358369
// http://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Diffusion_Tensor_Imaging
359370
float swap = vx[i].V[1];
360371
vx[i].V[1] = vx[i].V[2];
361372
vx[i].V[2] = swap;
362-
vx[i].V[2] = -vx[i].V[2]; // because of transpose?
363-
}
364-
for (int v = 0; v < 3; v++)
365-
if (flp.v[v] == 1)
366-
vx[i].V[v + 1] = -vx[i].V[v + 1];
367-
vx[i].V[2] = -vx[i].V[2]; // we read out Y-direction opposite order as dicm2nii, see also opts.isFlipY
373+
vx[i].V[1] = -vx[i].V[1]; // because of transpose?
374+
}
368375
}
369376
// These next lines are only so files appear identical to old versions of dcm2niix:
370377
// dicm2nii and dcm2niix generate polar opposite gradient directions.

0 commit comments

Comments
 (0)