How to remove the CT scanning bed with SimpleITK

I currently have CT scans that have the scanner bed in the image. I was wondering if someone knew of a method to crop out the bed from the images with SimpleITK. I have seen some work using 3D Slicer, but as this is part of a larger project I am not able to jump between 3D Slicer and Python easily.

image

1 Like

Slicer has a Python scripting interface, and ships with a recent ITK and SimpleITK.

Hopefully, someone will reply about existence of scripts for it in SimpleITK.

1 Like

I am aware of Slicer’s Python interface, but since it relies on its own version of Python and does not communicate with other system Python it won’t work well for this.

I think you can pip install packages in Slicer’s Python since recently. Isn’t that enough?

Not really, this work is going to be deployed on remote servers to run and using Slicer with it would be extremely overly complicated.

1 Like

Hello @kleingeo ,

As you can see in the Slicer bed removal video, the functionality which is not in SimpleITK is the GUI which allows the user to interactively define a mask. Using the mask in SimpleITK to remove the table is trivial. If user interaction is acceptable and you don’t want to use slicer, use your own GUI to define the mask.

If user interaction is not acceptable, take a look at this paper: Automatic Patient Table Removal in CT Images (I have no idea how well this really works). Looks like the components used in that work, are available in ITK/SimpleITK.

If you implement an image processing service on a server that accepts user-provided data then it won’t be very simple anyway, because you need to run the processing in some sandboxed container (e.g., docker) for security reasons. None of the medical image processing software libraries are hardened against security vulnerabilities so that you could just directly run them on your server.

If you already use docker then adding Slicer to it is straightforward. You can find dockerfiles and simple processing examples here.

Slicer also has a REST API, so if you only need to do some simple automatic processing then you can keep one docker instance running a Slicer server in it and use it from your web app. The API contains a number of general-purpose features, but any Slicer module can provide additional REST API endpoints for some specialized processing.

You can even expose Slicer’s interactive GUI in the web browser (usually with a simplified layout of showing only the viewers and a few button) but that indeed starts to become a more complex setup.

This tool is supposed to be part of a larger deep learning pipeline, so I integrating it with Slicer would be unnecessarily complicated and probably add a significant bottleneck to the overall training. It would probably be more time efficient then to simply crop the CT images manually before training.

Hi @kleingeo,

I once used the Hough Transform (like in the paper @zivy linked) for a project to remove the scanner bed since it resembles (multiple) straight lines. I took the coordinates closest to the middle and applied a binary mask to the image. Maybe this is suitable for you, and you can look into it. You can also detect other simple shapes with it.

It worked well for me.

All the best