Skip to content

Commit

Permalink
Merge pull request #137 from pnlbwh/bzero-thresh
Browse files Browse the repository at this point in the history
Determine bzero based on absolute s/mm^2
  • Loading branch information
tashrifbillah authored Jan 6, 2021
2 parents 2e485b4 + 9158312 commit 751cc1a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ukf/dwi_normalize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ void dwiNormalize(const Nrrd *raw, Nrrd *& normalized)
char *value;
nrrdKeyValueIndex(raw, &key, &value, i);
std::string keyStr(key);

// Obtain DWMRI_b-value
int bmax;
if( keyStr.length() == 13 && !keyStr.compare("DWMRI_b-value") )
{
sscanf(value, "%d", &bmax);
std::cout << "DWMRI_b-value " << bmax << std::endl;

}


if( keyStr.length() > 14 && !keyStr.substr(0, 14).compare("DWMRI_gradient") )
{
float gx, gy, gz;
Expand All @@ -64,8 +75,12 @@ void dwiNormalize(const Nrrd *raw, Nrrd *& normalized)
std::cout << "The gradients must have 3 components!" << std::endl;
throw;
}

const float gradient_magnitude = sqrt(gx * gx + gy * gy + gz * gz);
nonZeroGradientFlag.push_back( gradient_magnitude > 0.05F );

// See https://github.com/pnlbwh/ukftractography/issues/136#issuecomment-753173654
// for details about the following criteria
nonZeroGradientFlag.push_back( bmax * gradient_magnitude * gradient_magnitude > 50 );
}
keyValuePairsOfRaw.push_back(std::make_pair(std::string(key), std::string(value)) );
free(key); //Key and value generated by Nrrd by malloc, so free needs to be used.
Expand Down

0 comments on commit 751cc1a

Please sign in to comment.