BRAINSfit Registration gives error "Number of objects (70129) greater than maximum of output pixel type (65535)"?

Hello, I am using the BRAINS registration module to try to register two CT images together, and am getting the following error:

General Registration (BRAINS) standard error:

Relabel: exception caught !

itk::ExceptionObject (0000005B8E8F2EC8)

Location: "unknown"

File: d:\d\p\slicer-0-build\itk\modules\segmentation\connectedcomponents\include\itkConnectedComponentImageFilter.hxx

Line: 133

Description: itk::ERROR: ConnectedComponentImageFilter(00000240C5DB4600): Number of objects (70129) greater than maximum of output pixel type (65535).

I’m not sure what will lead to this error or how to resolve it. I’m not sure why the registration process is concerned with the maximum of the output pixel type. In this case, both the moving and the fixed CT images are of type “short”. In my case, I am just trying to get the transform between the two, so I am not actually even asking for an output transformed image. Even if I were, it wouldn’t require pixel values outside the range of the untransformed image. It seems odd that an intermediate image would require so many more possible pixel values.

Any suggestions or insight? Thanks.

Maybe ConnectedComponentImageFilter is used for automatic ROI generation. What parameters have you changed from the default? Have you tried if the behavior is the same in latest Slicer preview and stable releases?

@hjmjohnson do you know why ConnectedComponentImageFilter is used in BRAINS registration?

I wondered if it might have something to do with something like a “number of bins” for mutual information registration. I use mostly default parameters. I sometimes increase or more occasionally decrease the percentage of samples, and often increase the “Remove intensity outliers” to .0005 or .001 because I am usually trying to register two images which differ by primarily by the addition of a small amount of metal hardware. I use the “useCenterOfHeadAlign” for initialization and am doing only rigid registration. I have tried ROIAUTO, but it has never helped in a case where I was getting this error on NOMASK.

On the theory that the error might be caused by too many different pairings between pixel values in the mutual information, I tried increasing the Median Filter Size from 0,0,0 to 3,3,3, and this did not give an error and registered the two volumes. So, in the future I’ll try that as well.

That explains it. This method performs simple image analysis to detect the head and uses the center of the head object that it found for initial alignment. Most likely itkConnectedComponentImageFilter is used for getting the largest connected component (the head) and you run into issues because the threshold that produces the head also produces 70219 small islands, which are more than the algorithm expects (it cannot store it in its internal 16-bit labelmap image).

Maybe your image is not actually a head MRI image or it is unusual in some way that makes the head detection algorithm fail (in this case, don’t use this initialization option) or it is very noisy (then application of a noise filter, such as median or Gaussian can help).

YES! I’m 99% sure I fixed this a few days ago. I am working on a few other cleanups.

This also prompted a recent error message change in ITK to better refect the problem.

The problem is caused by incorrectly using an intermediate datatype of unsigned char that is too small to hold the number of objects.

My plan is to update Slicer’s version of BRAINSTools in the middle of this week (Wed or Thursday).

If you have a test data set, I could confirm that this is fixed at the end of the week.

Hans

2 Likes

The volumes I have are medical, so I can’t share, but I can test next week to verify. They are not head MRIs, they are head CTs, though I believe I may have gotten this error when trying to register a head MR to head CT.

Should I not use “useCenterOfHeadAlign” for CT volumes?