# Not imported DICOM files

**URL:** <https://discourse.slicer.org/t/not-imported-dicom-files/32868>\
**Category:** Support\
**Tags:** dicom, file-import\
**Created:** [November 16, 2023, 11:40pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868 "2023-11-16T23:40:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![luarpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luarpy/32/67016_2.png) [@luarpy](https://discourse.slicer.org/u/luarpy)\
**Post date:** [November 16, 2023, 11:40pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/1 "2023-11-16T23:40:17Z")

</div>

Hello  
I could see that Slicer for Linux is not able to load all the DICOM files present in a folder. I have checked the following checks:

- Files exist: yes
- Slicer for Windows loads them: yes
- The files contain data: yes
- Are errors or warnings during import: no

What could be the steps to follow? What else should I check?  
Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 16, 2023, 11:43pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/2 "2023-11-16T23:43:26Z")

</div>

Perhaps narrow down to two files, one that loads and one that doesn’t and inspect what’s possibly different about them.

---

<div class="post-metadata">

**Author:** ![luarpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luarpy/32/67016_2.png) [@luarpy](https://discourse.slicer.org/u/luarpy)\
**Post date:** [November 17, 2023, 6:23pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/3 "2023-11-17T18:23:34Z")

</div>

Do you mean internally, all the DICOM tags?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 17, 2023, 7:04pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/4 "2023-11-17T19:04:13Z")

</div>

Probably not the dicom tags if the files load correctly on windows, but maybe something about the file path or permissions. It’s hard to think of any reason two versions of slicer would treat the same dicom files differently.

---

<div class="post-metadata">

**Author:** ![luarpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luarpy/32/67016_2.png) [@luarpy](https://discourse.slicer.org/u/luarpy)\
**Post date:** [November 30, 2023, 6:41pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/5 "2023-11-30T18:41:20Z")

</div>

I have noticed that files are missing when Slicer loads a folder with DICOM content.  
I wanted to share this simple script to generate a CSV file to check name by name which files are missing from the list in Slicer:

```python
import pydicom
import sys
import csv
import os

from os import listdir
from os.path import join,isfile

def main():
    input_dir = sys.argv[1]
    output_file = sys.argv[2]
    ds_dict = {               
                "PatientID": None,       
                "FileName": None,
                "SeriesNumber": None,     
                "SeriesDescription": None,
                "Modality": None}      
    input_dir = os.path.abspath(input_dir)

    with open(output_file, 'a') as f:
        w = csv.DictWriter(f, ds_dict.keys())
        w.writeheader()
        for root, dirs, files in os.walk(input_dir):
            for file in files:
                file_abspath = os.path.join(input_dir, file)
                if file_abspath.endswith('EXTREME'):
                    try:
                        ds = pydicom.dcmread(file_abspath, force=True)
                        ds_dict["FileName"] = str(file)
                        ds_dict["PatientID"] = str(ds.PatientID)
                        ds_dict["SeriesNumber"] = str(ds.SeriesNumber)
                        ds_dict["SeriesDescription"] = str(ds.SeriesDescription)
                        ds_dict["Modality"] = str(ds.Modality)
                        
                        w.writerow(ds_dict)
                        ds_dict = ds_dict.fromkeys(ds_dict, None)
                    except Exception as ex:
                        print(str(ex))
                        continue
        
    f.close()

if __name__ == " __main__":
    main()

```

To run it, just type it in the command line:

```bash
python script.py input_folder/ output.csv

```

The generated CSV file can be opened with any spreadsheet software. By copying the unloaded file to a separate folder and importing it with the “Import DICOM” tool, I can load the missing files one by one.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 30, 2023, 9:44pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/6 "2023-11-30T21:44:20Z")

</div>

> [@luarpy](#):
>
> By copying the unloaded file to a separate folder and importing it with the “Import DICOM” tool, I can load the missing files one by one.

So this indicates that the files didn’t load due to something about the folder they were originally in?

---

<div class="post-metadata">

**Author:** ![luarpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luarpy/32/67016_2.png) [@luarpy](https://discourse.slicer.org/u/luarpy)\
**Post date:** [November 30, 2023, 9:58pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/7 "2023-11-30T21:58:58Z")

</div>

Nope, I checked by moving the parent directory to see if it could be due to a too long path. But the files are arbitrarily missing

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 30, 2023, 10:08pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/8 "2023-11-30T22:08:39Z")

</div>

Is there a way you can turn this into a report that can be reproduced on other machines?

---

<div class="post-metadata">

**Author:** ![luarpy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luarpy/32/67016_2.png) [@luarpy](https://discourse.slicer.org/u/luarpy)\
**Post date:** [November 30, 2023, 11:53pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/9 "2023-11-30T23:53:12Z")

</div>

Do you mean by sharing the DICOM files I use (I should consult it) or with a public example DB? I could get an estimate of what is missing in proportion to those that exist.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 1, 2023, 10:03pm UTC](https://discourse.slicer.org/t/not-imported-dicom-files/32868/10 "2023-12-01T22:03:03Z")

</div>

What I mean is that it’s not clear if this is an issue with the files or your system of if it’s something to do with Slicer itself. If you are able to provide a set of data and instructions that can be replicated elsewhere it might be possible to get to the heart of the issue.
