# How to create 3 channel image from different DICOMs?

**URL:** https://discourse.slicer.org/t/how-to-create-3-channel-image-from-different-dicoms/16481
**Category:** Development
**Tags:** segmentation, dicom, pytorch
**Created:** [March 11, 2021, 5:09pm UTC](https://discourse.slicer.org/t/how-to-create-3-channel-image-from-different-dicoms/16481 "2021-03-11T17:09:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![coconutattitude](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/coconutattitude/32/9123_2.png) [@coconutattitude](https://discourse.slicer.org/u/coconutattitude)
#### Post date: [March 11, 2021, 5:09pm UTC](https://discourse.slicer.org/t/how-to-create-3-channel-image-from-different-dicoms/16481/1 "2021-03-11T17:09:51Z")

</div>

Hi, is there a way to combine different DICOMS into a single image in Slicer? I have several examinations, and I want to reproduce this AI segmentation: [U-Net for brain MRI | PyTorch](https://pytorch.org/hub/mateuszbuda_brain-segmentation-pytorch_unet//) However, It asks for specific input images:  
“Input image is a 3-channel brain MRI slice from pre-contrast, FLAIR, and post-contrast sequences, respectively.”

Is there any way to export DICOM or TIF that has different examination per channel?

---

<div class="post-metadata">

### Author: ![JanWitowski](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/janwitowski/32/4512_2.png) [@JanWitowski](https://discourse.slicer.org/u/JanWitowski)
#### Post date: [March 11, 2021, 10:56pm UTC](https://discourse.slicer.org/t/how-to-create-3-channel-image-from-different-dicoms/16481/2 "2021-03-11T22:56:27Z")

</div>

You probably can, you would have to load three series (pre-contrast, FLAIR and postcontrast), then [access pixel arrays from your loaded volumes](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#Accessing_Volume_data_as_numpy_array), and then stack them with e.g. `numpy.stack` or `torch.stack` to get your three channels matrix. I’m not sure why you would necessarily need Slicer for this specific task, though, this is probably easier to do with some scripting using SimpleITK or Pydicom (maybe even directly in your PyTorch DataLoader).
