# vtkDICOMImageReader function SetFileNames is not working?

**URL:** https://discourse.vtk.org/t/vtkdicomimagereader-function-setfilenames-is-not-working/9521
**Category:** Support
**Created:** [October 3, 2022, 7:37am UTC](https://discourse.vtk.org/t/vtkdicomimagereader-function-setfilenames-is-not-working/9521 "2022-10-03T07:37:07Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BJladika](https://discourse.vtk.org/user_avatar/discourse.vtk.org/bjladika/32/5671_2.png) [@BJladika](https://discourse.vtk.org/u/BJladika)
#### Post date: [October 3, 2022, 7:37am UTC](https://discourse.vtk.org/t/vtkdicomimagereader-function-setfilenames-is-not-working/9521/1 "2022-10-03T07:37:07Z")

</div>

So I have stumbled on example of vtkResliceCursor which uses a vtkDICOMImageReader function SetDirectoryName for generating output. And I have a set of DICOM Files.

```python
reader = vtkDICOMImageReader();
reader.SetDirectoryName("CT");
reader.Update();
imageDims = reader.GetOutput().GetDimensions();

```

But it is kinda not very flexible (like if you put multiple series in one directory, it will not work). So I tried to make a workaround, with using function SetFileNames, except it is absolutely not working for me.

```python
reader = vtkDICOMImageReader();
files_path = [sop_instance.path_prefix for sop_instance in series] #generates X:\X\1.dcm 2.dcm and etc
array = vtkStringArray()
for file_path in files_path:
    array.InsertNextValue(file_path)
reader.SetFilesName(array);
reader.Update();
imageDims = reader.GetOutput().GetDimensions();

```

except its not working. Just getting empty window  
So my basic question what am I doing wrong? Is vtkDICOMImageReader is a good way of generating volume (model) for reslice cursor? I think about other workaround, although its kinda lame (generating folder, putting there all .dcm files of one series)

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 3, 2022, 3:44pm UTC](https://discourse.vtk.org/t/vtkdicomimagereader-function-setfilenames-is-not-working/9521/2 "2022-10-03T15:44:45Z")

</div>

The vtkDICOMImageReader doesn’t support the use of SetFileNames(). I looked at the code, and it has this:

```nohighlight
void vtkDICOMImageReader::ExecuteInformation()
{
  if (this->FileName == nullptr && this->DirectoryName == nullptr)
  {
    return;
  }
 ...
}

```

SetFileName() and SetDirectoryName() are the only methods for providing data.

I have my own DICOM reader at [github.com/dgobbi/vtk-dicom](https://github.com/dgobbi/vtk-dicom), and it supports the SetFileNames() method, but it must be built from source (there is no package for pip).
