# Aligning Segmentation and CT slices for feature extraction via Pyradiomics

**URL:** <https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625>\
**Category:** Support\
**Tags:** nlst\
**Created:** [September 9, 2024, 2:42am UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625 "2024-09-09T02:42:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nav\_Malhotra](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.canceridc.dev/nav_malhotra/32/471_2.png) [@Nav\_Malhotra](https://discourse.canceridc.dev/u/Nav_Malhotra)\
**Post date:** [September 9, 2024, 2:42am UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625/1 "2024-09-09T02:42:46Z")

</div>

Currently I am trying to extract higher order and texture based features from NLST chest CTs from their downloaded DICOM format.

I was having trouble properly formatting the data for insertion into a feature extraction pipeline. Upon downloading the data using AWS, the CT slices are returned as a separate DICOM per slice, while the segmentation is stored entirely as one DICOM.

For patient with PID 100002 for instance,

CT scans (126 slices):

 ![image (1)](https://us1.discourse-cdn.com/flex015/uploads/canceridc/original/1X/07a172642a11e63f3e1d89883364216a61cffaee.png)

Segmentation Mask (2697 slices):

 ![image (2)](https://us1.discourse-cdn.com/flex015/uploads/canceridc/original/1X/3d5b072ad7fef157d008363546cfbbe0a5cfe8fb.png)

Thus it cannot be simply fed into a pipeline with the respective file paths as they do not match up.

Do you have any ideas to align or overlay both the mask and CT slices in order to extract higher order and texture features from their respective DICOMs?

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.canceridc.dev/fedorov/32/3_2.png) [@fedorov](https://discourse.canceridc.dev/u/fedorov)\
**Post date:** [September 9, 2024, 9:29pm UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625/2 "2024-09-09T21:29:55Z")

</div>

@Nav_Malhotra thank you for reaching out to ask about this in the forum!

pyradiomics, as many other tools, is designed to work more reliably with the data converted to one of the 3d research formats, such as NRRD or NIfTI. IDC data is stored in DICOM. Fortunately, conversion from DICOM to those research format is quite straightforward. I recommend the following:

1. for DICOM CT series, you can use [dcm2niix](https://github.com/rordenlab/dcm2niix) command line converter - you can install binary for your platform from the releases page here: [Releases · rordenlab/dcm2niix · GitHub](https://github.com/rordenlab/dcm2niix/releases). Once you installed it, run `dcm2niix` pointing it to the directory containing a single CT series.
2. for DICOM SEG series (I see from the identifier `9629abf6-d1de-4931-bc6a-061890ae275c` in your screenshot that you were looking at the [TotalSegmentator segmentations collection](https://discourse.canceridc.dev/t/new-in-idc-v18-totalsegmentator-segmentations-and-radiomics-features-for-nlst-cts/582/7) in IDC), you can use [dcmqi](https://github.com/QIICR/dcmqi) [segimage2itkimage](https://qiicr.gitbook.io/dcmqi-guide/opening/cmd_tools/seg/segimage2itkimage) tool for conversion (again, you can download binaries of dcmqi in the repo: [Releases · QIICR/dcmqi · GitHub](https://github.com/QIICR/dcmqi/releases)).

Can you tell me how you are downloading the files from IDC? We recently added some convenience functions to the [`idc-index`](https://github.com/ImagingDataCommons/idc-index) that aim to simplify the process. You can learn about this from the updated [download instructions page](https://learn.canceridc.dev/data/downloading-data). Would be very interested to hear your thoughts and any feedback on this new functionality!

Hope this helps, but do let us know if you need more assistance!

---

<div class="post-metadata">

**Author:** ![YLi64](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@YLi64](https://discourse.canceridc.dev/u/YLi64)\
**Post date:** [January 17, 2026, 12:22am UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625/3 "2026-01-17T00:22:37Z")

</div>

Hi Fedorov, May I ask does [Aligning Segmentation and CT slices](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625) have better methods now?

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.canceridc.dev/fedorov/32/3_2.png) [@fedorov](https://discourse.canceridc.dev/u/fedorov)\
**Post date:** [January 17, 2026, 2:30am UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625/4 "2026-01-17T02:30:56Z")

</div>

I would still recommend following the instructions in my previous post.

---

<div class="post-metadata">

**Author:** ![CPBridge](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.canceridc.dev/cpbridge/32/679_2.png) [@CPBridge](https://discourse.canceridc.dev/u/CPBridge)\
**Post date:** [August 12, 2026, 1:56pm UTC](https://discourse.canceridc.dev/t/aligning-segmentation-and-ct-slices-for-feature-extraction-via-pyradiomics/625/5 "2026-08-12T13:56:48Z")

</div>

Using tools in the latest version of highdicom, this becomes somewhat simpler:

```python
import highdicom

ct_files = ["ct_image1.dcm", "ct_image2.dcm", ...]
seg_file = "seg_image.dcm"

# Read CT into a volume
ct_vol = hd.get_volume_from_series([hd.imread(f) for f in ct_files])

# Read segmentation into a volume
seg_vol = hd.seg.segread(seg_file).get_volume(combine_segments=True)

# Ensure the two volumes are spatially aligned
seg_vol = seg_vol.match_geometry(ct_vol)

# Convert both volumes to ITK, as required for pyradiomics
seg_itk = seg_vol.to_itk()
ct_itk = ct_vol.to_itk()

```
