Open jcohenadad opened 5 years ago
Slightly related, but during my PhD I always just handled the outputs (second option) for all methods where voxels were independently processed (except for the case of the divisor being equal exactly to 0, obviously). This let me handle functionality “spurious values” for all my methods the same way i.e. I could reuse masking functions (filter out values beyond a range), and then save masks of those voxels. I would set the values to 0 (as I would with any other mask), but provide the accompanying "outlier" mask & values map for further quality assurance if desired.
That was my logic behind it, anyways.
Doing it after also lets you handle your outlier mask with more representative values (i.e. NaN for true divisions by 0 vs the true values of small divisors.), things like that. But this was just my own preference, there might be a better workflow that someone else is using.
@spinicist, care to chime in on what you do in QUIT?
Sadly, I currently do very little in this situation.
The models which require non-linear fitting have the ability to detect bad input data or fitting failures and inform the user (a message is printed for each voxel that fails). Most of the time the problem is a bad mask that includes background.
I think the only straight division in QUIT is in the MTSat program. This does absolutely nothing about bad values. Because MTSat is a simple calculation and not a non-linear fit, it uses the ITK ParallelizeImageRegion
function and so it would be quite tedious to add per-voxel error reporting (I'd need mutexes or similar to avoid race conditions in the print statements). I suppose a simple solution could be a flag that I set on encountering bad values and then I print a single message at the end (I quite like this idea). It would also be fairly straightforward to make it detect NaN
or Inf
and clamp those a particular value, but currently I don't do that.
I'm not sure there is a particularly good way to solve this beyond reporting suspicious values during processing. In my experience a division by zero (or small value) is either a bug or the result of a bad mask that included background regions - hence if the program reports a bad value people should check their masks and reprocess?
hey team! what should be the strategy for handling division by zero (or epsilon) when computing MTR (this applies to other methods too, e.g. MTsat)?
What should be X: zeros? nan? inf?
I've been trying to handle this at both levels (during the division process, and at the output level), to provide maximum flexibility. See an example here (feedback welcome :-)).