-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Atropos - Error when using 3 class tissue segmentation #1765
Comments
Thanks for the command and data. I think the problem is that there are zero voxels with label 3 in the segmentation. If I dilate the mask, it works for me. |
Thanks so much for the quick reply, I am trying to get some scripts updated to work with the newest version of ants. Maybe this should addressed as a bug for fixing or detailed somewhere in the documentation |
There was a bug in the parzen window code where it would fail if multi-threaded, so if you run 2.3.5 to check, use one thread. I'll build 2.3.5 and check in a bit |
Thanks, something I forgot to mention, I can reproduce the error in 2.5.2 when I remove the parzen window option and just use defaults. Just an FYI incase you are testing. |
Thanks, yes I switched to Gaussian to avoid that other bug. I couldn't build 2.3.5 but I was able to run the binaries for 2.4.1, and it works. Will track down the release where this occurs. |
OK, it works with 2.5.1 but not 2.5.2. @ntustison, would you mind taking a look when you have time? The simplified command I was running with the example data above:
It works on 2.5.1 but with 2.5.2, it gives this error
|
Could try a git bisect to find the exact commit which did it. |
You're setting up your initial partitioning of the masked region with the three probability images (I'm guessing 1: amygdala, 2: hippocampus, and 3: cortex. Just probing the values in the mask, it would appear to me that no voxels are being assigned to the third label because one or both of the probabilities of the first two labels for all the voxels in the mask are greater than the corresponding probabilities of the third. Did you check that this isn't the case? |
That is what's happening, yes. But this did not cause an error in ANTs 2.5.1 and earlier. Earlier versions did produce the warning
but then ran successfully. The output posteriors for class 3 were very small, and there were no class 3 labels in the output, but it didn't exit with the error. |
If this is that degenerate case, it shouldn't go past initialization because the distribution for the third label is unknown without any representative samples. Perhaps a better use of time would be a check and a better explanation of the error, rather than tracking down why it "worked" before. Although if i had to guess, it is probably due to keeping the sample list around and some check that I'm doing. |
Okay @cookpa , see if the above proposed solution works for you. I did a brief look to figure out why it worked before but I didn't see anything obvious. |
Thanks @ntustison @grahamlittlephd I think @ntustison is correct that it's better to error in this situation because the algorithm updates based on voxels labeled as a class, not just voxels with a non-zero prior probability. Maybe it would make sense to extend the ROI or maybe even have a separate ROI representing cortex, so that Atropos has some sense of what cortex looks like |
Related a bit---@grahamlittlephd, are you interested in segmenting the amygdala and hippocampus? If so, I can point you to functionality in our deep learning library which does this. |
Thanks so much for looking into this! I agree that raising an error at least prevents the user from getting into this situation. However, this still doesn't explain why the behavior of Atropos changed from 2.5.1 to 2.5.2. In 2.5.1 I always would get 3-classes in my output even if there are only a few voxels in label 3 (cortex). I have ran this command on at least 500 subjects. Now in version 2.5.2 there are only 2-classes in my output and the error was thrown. I realize this is very much an edge case but you may want to consider finding the commit that did it like @gdevenyi mentioned, otherwise are you sure that this version update didn't effect other ants tools? |
Very cool didn't know this existed. Not for this project but will add for something to try out at some point 👍 |
It shouldn't have worked. I don't know exactly why it did. I have my hunches but, as I mentioned above, it's not worth my time to go back and investigate.
I can't guarantee that it didn't but I highly doubt that it did. |
We should have better automated regression testing but I think the sampling updates are good, I ran
which produces identical results on 2.5.2, 2.5.1, 2.4.1. |
Thanks for checking @cookpa. Is there anything outstanding for this issue or can we close it? |
I think we can close this. Sorry this solution is not very convenient @grahamlittlephd, but Atropos was not intended to run when one of the classes is not present inside the mask. |
Operating system and version
Ubuntu 22.04
CPU architecture
x86_64 (PC, Intel Mac, other Intel/AMD)
ANTs code version
2.5.2
ANTs installation type
Downloaded Github release binaries
Summary of the problem
Getting the following error when running a 3 class tissue segmentation of the hippocampus/amygdala.
Progress:
WARNING: In /home/runner/work/ANTs/ANTs/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx, line 57
HistogramParzenWindowsListSampleFunction (0x55a3c60883d0): The input list sample has <= 1 element.Function evaluations will be equal to 0.
Iteration 0 (of 5): posterior probability = 0 (annealing temperature = 1)
itk::ExceptionObject (0x55a3c60b8cf0)
Location: "unknown"
File: /home/runner/work/_temp/build/staging/include/ITK-5.4/itkLabelMap.hxx
Line: 180
Description: ITK ERROR: LabelMap(0x55a3c6f42450): Can't access label object at position 2. The label map has only 2 label objects registered
Seems to work with v2.3.5.post76-g28dd25c
Note if I change the number of classes to 2, without changing any other input the command works
Commands to reproduce the problem.
Atropos -a 122317_b0b1000_MD_plusFA.nii.gz -x 122317_initialization_LEFT_HIPPOAMYG.nii.gz -i PriorProbabilityImages[3,122317_initialization_INITAMYGHIPPO_LH_%02d.nii.gz,0.3,0.0001] -m [0.3, 2x2x2] --use-partial-volume-likelihoods false -s 1x3 -s 1x2 -o [122317_initialization_INITAMYGHIPPO_LH_LABELS.nii.gz, 122317_initialization_INITAMYGHIPPO_LH_PROBS_%02d.nii.gz] -k HistogramParzenWindows[1.0,32] -v 1
Output of the command with verbose output.
"""Atropos -a 122317_b0b1000_MD_plusFA.nii.gz -x 122317_initialization_LEFT_HIPPOAMYG.nii.gz -i PriorProbabilityImages[3,122317_initialization_INITAMYGHIPPO_LH_%02d.nii.gz,0.3,0.0001] -m [0.3, 2x2x2] --use-partial-volume-likelihoods false -s 1x3 -s 1x2 -o [122317_initialization_INITAMYGHIPPO_LH_LABELS.nii.gz, 122317_initialization_INITAMYGHIPPO_LH_PROBS_%02d.nii.gz] -k HistogramParzenWindows[1.0,32] -v 1
Running Atropos for 3-dimensional images.
Progress:
WARNING: In /home/runner/work/ANTs/ANTs/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx, line 57
HistogramParzenWindowsListSampleFunction (0x55a3c60883d0): The input list sample has <= 1 element.Function evaluations will be equal to 0.
Iteration 0 (of 5): posterior probability = 0 (annealing temperature = 1)
itk::ExceptionObject (0x55a3c60b8cf0)
Location: "unknown"
File: /home/runner/work/_temp/build/staging/include/ITK-5.4/itkLabelMap.hxx
Line: 180
Description: ITK ERROR: LabelMap(0x55a3c6f42450): Can't access label object at position 2. The label map has only 2 label objects registered."""
Data to reproduce the problem
atropos_hippoamyg_seg.zip
You should be able to run the command from the inside the directory in the zip
The text was updated successfully, but these errors were encountered: