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

notes on thd_niftiread.c #324

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

notes on thd_niftiread.c #324

wants to merge 13 commits into from

Conversation

afniHQ
Copy link
Contributor

@afniHQ afniHQ commented Dec 13, 2021

for testing things out: to go into ni_attr branch

Comment on lines 1146 to 1149
float fracdiff;

fracdiff = frac_diff(atr_flt->fl[0],
dset->daxes->ijk_to_dicom_real.m[0][0]);
Copy link
Contributor

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.)

Comment on lines 730 to 736
float fracdiff;

if (fabs(old) + fabs(new) != 0) {
fracdiff = fabs(old - new) / (fabs(old) + fabs(new));
} else {
fracdiff = 0;
}
Copy link
Contributor

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.

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?
Copy link
Contributor

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.

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.

None yet

4 participants