Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion console/nii_dicom.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern "C" {
#define kCPUsuf " " // unknown CPU
#endif

#define kDCMdate "v1.0.20250626"
#define kDCMdate "v1.0.20250827"
#define kDCMvers kDCMdate " " kJP2suf kTurbosuf kLSsuf kCCsuf kCPUsuf

static const int kMaxEPI3D = 1024; // maximum number of EPI images in Siemens Mosaic
Expand Down
19 changes: 13 additions & 6 deletions console/nii_dicom_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ void geCorrectBvecs(struct TDICOMdata *d, int sliceDir, struct TDTI *vx, int isV
if (abs(sliceDir) != 3)
printWarning("Limited validation for non-Axial DTI: confirm gradient vector transformation.\n");
// GE vectors from Xiangrui Li' dicm2nii, validated with datasets from https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage#Diffusion_Tensor_Imaging
//
// GE → FSL bvec (see issue 970) for unit vector
// 1) Apply plane-dependent flip first
// 2) Always negate Y
// 3) ROW swap/flip (if !col)
// 4) Negate all components (compatibility)
ivec3 flp;
if (abs(sliceDir) == 1)
flp = setiVec3(1, 1, 0); // SAGITTAL
Expand Down Expand Up @@ -353,18 +359,19 @@ void geCorrectBvecs(struct TDICOMdata *d, int sliceDir, struct TDTI *vx, int isV
vx[i].V[2] = vx[i].V[2] * bVecScale;
vx[i].V[3] = vx[i].V[3] * bVecScale;
}
for (int v = 0; v < 3; v++)
if (flp.v[v] == 1)
vx[i].V[v + 1] = -vx[i].V[v + 1];
vx[i].V[2] = -vx[i].V[2]; // we read out Y-direction opposite order as dicm2nii, see also opts.isFlipY
// 3) ROW swap/flip (if !col) (see issue 970)
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];
vx[i].V[1] = vx[i].V[2];
vx[i].V[2] = swap;
vx[i].V[2] = -vx[i].V[2]; // because of transpose?
}
for (int v = 0; v < 3; v++)
if (flp.v[v] == 1)
vx[i].V[v + 1] = -vx[i].V[v + 1];
vx[i].V[2] = -vx[i].V[2]; // we read out Y-direction opposite order as dicm2nii, see also opts.isFlipY
vx[i].V[1] = -vx[i].V[1]; // because of transpose?
}
}
// These next lines are only so files appear identical to old versions of dcm2niix:
// dicm2nii and dcm2niix generate polar opposite gradient directions.
Expand Down