# Subtract baseline scan

**URL:** <https://discourse.slicer.org/t/subtract-baseline-scan/1113>\
**Category:** Support\
**Tags:** subtraction\
**Created:** [September 25, 2017, 12:49pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113 "2017-09-25T12:49:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 25, 2017, 12:49pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/1 "2017-09-25T12:49:58Z")

</div>

Hi,

We have imaged a mouse before and after injecting a vascular contrast agent.

Looking to subtract the before-scan to eliminate the skeletal structure and amplify the arteries for segmentation

Tried the subtraction scalar volumes routing however the resulting image is all grey with a silhouette of the body issue, skeletal structures. Noted there are other masking and registration modules.

As not done such subtraction before, would appreciate any and all guidance on how to perform this using Slicer.

Thanks,

Miten

---

<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:** [September 25, 2017, 1:26pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/2 "2017-09-25T13:26:13Z")

</div>

You need to adjust brightness/contrast after subtraction. Left click+drag over the slice view or go to Volumes module and edit window/level in Display section. If you see artifacts due to small displacements between the two scans then you may use “General registration (BRAINS)” module (in SlicerCore) or “General registration (Elastix)” module (in SlicerElastix extension) to align the scans before subtraction.

---

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 25, 2017, 9:44pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/3 "2017-09-25T21:44:51Z")

</div>

Hi,

There is no registration required as the mouse was not moved between the two scans so the image locations are practically the same.

I think there’s an issue with how I am doing the subtraction. See attached images [http://tinyurl.com/slicer-subtract](http://tinyurl.com/slicer-subtract) or [https://drive.google.com/drive/folders/0B\_nZ6skqKQv-aUxQWkx2cHJFZ0k?usp=sharing](https://drive.google.com/drive/folders/0B_nZ6skqKQv-aUxQWkx2cHJFZ0k?usp=sharing)

There are three images, pre, post and subtract. The Subtract is pretty much all grey whereas the mouse and structures are quite defined in the pre & post.

Thanks,

Miten

---

<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:** [September 26, 2017, 2:54am UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/4 "2017-09-26T02:54:22Z")

</div>

The subtracted image looks correct. You just have to adjust the window/level (brightness/contrast) as I described above.

---

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 26, 2017, 1:54pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/5 "2017-09-26T13:54:08Z")

</div>

Cool. Just realised I was subtracting in wrong order ie ended up with Pre - Post rather than Post - Pre

Am re-doing.

Can you advise what Interpolation order controls ?

Thanks

---

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 26, 2017, 6:12pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/6 "2017-09-26T18:12:28Z")

</div>

Hi,

We did a subtraction using MATLAB of two tiffs saved from slicer of Pre and Post and the resulting image has higher contrast, in line with what we were expecting to see, [https://drive.google.com/file/d/0B\_nZ6skqKQv-amM0TnpKR1l6MVE/view?usp=sharing](https://drive.google.com/file/d/0B_nZ6skqKQv-amM0TnpKR1l6MVE/view?usp=sharing)

Could you advise if the subtraction module in Slicer can produce similar contrast or that requires further processing after subtraction in slicer?

Thanks again,

Miten

---

<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:** [September 26, 2017, 6:24pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/7 "2017-09-26T18:24:36Z")

</div>

No further processing should ne needed, just adjusting the window/level to have higher contrast. If you share an anonymized data set through dropbox/onedrive/gdrive and post the link here then I can have a look.

---

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 26, 2017, 10:54pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/8 "2017-09-26T22:54:32Z")

</div>

Hi,

Great, Have copied both sets of DICOM files on to google drive  
[http://tinyurl.com/pre-post-review](http://tinyurl.com/pre-post-review) OR  
[https://drive.google.com/open?id=0B\_nZ6skqKQv-ZUMtMDJuRER5Vms](https://drive.google.com/open?id=0B_nZ6skqKQv-ZUMtMDJuRER5Vms)

Two directories with DICOM directories in each.

Let me know if you need anything else.

Many Thanks

Miten

---

<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:** [September 27, 2017, 4:13am UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/9 "2017-09-27T04:13:02Z")

</div>

I’ve checked your images and I can confirm that subtraction works as expected. A couple of comments and recommendations:

1. Your images are very high resolution and very noisy. Before you can analyze your images, most likely you need to apply smoothing filters, so you won’t be able to benefit from high frequency details in your image but you still have to deal with the large image size (consuming lots of memory, taking long time to compute, etc). If you can change your imaging protocol, I would suggest to try to lower the resolution and/or increase dose. If that’s not feasible, then use Crop volume module to reduce image extent and resolution of your input volumes (Spacing scale = 2.0x, use the same ROI on both pre and post volumes).

2. After you performed subtraction, go to Volumes module and set W: 500, L: 100 (you can left-click + drag on the image to adjust the values). Don’t forget to select the difference volume as `Active volume` at the top before you adjust the W/L values. You should get something like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f1215dc5be31d0be301f5fb97482e64241fed185.jpeg)

1. Even if nothing supposed to be moving between pre and post images, typically there is some motion, which causes very visible artifacts in the difference image. You can use Slicer’s deformable registration modules to compensate motion. I would recommend “General registration (Elastix)” module (in SlicerElastix extension) to align the pre/post image before subtraction.

Difference image without motion compensation:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/0/609f0357f65167e27f49db5020ca2e88b72e3062.jpeg)

Difference image with motion compensation:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/4/d43f23e6cef56fcce655d94c0b1236e57a182688.jpeg)

1. For 3D visualization, volume measurement, etc. you most likely need to segment the image. You can do that using Segment Editor module. Use the difference image as master volume, select `Threshold` effect, approximately 100 as lower threshold, and click Apply. Then click `Show 3D` to show the reconstructed structures in 3D. There will be always small, isolated artifacts that you can remove by `Islands` effect’s `Keep largest island` method (removes all disconnected regions) and/or remove unwanted parts with the `Scissors` effect manually.

Show 3D - before Islands effect (difference image computed _without_ motion compensation):

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/d/3d9881f65e3c2440f975ea2df08a6caded1e57bb.jpeg)

Show 3D - after Islands effect (difference image computed _without_ motion compensation):

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/22ec7575bd0f2fbb8fa2d2ee85788aa66afd9e57.jpeg)

Show 3D - after Islands effect (difference image computed _with_ motion compensation):

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/c/ac948c73ef5564ac04d261cbbd254ec1ab29ff31.png)

Rotation view (created by Screen Capture module):

![SlicerCapture](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/2/62db375364e83edbd4ecd7691cc45f9c6749e24d.gif)

---

<div class="post-metadata">

**Author:** ![mitenp](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@mitenp](https://discourse.slicer.org/u/mitenp)\
**Post date:** [September 27, 2017, 8:28pm UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/10 "2017-09-27T20:28:22Z")

</div>

Wow Andras, thanks for that. You answered the some other questions we were starting to have once we had resolved how to subtraction !

Lowering scanning resolution is not ideal as the carotid we are interested in are only 500um in diameter. However we will be reducing the actual ROI (scanROI) that we scan. Also using slicer crop ROI (cropROI) to eliminate bulk of the image captured was an idea we had. We will be able to take advantage of cropping even in the refined scanROI at imaging as we are only interested in the carotids on either side of the trachea.

However we weren’t too sure how we can ensure the cropROI created from Pre and Post scans are of exactly the same location ?

Is there a trick to do ensure both are exactly the same that or is that by eye ?

Ultimate aim is to segment the carotids to generate STL and centerline for CFD & FSI modelling. Generally familiar with that process though the info you mentioned for segmenting will improve the approach we had tried before. Will forward the outcome for your review and in case it helps others.

Cheers, much appreciated !

Miten

---

<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:** [September 29, 2017, 12:31am UTC](https://discourse.slicer.org/t/subtract-baseline-scan/1113/11 "2017-09-29T00:31:03Z")

</div>

> [@mitenp](#):
>
> Is there a trick to do ensure both are exactly the same that or is that by eye ?

Use the same ROI node and then the images will be cropped exactly to the same size. If you register them after cropping then small differences do not matter anyway, as the moving volume is always resampled at the end to the grid of the fixed volume.

> [@mitenp](#):
>
> Ultimate aim is to segment the carotids to generate STL and centerline

Segment Editor module creates surface mesh (that can be saved as STL), just export it to a model node after the segmentation is completed. VMTK extension can segment vessel and extract vessel centerline automatically.
