# How to use qSlicerCoreIOManager::loadNodes to load dicom files by cpp

**URL:** <https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858>\
**Category:** Development\
**Created:** [June 18, 2024, 8:06am UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858 "2024-06-18T08:06:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fqzhice](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@fqzhice](https://discourse.slicer.org/u/fqzhice)\
**Post date:** [June 18, 2024, 8:06am UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858/1 "2024-06-18T08:06:49Z")

</div>

To load dicom series “.dcm” file, code is as below

```auto
    qSlicerCoreIOManager* ioManager = qSlicerCoreApplication::application()->coreIOManager();
    properties["fileName"] = file; // the first file in series
    ioManager->loadNodes("VolumeFile", properties );

```

some dicom files can be loaded as single volume, some generates multiple series for every dicom file

How can i solve this?

---

<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:** [June 18, 2024, 7:23pm UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858/2 "2024-06-18T19:23:04Z")

</div>

DICOM files have to be loaded with the DICOM module. The IO plugin for the IO manager just calls the DICOM module to import the image, too.

There are often several different interpretations of a set of DICOM files, so you have to ask the user or make assumptions.

---

<div class="post-metadata">

**Author:** ![fqzhice](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@fqzhice](https://discourse.slicer.org/u/fqzhice)\
**Post date:** [June 19, 2024, 12:44am UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858/3 "2024-06-19T00:44:54Z")

</div>

Thanks for your replay.  
Does that mean the first arguments should not only ‘VolumeFile’ and change according to some dicom feature?

---

<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:** [June 19, 2024, 12:59am UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858/4 "2024-06-19T00:59:24Z")

</div>

Specifying `VolumeFile` would use ITK library’s DICOM reader, which only loads some images correctly. It loads some images incorrectly or not at all, and it cannot read any other information objects. Therefore, I would recommend to always use the DICOM module for loading DICOM data. First you need to import the data, then examine, select what you want to load, and finally load them. You can find examples in the script repository. You can execute Python commands in C++ using the Python manager object.

---

<div class="post-metadata">

**Author:** ![fqzhice](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@fqzhice](https://discourse.slicer.org/u/fqzhice)\
**Post date:** [June 19, 2024, 1:02am UTC](https://discourse.slicer.org/t/how-to-use-qslicercoreiomanager-loadnodes-to-load-dicom-files-by-cpp/36858/5 "2024-06-19T01:02:30Z")

</div>

yeah  
very appreciated！
