1

I'm trying to perform a skull stripping with simpleITK in python. I'm using the StripTsImageFilter function as follows:

#upload data
# Path of nii img
path = r'C:\Users\Kate\Jupyter\DataThesis\PROGRESSION\0003\fet.nii.gz'

# Read the .nii image with SimpleITK:
img = sitk.ReadImage(path)

#read atlas and atlasmap
#Obtained from 3DSlicer documentation: https://www.slicer.org/wiki/Documentation/Nightly/Modules/SwissSkullStripper

atlas = sitk.ReadImage(r'C:\Users\Kate\Jupyter\thesis\atlasImage.mha')
atlasMask = sitk.ReadImage(r'C:\Users\Kate\Jupyter\thesis\atlasMask.mha')

#Skull stripping 
#https://www.istb.unibe.ch/e43946/e43949/e158631/e187931/pane187932/e187939/files187941/article_eng.pdf

brainMask = sitk.StripTsImageFilter(img, atlas, atlasMask)

I get the error 'AttributeError: module 'SimpleITK' has no attribute 'StripTsImageFilter'' I have tried implementing img.StripTsImageFilter and tried using sitk.SkullStrip.StripTsFilter as well.

Does anyone know how to solve this?

Kate
  • 13
  • 3

2 Answers2

0

StripTsImageFilter is a 'remote' module for ITK. So it is not wrapped by SimpleITK and is not even built by default in ITK.

To gain access to it in Python you're going to have to use ITK's Python wrapping, and you're going to have to build ITK-Python yourself, since it is not in the pre-build ITK-Python on PyPi.

Dave Chen
  • 1,905
  • 1
  • 12
  • 18
  • Hi! Thanks for the comment, would you recommend another skull stripping module I could use with Python directly? – Kate Feb 24 '22 at 14:00
  • I don't know, but a google search on 'python skull stripping' produced some promising results on the first page. – Dave Chen Feb 24 '22 at 15:15
  • 1
    Yeah, I was just wondering if there was one that was generally more or less accepted. I ended up going with deepbrain, thanks :) – Kate Feb 24 '22 at 15:55
0

As Dave pointed out, the StripTsImageFilter is included in SimpleITK (or 'raw' ITK) by default. You can install the remote module from PyPi like so:

pip install itk-skullstripping

More information is available here: https://github.com/InsightSoftwareConsortium/ITKSkullStrip

Converting itk to sitk and back is explained here: https://discourse.itk.org/t/in-python-how-to-convert-between-simpleitk-and-itk-images/1922

dyoll
  • 187
  • 2
  • 6