BRAINSia / BRAINSTools

A suite of tools for medical image processing focused on brain analysis
http://brainsia.github.io/BRAINSTools/
Apache License 2.0
111 stars 96 forks source link

When writing bvec,bval files, the bvec values should all be unit norm #78

Closed hjmjohnson closed 10 years ago

hjmjohnson commented 10 years ago

Kent,

When writing bvec files, the vectors all need to be normalized to unit length. For this format, the magnitude of the bval is encoded separately from the directions. (in the NRRD files they are combined).

Could you make this change quickly?

Thanks, Hans

hi martin and hans,

indeed the place where the issue is in the conversion. i would like to note that even with single b-values, scanners cannot always hit the right target, so when q is estimated from the B matrix, you can often see values that are around the target but not exactly equal to it.

so far a bmax of 1000, you might see values as seen in this scan: 995, 974, etc.,. depending on the gradient direction and the gradients that came before it.

martin: there is no standard. but i think if we wrote out fsl style, then doing bvecs as unit norm and bvals reflecting magnitude makes sense.

cheers,

satra

On Wed, Jan 22, 2014 at 11:12 AM, Johnson, Hans J hans-johnson@uiowa.edu wrote: Martin’s comments are a good guess that it is a bug in DWIConvert for nrrd files.

It should be a very easy fix. We have always been working with single b-value DWI’s so we probably missed the norming step.

Hans

From: Martin Styner martin_styner@me.com Date: Wednesday, January 22, 2014 at 10:08 AM To: Satrajit Ghosh satra@mit.edu Cc: Francois Budin francois.budin@gmail.com, Hans Johnson hans.j.johnson@gmail.com, Kent Williams norman-k-williams@uiowa.edu

Subject: Re: vector norms from DTIPrep

Hi Satra

Not 100% where the problem is, but likely in NRRD to FSL conversion. In NRRD, the bvecs are NOT unit norm, but rather the norm scales the single b-value recorded in the header. For FSL, you have a bval file with different bvalues per DWI (different to NRRD), so my expectation is an imperfect conversion from NRRD to FSL, where all the bvals are the same and the bvecs scale the ovals (rather than all the bvals should be slightly different and the bvecs should be unit norm).

If the unit norm requirement on the bvecs a “standard” for the nifti DWI format, or does FSL simply assume so?

Martin

Martin Styner, PhD. MS ETH Associate Professor Neuro Image Analysis and Research Lab Carolina Institute of Developmental Disabilities Departments of Psychiatry and Computer Science CB 7160, University of North Carolina at Chapel Hill Chapel Hill, NC 27599-7160 Cell: 919 260 6674 Fax: 919 962 1799

On Jan 22, 2014, at 11:01 AM, Satrajit Ghosh satra@mit.edu wrote:

update:

the norm of the bvecs are representing the percentage of bmax, i.e. the bvals. i think if we are writing out bvecs and bvals, the bvecs should be unit norm, no?

cheers,

satra

On Wed, Jan 22, 2014 at 10:48 AM, Satrajit Ghosh satra@mit.edu wrote: hi folks,

i'm seeing the following from an older version of DTIprep.

In [5]: bvecs = np.genfromtxt('P9_QCed.bvec')
In [6]: vector_norm(bvecs)
Out[6]: 
array([ 0.        ,  1.00000001,  0.99999999,  1.00000006,  0.99999999,
        1.0000001 ,  0.97467948,  1.00000006,  0.97467935,  1.00000006,
        0.9999999 ,  0.97467951,  0.99999998,  0.97467948,  0.99999991,
        1.00000009,  0.9746795 ,  1.        ,  0.99999993,  1.00000008,
        0.99999996,  1.        ,  1.00000009,  1.00000014,  0.97467939,
        0.97467938,  1.00000009,  1.        ,  1.00000005,  1.00000011,
        1.0000001 ,  0.99999996,  1.00000002,  0.99999979,  1.00000004,
        0.99999999,  0.97467945,  0.97467947,  1.00000007,  1.00000016,
        0.97467938,  1.00000005,  0.99999994,  0.97467936,  0.99999998,
        0.97467946,  1.00000003,  1.00000003,  0.97467924,  0.99999995,
        0.99999998,  0.99999973,  0.97467948,  1.00000003,  1.00000008,
        0.97467943,  1.00000008,  1.00000006,  1.00000001,  0.99999997,
        1.        ,  0.99999998])

as you can see many of the vector norms are not that close to 1 and is therefore throwing off some tools i am using.

just checking if this is something you have come across and fixed in more recent versions.

processing route: dicoms -> nrrd -> dtiprep -> fsl

cheers,

satra

ps. i'm trying to compile the latest - running into some qt issues - but that's my problem.

Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.

Chaircrusher commented 10 years ago

fixed, checked into BRAINStools. Tag updated in NamicExternalProjects to pull in the normalization change.

Don't know best way to get the fix to Satra.