Closed demidenm closed 1 year ago
The issue here is that this function:
Needs to decide what to do if a label contains no voxels. Should it be dropped, or should the results all be None
or nan
, or is raising an exception appropriate? If raising an exception is appropriate, all interfaces that call it should check for that exception and decide how to handle this case, as interfaces should not raise exceptions for empty ROIs.
@mckenziephagen or @celprov could I ask one of you to make the call on this? My guess is that either the ROI should be dropped or filled with nan
s, and then any calling code should verify that the result isn't empty or that nans are properly handled. But you are much more in the weeds of how MRIQC works/should work than I am...
@demidenm Would you be interested in submitting a PR once a decision is made?
@effigies - Thanks for the follow up, Chris. Do you suggest that the issue is with the final values so updating to something such as?
if not img:
output = {
"mean": np.nan,
"stdv": np.nan,
"median": np.nan,
"mad": np.nan,
"p95": np.nan,
"p05": np.nan,
"k": np.nan,
"n": np.nan,
}
else:
output = {
"mean": float(img[mask == 1].mean()),
"stdv": float(img[mask == 1].std()),
"median": float(np.median(img[mask == 1])),
"mad": float(mad(img[mask == 1])),
"p95": float(np.percentile(img[mask == 1], 95)),
"p05": float(np.percentile(img[mask == 1], 5)),
"k": float(kurtosis(img[mask == 1])),
"n": nvox,
}
I had a very quick look through earlier, but looking at it again, it seems a solution is already there for one ROI, we just need to make it accessible to other ROIs:
Why not just:
- if k == "bg":
- output["bg"] = {
+ if k == "bg" or nvox == 0:
+ output[k] = {
@effigies That makes more sense! Incorrectly misread the no voxels as empty img 🤦♂️
Running MRIQC (singularity: nipreps/mriqc:22.0.6) and have an error that @effigies described as, "interface is not checking for empty masks before masking." Out of on the ~15706 session data, this has occurred for 27 subjects. It appears as though this is an issue that has come up in older version, see issue #868. I cleared the working scratch folders and retried on a subject to no avail.
Curious how I may troubleshoot this error.
The MRIQC command:
Error log:
Crash log: