Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NrrdToFSL: DWIConvert vs ConvertBetweenFileFormats #342

Open
reckbo opened this issue Mar 22, 2017 · 4 comments
Open

NrrdToFSL: DWIConvert vs ConvertBetweenFileFormats #342

reckbo opened this issue Mar 22, 2017 · 4 comments
Assignees

Comments

@reckbo
Copy link

reckbo commented Mar 22, 2017

Description

Given an LPS DWI nrrd, DWIConvert makes an LAS nifti, and given a single diffusion volume of that nrrd, ConvertBetweenFileFormats makes an LPS nifti. This has consequences when converting back to nrrd, namely the j in ijk space is flipped in the first case, but remains unchanged and matches the original in the latter case. (The world coordinates are fine and correct).

Issue

Here's an example of where this affected me:

  1. LPS DWI nrrd -> DWIConvert -> LAS nifti -> bet -> ConvertBetweenFileFormats -> LPS DWI mask with j axis flipped
  2. LPS DWI nrrd -> extract baseline -> ConvertBetweenFileFormats -> LPS nifti -> bet -> ConvertBetweenFileformats -> LPS DWI mask with original ijk orientation

Usually I mask a nrrd using unu 3op ifelse but that does so in ijk space, so 1 does not work, but 2 is fine.
So my questions are:

  1. Is there a reason for this discrepancy in behaviour?
  2. Is there a way to mask in world coordinate space?

Reproduce

git clone https://github.com/pnlbwh/BRAINSTools-debug
cd BRAINSTools-debug && make

@hjmjohnson
Copy link
Member

ConvertBetweenFileFormats attempts to maintain the input images direction cosines as closely as possible.

DWIConvert tries to match the FSL standards. Due to the fact that the BVEC and BVAL information is implicitly in an LAS corrdinate system (and the fact that the measurement frame is implicitly an identity matrix), we needed to re-organize some data sets to ensure that a consistent representation from the DWI data was maintained.

@reckbo
Copy link
Author

reckbo commented Mar 22, 2017

Great, thanks.

@ihnorton
Copy link
Collaborator

Due to the fact that the BVEC and BVAL information is implicitly in an LAS corrdinate system (and the fact that the measurement frame is implicitly an identity matrix

@hjmjohnson I'd like to re-open this to discuss the current behavior for FSL Nifti -> NRRD

  1. measurement frame = identity behavior for DWIConvert output when converting
  2. writing FSL bvec file with g[i] = inv(MF) * g_orig[i]

For (1):

  • the gradients in FSL bvec files are expressed with respect to the image axes: link 1, link 2
  • DWIConvert tries to account for this when going DICOM/NRRD -> FSL-bvec by rotating vectors by inv(measurement frame) (but see (2) below)
  • however, when converting FSL Nifti -> NRRD, DWIConvert sets the output measurement frame to identity (without any change to the bvec values)

For (2):
What is the reason for using inv(measurement frame)? Considering that the bvec is expressed with respect to the image axes, shouldn't the transform that takes the vector from image axes to world space be just measurement frame, not inv(mf)? As a concrete example, here is a comparison of two tensor maps computed with FDT, using output from dcm2niix [1] and DWIConvert [2].

[1]
image

[2]
image

@neurolabusc
Copy link

In addition to the links provided by @ihnorton, I would suggest this link. Fortunately, DWI data is is virtually always acquired axially, but if you do encounter coronal or sagittal acquisitions, I would be very cautious of hard coding the LAS reorientation, as Eddy assumes that slices are the 3rd dimension and altering this will impact options like --repol and --slspec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants