# identify a single slice file name in 3D dicom volume

**URL:** <https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110>\
**Category:** Support\
**Tags:** dicom\
**Created:** [April 25, 2023, 11:10am UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110 "2023-04-25T11:10:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumsumin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sumsumin/32/65767_2.png) [@sumsumin](https://discourse.slicer.org/u/sumsumin)\
**Post date:** [April 25, 2023, 11:10am UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/1 "2023-04-25T11:10:16Z")

</div>

How can I identify a the file name of a single slice in a loaded 3D DICOM volume? I have loaded a DICOM directory with several hundred slices, but after I have identified a single slice of interest, I would like to know which file name it is.

---

<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:** [April 25, 2023, 12:58pm UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/2 "2023-04-25T12:58:32Z")

</div>

You can use the python api like in the example linked below. The `instanceUIDs` attribute of the volume node can be used with `fileForInstance()` to get the path.

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#get-path-and-filename-of-a-scalar-volume-node-loaded-from-dicom](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-path-and-filename-of-a-scalar-volume-node-loaded-from-dicom)

---

<div class="post-metadata">

**Author:** ![sumsumin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sumsumin/32/65767_2.png) [@sumsumin](https://discourse.slicer.org/u/sumsumin)\
**Post date:** [April 26, 2023, 2:55am UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/3 "2023-04-26T02:55:30Z")

</div>

thanks for reply.

‘’’  
volumeName = “1302: Chest CE 3.0 I50f 2\_1”

volumeNode = slicer.util.getNode(volumeName)

instUids = volumeNode.GetAttribute(“DICOM.instanceUIDs”).split()

filepath = slicer.dicomDatabase.fileForInstance(instUids[0])

print(“DICOM path=%s” % filepath)  
‘’’

I implemented this code , and the result of filepath was from DicomDatabase.  
But i want the filepath from where I import the dicom file.

---

<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:** [April 26, 2023, 3:29am UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/4 "2023-04-26T03:29:15Z")

</div>

You can choose to copy the imported DICOM files into the database or just add a link to it. For example to con toggle this setting in the DICOM module by clicking the down-arrow button on the DICOM import button.

That said, filename is not the most robust way of referring to an image slice. Instead, the instance UID uniquely identifies the entire content of the image frame, globally, forever. If you have the UID then you can always retrieve the file from a local folder, from a DICOM server, from a local database, etc.

---

<div class="post-metadata">

**Author:** ![sumsumin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sumsumin/32/65767_2.png) [@sumsumin](https://discourse.slicer.org/u/sumsumin)\
**Post date:** [April 26, 2023, 4:34am UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/5 "2023-04-26T04:34:01Z")

</div>

> [@sumsumin](#):
>
> ‘’’  
> volumeName = “1302: Chest CE 3.0 I50f 2\_1”
> 
> volumeNode = slicer.util.getNode(volumeName)
> 
> instUids = volumeNode.GetAttribute(“DICOM.instanceUIDs”).split()
> 
> filepath = slicer.dicomDatabase.fileForInstance(instUids[0])
> 
> print(“DICOM path=%s” % filepath)  
> ‘’’

if i print(instUids) in this code, there are lot of UID , but i want to know only specific slice UID.  
How can i know the index of slice file and approach to that?

---

<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:** [May 2, 2023, 8:03pm UTC](https://discourse.slicer.org/t/identify-a-single-slice-file-name-in-3d-dicom-volume/29110/6 "2023-05-02T20:03:06Z")

</div>

In most cases, there is an instance UID for each slice. The slice index is the third voxel coordinate (K). You can convert RAS to IJK as shown in [this example](https://stackoverflow.com/questions/16087674/how-can-i-make-my-nsis-silent-installer-block-until-complete).
