# How to stitch together two sets of CT slices to make one file

**URL:** <https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197>\
**Category:** Support\
**Created:** [October 7, 2017, 8:02pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197 "2017-10-07T20:02:40Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noemi\_Perez](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@Noemi\_Perez](https://discourse.slicer.org/u/Noemi_Perez)\
**Post date:** [October 7, 2017, 8:02pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/1 "2017-10-07T20:02:40Z")

</div>

Operating system: Mac OS X 10.10  
Slicer version: 4.6.2  
Expected behavior: I import a folder with 421 DICOM slices that should show all of the cranium and mandible of an individual  
Actual behavior: The program says that 421 slices have been successfully loaded, when the files of the individual are loaded, the upper part of the cranium is cut out, so it doesn’t show.

Is there a limit of images that can be loaded? How should I solve this problem?? Thank you very much in advance

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 7, 2017, 8:56pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/2 "2017-10-07T20:56:30Z")

</div>

Do you know if the DICOM series has a uniform slice thickness? The symptom you mention has occurred with datasets with non-uniform slice thickness.

In any case, please try it out again with the latest nightly, 4.6.2 is almost a year old now. Thanks!

---

<div class="post-metadata">

**Author:** ![Noemi\_Perez](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@Noemi\_Perez](https://discourse.slicer.org/u/Noemi_Perez)\
**Post date:** [October 8, 2017, 8:54am UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/3 "2017-10-08T08:54:15Z")

</div>

Thank you very much, I’ve downloaded the newest version of the program and now I realised that the problem is that each individual is comprised of two series of CT scans, I have been looking for an explanation or a tutorial on how to stitch these two sets together but so far I haven’t found anything. Is it possible to do it with Slicer??

EDIT: I’m going to change the name of the topic to make it more accurate

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 8, 2017, 4:04pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/4 "2017-10-08T16:04:02Z")

</div>

Thanks for the update, it seems we are making progress! Also thanks for changing the title.

Stitching the volumes is possible, but it won’t be trivial. I imagine the major steps will be these:

1. Make sure the two volumes align. If showing them together (set one as background, the other as foreground with 50% opacity) shows overlap, or the two parts are otherwise do not align, then a transform needs to be created to make them align perfectly (create linear transform in Transforms module, set it to one of the volumes, and tweak the transform until alignment is reached)
2. Resample the volumes to a common frame of reference. Need to create an empty volume that spans both images, ideally in a way that the voxels do not need to be interpolated. I’d try to do this with the Crop Volume module, but I’m not sure that a ROI larger than the cropped image is handled. Then both volumes need to be resampled to this common frame of reference with Resample Image (BRAINS).
3. Add the two volumes together with Add Scalar Volumes

The exact details of these steps will need to be figured out. Let us know how it goes.

---

<div class="post-metadata">

**Author:** ![Noemi\_Perez](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@Noemi\_Perez](https://discourse.slicer.org/u/Noemi_Perez)\
**Post date:** [October 8, 2017, 5:08pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/5 "2017-10-08T17:08:13Z")

</div>

First of all, thank you again! The thing is that when I load the folder with all of the images Slicer just recognises one patient, and it’s always the same part of the CT scan. I realised the folder contained two different scans because I tried opening the folder in Mimics 10.1, which “made me” choose to load one of the sets.  
I’m sorry for all of the trouble, I’m fairly new to using Slicer so I’m still getting used to it

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 8, 2017, 5:24pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/6 "2017-10-08T17:24:10Z")

</div>

No worries! Let us know if you have further quetsions.

---

<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:** [October 9, 2017, 2:47pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/7 "2017-10-09T14:47:28Z")

</div>

If multiple series are stored in a folder or files of a series is spread across multiple folders then you need to use the DICOM module to import it. It will show you a similar patient/study/series selector as Mimics.

---

<div class="post-metadata">

**Author:** ![Noemi\_Perez](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@Noemi\_Perez](https://discourse.slicer.org/u/Noemi_Perez)\
**Post date:** [October 17, 2017, 8:56am UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/8 "2017-10-17T08:56:29Z")

</div>

Thank you very much for your answer.  
The problem is that it just recognises one patient and shows just one of the halves, whereas Mimics recognises two different sets. I’m still trying to open both halves at the same time to try to stitch both parts together.

---

<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:** [October 17, 2017, 11:34am UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/9 "2017-10-17T11:34:38Z")

</div>

To see both sets, you need to import the folder into Slicer (drag-and-drop the folder and choose to import as DICOM), then load it using the DICOM browser. See details here: [https://www.slicer.org/wiki/Documentation/Nightly/Modules/DICOM](https://www.slicer.org/wiki/Documentation/Nightly/Modules/DICOM)

---

<div class="post-metadata">

**Author:** ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)\
**Post date:** [March 30, 2018, 7:57pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/10 "2018-03-30T19:57:17Z")

</div>

What about if there is a large region of overlap? How can I get either the average, max, or some kind of boolean, i.e. pick volume A over B except where A = -1024

---

<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:** [March 31, 2018, 1:31am UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/11 "2018-03-31T01:31:13Z")

</div>

You can get images as numpy arrays, so you can very easily combine them in any way you want using numpy operations.

Just a few illustrative examples (I haven’t tested these expressions, so syntax may not be fully correct, but something similar should work):

Get minimum of two images: `imageCombined = numpy.minimum(imageA,imageB)`

Get image A voxels if it is above a certain intensity threshold, otherwise return the mean of image A and B: `imageCombined = numpy.where(imageA>1500, imageA, (imageA+imageB)/2.0)`

---

<div class="post-metadata">

**Author:** ![Alex\_Wiley](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alex\_Wiley](https://discourse.slicer.org/u/Alex_Wiley)\
**Post date:** [May 24, 2018, 1:02pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/12 "2018-05-24T13:02:33Z")

</div>

I am trying to piece together multiple VTK files. When I go to add scalar volumes, its says completes with errors.

---

<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, 2018, 6:44pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/13 "2018-05-27T18:44:48Z")

</div>

You have to follow the instructions above. Most importantly: resample the volumes using the same reference volume (to make them have the same origin, spacing, axis directions, and extent).

---

<div class="post-metadata">

**Author:** ![Alex\_Wiley](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Alex\_Wiley](https://discourse.slicer.org/u/Alex_Wiley)\
**Post date:** [May 29, 2018, 2:43pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/14 "2018-05-29T14:43:51Z")

</div>

When performing BRAINSresample it is saying completed with error and indicates that it was only performed with 1.

---

<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 29, 2018, 4:48pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/15 "2018-05-29T16:48:54Z")

</div>

Do you use the latest stable version (Slicer-4.8.1)? Can you attach a screenshot of the BRAINSresample module user interface to see how you set your inputs and outputs?

---

<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:** [October 20, 2022, 3:09pm UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/16 "2022-10-20T15:09:22Z")

</div>

Just in case somebody comes across this topic now: @mikebind recently contributed the [Stitch Volumes module](https://github.com/PerkLab/SlicerSandbox#stitch-volumes) for stitching multiple volumes into one. It is available in Sandbox extension.

---

<div class="post-metadata">

**Author:** ![Unicom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/unicom/32/15532_2.png) [@Unicom](https://discourse.slicer.org/u/Unicom)\
**Post date:** [October 16, 2025, 1:36am UTC](https://discourse.slicer.org/t/how-to-stitch-together-two-sets-of-ct-slices-to-make-one-file/1197/17 "2025-10-16T01:36:13Z")

</div>

Just in case somebody comes across this topic now:

> **[GitHub - PerkLab/SlicerSandbox: Collection of utilities that are not polished...](https://github.com/PerkLab/SlicerSandbox#stitch-volumes)**
>
> Collection of utilities that are not polished implementations but can be useful to users

The tool was built only for 3D image volumes; it would likely require source code modification before it could work for blending 2D images.
