2

My aim is to mask a 3D image at a given location with a 3d spherical mask. I want to extract all of the values of the image within this 3D mask

I am currently using python's nilearn.image.NiftiSpheresMasker function to achieve this in the following way:

central_coordinates=(x,y,z)
masker = NiftiSpheresMasker(central_coordinates, radius=rad)
values=masker.fit_transform(resampled_image) 

However, this only returns the mean signal within the ROI. Is there a way to either:

  • Extract the mask that this function uses (so that I can obtain the values manually)
  • Use an alternative method to achieve this 3D ROI

P.s I have already tried using FSL's fslmaths -kernel which works for cubes but not spheres.

Joe
  • 51
  • 1
  • 6

1 Answers1

1

I managed to solve this by using the function create_sphere from the package nltools

See this link: https://github.com/ljchang/nltools/issues/122

Joe
  • 51
  • 1
  • 6