Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 21:33
    mrbean-bremen commented #799
  • Jan 31 2019 20:48
    darcymason commented #799
  • Jan 31 2019 20:23
    mrbean-bremen labeled #799
  • Jan 31 2019 20:23
    mrbean-bremen commented #799
  • Jan 31 2019 20:16
    darcymason commented #799
  • Jan 31 2019 20:13
    mrbean-bremen commented #799
  • Jan 31 2019 20:12
    mrbean-bremen commented #799
  • Jan 31 2019 20:09
    mrbean-bremen commented #799
  • Jan 31 2019 20:01
    darcymason commented #799
  • Jan 31 2019 19:42
    mrbean-bremen commented #799
  • Jan 31 2019 19:31
    mrbean-bremen commented #796
  • Jan 31 2019 18:22
    darcymason opened #799
  • Jan 31 2019 14:56
    ManuelaPa commented #796
  • Jan 31 2019 11:39
    scaramallion commented #798
  • Jan 31 2019 11:39
    scaramallion commented #798
  • Jan 31 2019 11:38
    scaramallion commented #798
  • Jan 31 2019 11:37
    scaramallion labeled #798
  • Jan 31 2019 11:37
    scaramallion commented #798
  • Jan 31 2019 11:29
    scaramallion edited #798
  • Jan 31 2019 11:25
    scaramallion commented #796
scaramallion
@scaramallion
If the frame is uncompressed then you shouldn't encapsulate it, just to ds.PixelData = frame.tobytes()
And make sure the transfer syntax is set to an uncompressed one
If the frame is compressed (JPEG, RLE, whatever) then you must encapsulate it first
And set the transfer syntax accordingly
Note that for a compressed transfer syntax you must peform the compression of the data yourself, pydicom won't do it automatically
*of the pixel data
RoadToML
@RoadToML
@scaramallion wow thanks, removing encapsulation also helped solved my image flipping problem
I thought encapsulation was compression... can you define both those words in relation to the DICOM standard please?
i guess i am still confused about them
scaramallion
@scaramallion
compression just means the pixel data is compressed in some way (like JPEG, RLE)
encapsulation is required for compressed pixel data as a way to separate the frames (because they're compressed you can tell where the frame boundaries are)
*can't
Mateusz Korycinski
@mkorycinski
Hello. How could I cite PyDicom? Shall I create a bibtex myself based on the information available on the website or perhaps you already have one?
Darcy Mason
@darcymason
There is a zenodo DOI badge on the main page, using that is our usual recommendation for citing. It's updated every version so the one seen now is for v2.0, you could look at previous README to see the previous ones.
photonsarefree
@photonsarefree

Hi everyone, I am trying to do the following: Given a study with multiple series, identify one to process with an AI model that I have built. These are lung scans. The difference in series, is the convolution_kernel (0018|1210) used to reconsruct the CTs. They also have different slice counts, affecting the size on disk (in terms of MBs). In plane resolution is same in all cases.

My question is: given that my program will have to work with different vendors, should I look at SOP Instance UIDs or other such tags to identify the right (single) scan to pick to feed into the AI model? Feeding all scans will work but will increase the overall time spent from uploading the data to seeing the results (in my case user will wait until all series are processed through the model).

photonsarefree
@photonsarefree
Apologies I realized after posting this is a group to discuss pydicom development, and my question is dicom specific. I would appreciate answers if anyone knows but will find another discussion group to discuss this.
scaramallion
@scaramallion
It depends what you mean by "scan". If you're referring to a single slice of a CT acquisition then SOP Instance makes sense. If you're referring to a number of slices that belong together as part of the same acquisition then you should use the Series Instance UID
edmcdonagh
@edmcdonagh
Are you starting with the CT on disk, or querying them from the PACS? For the former, write your routine to open one image from each series and check the convolution kernel - if it is not lung/sharp/high number etc then ignore that series. If you are needing to query the PACS first, you won't get this information as part of a query response. You might be able to go by series description. Otherwise retrieve a single image from each series and process as before; when you've found your series, retrieve the rest of that series.
photonsarefree
@photonsarefree

Greatly appreciate both responses! By scan I mean a series (collection of slices that make up a 3D image).

At the moment I am using CTs on disk, with the idea that whatever logic I build using pydicom, I will apply during PACS integration using Java.
I wanted to use convolution kernels but found out that vendors were not consistent with each other. I could do a survey with the academic center I am working with to list out all scanners and possible conv kernel options, maybe I will try that if I fail to find an alternative logic.

bjarnidk
@bjarnidk
hi is there a resource on how to convert a folder of dcm files to a numpy array, such that the tensor becomes shape (s, 3, 256, 256) where is is number of slices for a given patient?
s is*
profhimtee
@profhimtee
It depends what type of dcm files are present in the folder. If they are compressed then you need to decode the compression. Anyway I am sharing code for both the scenario. For lossy-jpeg compression u can try this.
profhimtee
@profhimtee

import numpy as np
import cv2
from math import ceil
from pydicom import dcmread
from pydicom.encaps import decode_data_sequence

for _, folders, files in os.walk(folderPath):
break

for file in files:

dicom = dcmread(folderPath + "/" + file)
tile_height        = dicom[0x0028, 0x0010].value
tile_width         = dicom[0x0028, 0x0011].value
frame_count       = dicom[0x0028, 0x0008].value
bits                 = dicom[0x0028, 0x0100].value
pixels               = dicom[0x7fe0, 0x0010].value
frames               = decode_data_sequence(pixels)
rows               = ceil(dicom[0x0048, 0x0007].value / self.tile_height)
cols               = ceil(dicom[0x0048, 0x0006].value / self.tile_width)
samples_per_pixel = dicom[0x0028, 0x0002].value

itr = 0

if bits == 8:
    bits_type = np.uint8
elif bits == 16:
    bits_type = np.uint16
elif bits == 32:
    bits_type = np.uint32

while( itr < frame_count):
    temp = np.frombuffer(frames[itr], dtype = bits_type)

    try:
        temp = cv2.imdecode(temp, cv2.IMREAD_COLOR) 
        temp = temp.reshape(self.tile_height , self.tile_width, samples_per_pixel)
    except:
        return -6
bjarnidk
@bjarnidk
Thank you!
Jordan Blackadar
@redoverture
Hey all,
First of all thanks for maintaining a ridiculously useful package. I'm very happy to be able to use Python for DICOM stuff.
Just curious, is the next release planned? I'm itching to get that fix for DataSet.copy!
Darcy Mason
@darcymason
We had tentatively scheduled for around November (https://pydicom.github.io/pydicom/stable/faq/index.html#what-version-of-python-can-i-use), but I do feel like it is probably pushing out by early October-ish... I'll check with the other maintainers and see what we can come up with.
Jordan Blackadar
@redoverture
Awesome, thanks! Looking forward to it!
Max Karelov
@maxkarelov
Hi there. I am new to dicom. Could someone help to find out the c_get issue to retrieve file between Horos for Mac client and SCP c_get application from the pynetdicom?
ahmetgoze
@ahmetgoze
Hi there. I want to create a very simple GUI software by using pyqt. On this software, I want to add examples of DICOM images and do some functions like wheel movements to change images etc. I'd be so appreciated if you could give me some advises or where to start. Thanks!
James Kerns
@jrkerns
Hey there! I have a question about connecting pynetdicom to Eclipse. Is this the best place for it or should I post on the pydicom forums?
Darcy Mason
@darcymason
Hi James, @scaramallion is your best bet, and does seem to monitor this chat, so starting here is probably fine.
scaramallion
@scaramallion
Ask away, or maybe I should enable discussions on github?
moonn1214
@moonn1214

Hello. I cleared the contents of the dicom file header and used the code below. The decom file that was opened with the decom viewer does not run. Is something wrong? Are any of the contents of the header information related to the file?

filename = "dcm file path"
Metadata = pydicom.dcmread(str(filename), stop_before_pixels=True)
for i in Metadata:
i.value = ""
Metadata.save_as(str(filename))

mrbean-bremen
@mrbean-bremen
Several of the contents of the DICOM header are related to the image - without them, there is not enough information to display the image. You can't just remove them, they belong to the DICOM format.
moonn1214
@moonn1214
thanks for your kind reply!
RoadToML
@RoadToML
Hey guys, needed some help sending a dcm to a dicom adapter
here my code
This message was deleted
MyAE = AE('ggg')#, [ExplicitVRLittleEndian, ImplicitVRLittleEndian, ExplicitVRBigEndian])
MyAE.add_requested_context('1.2.840.10008.1.1', [ExplicitVRLittleEndian, ImplicitVRLittleEndian, ExplicitVRBigEndian])
MyAE.OnAssociateResponse = OnAssociateResponse

# create association with remote AE
print("Request association")
assoc = MyAE.associate('url', 11112)

if not assoc:
    print("Could not establish association")
    sys.exit(1)
# perform a DICOM ECHO, just to make sure remote AE is listening
print("DICOM Echo ... ",)
# st = assoc.send_c_echo()
# print('done with status "%s"' % st)

# create some dataset
folder_to_copy_in = 'string'
for uid in os.listdir(os.path.join(root_folder, folder_to_copy_in)):
    for i in os.listdir(os.path.join(root_folder, folder_to_copy_in, uid)):
        d = pydicom.dcmread(os.path.join(root_folder, folder_to_copy_in, uid, i))
        print("DICOM StoreSCU ... ",)
        try:
            st = assoc.send_c_store(d, 1)
but i get this error RuntimeError: The association with a peer SCP must be established before sending a C-STORE request and no idea how to fix
RoadToML
@RoadToML
anyone got some clue
i think its to do something around st = assoc.some_method_here to initialise but cant figure it out
Marwan Samih
@MarShallOwn
I wanted to ask a question how do i make my scp listen to multiple ports ?
scaramallion
@scaramallion
You need to use start_server with block=False and use a different port number for each
KunL21
@KunL21
Hi all,
I'm running into a issue where I use a RD dicom file as template and I saved my monte carlo calculated dose set into this RD dicom file named it with a new name eg. MCdose.dcm. The issue I ran into is I can't import this MCdose.dcm file into Eclipse treatment planning system where error message of dose already exist is shown. Anyone know the specific reason for this?
I'm thinking when modifying a RD file and save it as new, beside the pixel data (dose matrix) that I modified. I need to change some tag/id in that RD file in order for this to work. But I'm not sure which tag to change
Any suggestions would help, thanks in advance!
Darcy Mason
@darcymason
Needs a different SOPInstanceUID, but also needs to be changed in referenced instance UID in the associated rtplan.