Skip to content

Commit

Permalink
[bug] avoid overwriting mua/mus when one is nan, fix #224, fix #225
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jul 14, 2024
1 parent 80b5794 commit 78716e4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,7 @@ void mcx_loadvolume(char* filename, Config* cfg, int isbuf) {
for (i = 0; i < datalen; i++) {
f2h[0] = val[i << (1 + offset)] * cfg->unitinmm; // mua
f2h[1] = val[(i << (1 + offset)) + 1] * cfg->unitinmm; // mus
cfg->vol[i] = mcx_float2half2(f2h);

if (f2h[0] != f2h[0] || f2h[1] != f2h[1]) { /*if one of mua/mus is nan in continuous medium, convert to 0-voxel*/
cfg->vol[i] = 0;
Expand All @@ -3532,12 +3533,9 @@ void mcx_loadvolume(char* filename, Config* cfg, int isbuf) {
}

if (cfg->mediabyte == MEDIA_ASGN_F2H) {
cfg->vol[i] = mcx_float2half2(f2h);
f2h[0] = val[(i << 2) + 2]; // g
f2h[1] = val[(i << 2) + 3]; // n
cfg->vol[i + datalen] = mcx_float2half2(f2h);
} else {
cfg->vol[i] = mcx_float2half2(f2h);
}
}
} else if (cfg->mediabyte == MEDIA_2LABEL_SPLIT) {
Expand Down

0 comments on commit 78716e4

Please sign in to comment.