# Remove CT patient bed from dicom file automatically

**URL:** <https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614>\
**Category:** Support\
**Tags:** feature\
**Created:** [May 27, 2022, 7:04pm UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614 "2022-05-27T19:04:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gzt036](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gzt036/32/15418_2.png) [@gzt036](https://discourse.slicer.org/u/gzt036)\
**Post date:** [May 27, 2022, 7:04pm UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/1 "2022-05-27T19:04:19Z")

</div>

Is it possible to remove CT bed background noise from DICOM automatically without opening Slicer’s graphic window? The python script needs to be run by the server so human intervene needs to be avoided. My question is,

1. is there any scripts available for this
2. how could I run the script  
Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 27, 2022, 11:11pm UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/2 "2022-05-27T23:11:06Z")

</div>

Are all the images acquired by the same scanner, of the same body part, using the same imaging protocol? Or you are looking for a completely generic solution that can blank out the patient table on any CT image?

---

<div class="post-metadata">

**Author:** ![gzt036](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gzt036/32/15418_2.png) [@gzt036](https://discourse.slicer.org/u/gzt036)\
**Post date:** [May 27, 2022, 11:32pm UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/3 "2022-05-27T23:32:56Z")

</div>

The images could be different. However, I would only be interested in the bones. Yes, I am looking for a completely generic solution to remove the patient bed from the images. Thanks.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 28, 2022, 2:17am UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/4 "2022-05-28T02:17:41Z")

</div>

If you are only interested in the bones then it’s not a hard problem because there is always enough low-density material (muscles, fat, skin, padding on the table) to separate your region of interest (bones) from the table.

I’ve developed a short script for this some time ago, but to make it easier to use, I’ve now added it as a [module in the Sandbox extension](https://github.com/PerkLab/SlicerSandbox#remove-ct-table):

[![](https://raw.githubusercontent.com/PerkLab/SlicerSandbox/master/RemovePatientTable.jpg) ](https://raw.githubusercontent.com/PerkLab/SlicerSandbox/master/RemovePatientTable.jpg)

It will be available in the extensions manager from tomorrow.

---

<div class="post-metadata">

**Author:** ![gzt036](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gzt036/32/15418_2.png) [@gzt036](https://discourse.slicer.org/u/gzt036)\
**Post date:** [May 28, 2022, 6:12am UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/5 "2022-05-28T06:12:32Z")

</div>

Your solution looks great. Is it possible to run the script and obtain the modified DICOM files without opening slicer or any human intervention. Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 28, 2022, 11:58am UTC](https://discourse.slicer.org/t/remove-ct-patient-bed-from-dicom-file-automatically/23614/6 "2022-05-28T11:58:37Z")

</div>

Yes, everything that you can do using the GUI of Slicer is accessible via Python scripting.

I would recommend to spend some time with testing on a handful of randomly selected cases, carefully inspect the results and see if the default parameters work or if you need some tuning. Let me know if you think the defaults would need to be changed.

Then, you can use examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html) to see how to load images from DICOM and how to write results to files using Python scripting. You can see in the [module’s unit test](https://github.com/PerkLab/SlicerSandbox/blob/master/RemoveCtTable/RemoveCtTable.py#L407) how you can use it from a script. Note that you can [use Slicer as a Jupyter kernel](https://github.com/Slicer/SlicerJupyter), if you like working with notebooks.
