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
notes on thd_niftiread.c #324
base: master
Are you sure you want to change the base?
Conversation
src/thd_initdblk.c
Outdated
float fracdiff; | ||
|
||
fracdiff = frac_diff(atr_flt->fl[0], | ||
dset->daxes->ijk_to_dicom_real.m[0][0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the float var here should have the same name as the function---it makes my head hurt. (Perhaps it should make the compiler's head hurt, too.)
src/thd_initdblk.c
Outdated
float fracdiff; | ||
|
||
if (fabs(old) + fabs(new) != 0) { | ||
fracdiff = fabs(old - new) / (fabs(old) + fabs(new)); | ||
} else { | ||
fracdiff = 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about perhaps:
float fracdiff, denom;
denom = fabs(old) + fabs(new);
if (denom) {
fracdiff = 2 * fabs(old - new) / denom;
} else {
fracdiff = 0.;
}
... which calculates the denominator only once? A factor of 2 in the numerator makes sense to me, from the point of view of considering the denominator to be the average of old and new.
src/thd_initdblk.c
Outdated
int label_c = 0, count_o = 0, count_i = 0; | ||
|
||
if (validate) { /* disco change */ | ||
// should I free these vaiables at the end of the if statement? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A free is only needed when using a corresponding malloc/calloc/realloc.
for testing things out: to go into ni_attr branch