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

Fix dwi convert #315

Merged
merged 60 commits into from
Dec 11, 2016
Merged

Fix dwi convert #315

merged 60 commits into from
Dec 11, 2016

Conversation

hjmjohnson
Copy link
Member

This is a substantial re-write and re-organzation of the DWIConvert program to provide for better organization, a central consistent data model, and extensive test suite.

The rewrite helped to identify corner cases where conversion to/from FSL was often not performed correctly.

ihnorton and others added 30 commits December 10, 2016 10:43
Allows to convert DICOM series encoded with JPEG transfer syntax. ITK only registers these in one place (ITK::DCMTKImageIO), and that is too late for DWIConvert because it uses itkDCMTKSeriesFileNames to make a file list before directly (re-)reading the files.

Please see discussion: http://slicer-users.65878.n3.nabble.com/DWI-to-DTI-convertion-td4031356.html
The atlas data was not referenced properly for testing.
DCMTK needs a very new revision that includes bug fixes
when compiling in C++11 mode.
Version 4.8.0 is a major update for the DWIConvert program
to fix problems with DWI processing interactions between
FSL and NRRD based DWI processing tools.
This patch set provides some more checking regarding the imaging sequence
so that we can better identify how each images is megin written.
Nifti images can have both QForm and SForm matricies.
When converting from DICOM, and either form is sufficient
to fully understand the SCANNER_ANAT.

Prefer to use only ONE of these so that there is no
mis-interpretation.

{
   //Set the qform and sfrom codes for the MetaDataDictionary.
   itk::MetaDataDictionary & thisDic = img4D->GetMetaDataDictionary();
   itk::EncapsulateMetaData< std::string >( thisDic, "qform_code_name", "NIFTI_XFORM_SCANNER_ANAT" );
   itk::EncapsulateMetaData< std::string >( thisDic, "sform_code_name", "NIFTI_XFORM_UNKNOWN" );
}
The origin for a mosaic image was not being properly identified
in the previous version of the code.  After investigation,
the correct computation for the origin was found.

With this patch set, the T1 morphometric images and the DWI images
are almost perfectly overlapped.
Make variable more descriptive, and place code in more localized
conditionals to reduce the amount of logic conditionals.
m_LPSDirCos and m_NRRDSpaceDirection were possible to be out of sync.
Compute GetNRRDSpaceDirection as needed, and always modify the m_LPSDirCos
to represent the correct orientation of the data.
Encapsulate the writting of Nrrd file to a function so
that the code is more self-contained and re-usable.
Simplifying interface now that the state of the object
is completely internal to the converter class.
The DWICompare program needs to be able to compare measurement
frames in both native format, and in identity measurement rotated
frames of reference.

The DWICompare program was also re-written to use the
validator common code shared by DWIConverter and DWICompare.
Using FSL to visualize the data revealed that it had
been incorrectly created.  After fixing DWIConvert
this test was failing because the reference test data
was incorrect.

When compared to dcm2niix orientation bugs were fixed
and manual visualization confirmed that this new data
set has correct orientations.
Converting from NHDR to FSL to NRRD needs larger tolerance
for the origin to accomodate miniute numerical differences.
In order to improve conformance with other FSL
based tools, DWIConvert reorganizes data when
writing out FSL based files.  It also re-organizes
data when reading from FSL files to match historical
LPS/DICOM data organization that is stored in NRRD/NHDR
files.

These validation scripts for orientation testing

The attached scripts provide mechanisms for writing and visualizing
DTI images in both Slicer and FSL to ensure that data orientation
representation are consistent for tensor based analysis.
There is no need to compute the max bvalue inline.
ITK DICOM reader already computes the rows & column size of the images, so
there is no need to do it again.
These are not changes, but removal of comments that do not need to be addressed.
Extract dicom information and place in NRRD headers as a means of preserving
information.
When converting between different data representation (i.e. FSL vs NRRD) we
need to ensure that the entire data model remains consistent.

Pulling values that must change in unison into consistent single transaction
events can assist with the migration between different data representations.
The slice ordering needs to be corrected based on SI orientation for both
direction cosines and measurement frames!

This also allows makes the math easier to follow with respect to
the gradient directions and how they are represented.
Keep the main DWIConverter class free of unnecessary member vars/functions.
The measurement frame implicit representations need to be managed properly
for reading/writing BVec values and storing in nhdr or .bvec files.

This implicitly reads and flips FSL formatted files into Identity Dicom orientation
so that round trip to/from FSL results in consistent NRRD file header definition
as long as the starting NRRD file has identity measurement frame and nearly identity
direction cosines.
When using a refactoring tool, std::endl was replaced
by a compiler specific equivalent of std::__1::endl that
is not portable across compilers.  This was a mistake.
C++11 syntax needed to be removed.
Restore the --allowLossyConversion behavior for cases where the
input image is not a short int image type.
The same output file name can not be used for more than one test
to avoid parallel testing to pass all the time.
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

Successfully merging this pull request may close these issues.

2 participants