How to open a list of dicom image with python

161 views
Skip to first unread message

Antonella Patrizia Paredes Stefanelli

unread,
Apr 14, 2015, 7:35:41 AM4/14/15
to pyd...@googlegroups.com
Hello !!
I need help  to open a  list  of dicom image. i have 40 images in a directory

i have this code:  but i only can open 1 image , the last image in the directory. 

Created on Mon Mar 30 08:37:57 2015


Programa diseñado por ANTONELLA PATRIZIA PAREDES STEFANELLI 

Realizado en el ITEAM/GTS de la UNIVERSIDAD POLITÉCNICA DE VALENCIA. 

Año 2015.

"""

import sys

import os 

import stat

import numpy as np

import dicom 

import matplotlib.pyplot as plt

#Lectura de imagenes del directorio.  

#directorio = 'C:\Users\Antonella\Pictures/'

directorio =  'H:\DICOM\PT0\ST0\PC - SE8' 

#'G:\TESIS\FLUJO\DICOM\PT0\ST0\PC - SE10'

#lista de los archivos del directorio sin inlcuir los archivos de tipo "." ".."

lista_archivos = os.listdir(directorio ) #lista con los nombres de los archivos

l = len(lista_archivos) #longitud de la carpeta , numero de imagenes 



for f in lista_archivos:

    file_name = os.path.join(directorio, f)#entra al directorio 

    info = dicom.read_file(file_name) #seleccion de 1 archivo para lectura de parametro generales


#lectura de tags

    modality = info.Modality

    rows =  info.Rows

    cols = info.Columns

    nbits = info.BitsStored #Bits utilizados en las imágenes de fase

    velocity = info[0x0019,0x10cc].value

    image_type = info [0x0043,0x1030].value

Reese Haywood

unread,
Apr 14, 2015, 1:06:03 PM4/14/15
to pyd...@googlegroups.com
Maybe not the most efficient way but you need to append the next each image each time you loop. Something like the untested pseudo code below

info=[],modality=[],...
#current image index
k=0
for f in list:
 file_name=...
 info.append(dicom.read_file(file_name))
 modality.append(info[k].Modality)
 ...
 k++

Reese

--
You received this message because you are subscribed to the Google Groups "pydicom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydicom+u...@googlegroups.com.
To post to this group, send email to pyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/pydicom.
For more options, visit https://groups.google.com/d/optout.



--
*********************************************************
Please direct all e-mails to
reese....@gmail.com

This is my primary e-mail account.
*********************************************************

Antonella Patrizia Paredes Stefanelli

unread,
Apr 15, 2015, 3:45:28 AM4/15/15
to pyd...@googlegroups.com
Thanks  ;)
Reply all
Reply to author
Forward
0 new messages