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

ValueError: zero-size array to reduction operation minimum which has no identity #135

Open
JaySenthil opened this issue Oct 5, 2024 · 1 comment

Comments

@JaySenthil
Copy link

Hello,

When I run the inference pipeline for spine_muscle_adipose_tissue, I get the following errors for some of my datasets. I believe its because the posterior_anterior_line array is all zeros, which causes np.where to return an empty array, and then np.min to return the error seen below.

Traceback (most recent call last):
File "/sfs/qumulo/qhome//Comp2Comp/comp2comp/utils/process.py", line 131, in process_3d
pipeline(output_dir=output_dir, model_dir=model_dir)
File "/sfs/qumulo/qhome/
/Comp2Comp/comp2comp/inference_pipeline.py", line 73, in call
output = inference_class(inference_pipeline=self, output)
File "/sfs/qumulo/qhome/
/Comp2Comp/comp2comp/inference_pipeline.py", line 69, in call
output = inference_class(
File "/sfs/qumulo/qhome/
/Comp2Comp/comp2comp/spine/spine.py", line 314, in call
spine_utils.compute_rois(
File "/sfs/qumulo/qhome/
/Comp2Comp/comp2comp/spine/spine_utils.py", line 378, in compute_rois
roi, mask_2d = roi_from_mask(
File "/sfs/qumulo/qhome/
/Comp2Comp/comp2comp/spine/spine_utils.py", line 247, in roi_from_mask
np.min(np.where(posterior_anterior_line == 1))
File "<array_function internals>", line 180, in amin
File "/home/
/.conda/envs/c2c/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2918, in amin
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/home/
**/.conda/envs/c2c/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation minimum which has no identity

I'm not sure how to fix the error. Please let me know. Thanks.

@0rC0
Copy link

0rC0 commented Nov 28, 2024

Hello,

Thank you for making this package open-source!

I have encountered the same issue described by @JaySenthil with the spine_muscle_adipose_tissue pipeline (see the log below).

My hypothesis is that the problem lies with the spine segmentation. In my case, the subject has degenerative changes at T9-T11, which causes the spine segmentation to fail. As shown in the mask below from the spine segmentation nifti, one vertebra is segmented into two classes, which likely leads to the failure in the subsequent step.

Additionally, I have three different measurements from the same subject taken in three different years, and the pipeline fails in all cases following a similar spine segmentation issue.

I hope this information helps in resolving the issue. If I can run any tests on the images to assist with debugging, I’d be happy to do so.

Best regards

image

Running SpineComputeROIs with input keys odict_keys(['inference_pipeline'])
Computing ROI with centroid 265.000, 200.569, 41.951 and pixel spacing 0.782mm, 0.782mm, 4.000mm...
Elapsed time for erosion operation: 0.1857156753540039 seconds
Elapsed time for full ROI computation: 0.28458118438720703 seconds
Computing ROI with centroid 267.000, 206.149, 50.350 and pixel spacing 0.782mm, 0.782mm, 4.000mm...
Elapsed time for erosion operation: 0.1831667423248291 seconds
Elapsed time for full ROI computation: 0.2825322151184082 seconds
Computing ROI with centroid 265.000, 212.715, 58.741 and pixel spacing 0.782mm, 0.782mm, 4.000mm...
ERROR PROCESSING ./sub-SK0491_ses-op

Traceback (most recent call last):
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/utils/process.py", line 131, in process_3d
    pipeline(output_dir=output_dir, model_dir=model_dir)
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/inference_pipeline.py", line 73, in __call__
    output = inference_class(inference_pipeline=self, **output)
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/inference_pipeline.py", line 69, in __call__
    output = inference_class(
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/spine/spine.py", line 314, in __call__
    spine_utils.compute_rois(
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/spine/spine_utils.py", line 378, in compute_rois
    roi, mask_2d = roi_from_mask(
  File "/home/orco/data/Sarkopenie/code/Comp2Comp/comp2comp/spine/spine_utils.py", line 247, in roi_from_mask
    np.min(np.where(posterior_anterior_line == 1))
  File "<__array_function__ internals>", line 180, in amin
  File "/home/orco/anaconda3/envs/c2c_env/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2918, in amin
    return _wrapreduction(a, np.minimum, 'min', axis, None, out,
  File "/home/orco/anaconda3/envs/c2c_env/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation minimum which has no identity

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

No branches or pull requests

2 participants