ANTsPyNet icon indicating copy to clipboard operation
ANTsPyNet copied to clipboard

closest_simplified_direction_matrix bug + bounding box artifact

Open stnava opened this issue 4 years ago • 3 comments

https://github.com/ANTsX/ANTsPyNet/blob/d39ee8333149a84f6bb72b217419dacfd3872a0d/antspynet/utilities/white_matter_hyperintensity_segmentation.py#L76-L79

causes an error in some installations of python / numpy / tensorflow / antspynet ( can reproduced on ubuntu 18.04 with recent install )

the issue is in multiplying float with int. fixed with this https://github.com/ANTsX/ANTsPyNet/commit/ffe9b2496973b4445856995403d377a9c2b29d6a:

    def closest_simplified_direction_matrix(direction):
        closest = (np.abs(direction) + 0.5).astype(int).astype(float)
        closest[direction < 0] *= -1.0
        return closest

looked at results and saw:

image

maybe multiply the output probabilities with brain mask after mapping back to original space?

stnava avatar Nov 04 '21 16:11 stnava

Yeah, that's a good idea. The original implementation uses simple thresholding for "brain extraction." I'll work on this later today or tomorrow.

ntustison avatar Nov 04 '21 16:11 ntustison

here is what I recommended to a colleague for real processing scenarios:

  • run the flair through antspynet.sysu_media_wmh_segmentation
  • get the T1 from the same session
  • register the T1 and the Flair --- either before or after brain extraction probably does not matter much
  • mask the output of the WMH map with the white matter segmentation of the T1

what do you think? I guess the last step could cause some loss of "real" WMH but it would remove some of the spurious signal in the cortex. maybe it would be better to just set all CSF ( and maybe cortex) to zero?

stnava avatar Nov 04 '21 16:11 stnava

Yes, I've played with that in the development of our own pipeline because I think it's a good idea. I don't think I'd include it in the sysu function itself as I've tried to keep it as close to the original as possible.

ntustison avatar Nov 04 '21 16:11 ntustison