Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Replace raise by auto normalization when creating a gradient table with un-normalized bvecs. #452
When using gradients.gradient_table_from_bvals_bvecs with non-normalized bvecs, an exception is currently raised.
I was wondering if auto normalizing the bvecs was a viable alternative to that. This could be either triggered by an 'auto_normalize' parameter or just done if abs(norm - 1) > atol.
If you like the idea I dont mind doing the pull request for this.
I personally think this feature would cause more harm than good. bvecs, as
2000 [1., 0, 0]
Also it might not be obvious to someone else reading the code that the
gtab = gradient_table_from_bvals_bvecs(bvals, normalize(vertors))
It's obvious to anyone reading the code that the directions of
On Tue, Oct 28, 2014 at 9:08 AM, matthieudumont firstname.lastname@example.org
I also think auto-normalizing bvecs is a bad idea. On GE scanners, multi-shell diffusion is achieved by scaling the bvec magnitude in the scanner's tensor.dat file, which is a look-up table of gradient directions to be played out for any particular number of prescribed diffusion directions. And these scaled bvecs are what end up in the DICOM header, along with the prescribed bvalue (which is actually not the correct bvalue for non-unit length bvecs). E.g., the effective bvalue for a particular measurement is the prescribed bvalue stored in the DICOM header * bvec_norm**2. So a typical multi-shell scan on GE will have bvecs with non-unit norms, and auto-normalizing them will create an incorrect gradient table. I suggest making the normalization explicit (as suggested by Bago). If the user has GE vectors (and knows what they are doing) they might use:
gtab = gradient_table_from_bvals_bvecs(bvals_norm(vectors)_*2, normalize(vertors))
On Tue, Oct 28, 2014 at 11:11 AM, Bob Dougherty email@example.com
gtab = GradientTable( bvals[:, np.newaxis] * bvecs )