Python Extracting 2d array from numpy.pixel_array dicom image

  • Thread starter Thread starter ProPatto16
  • Start date Start date
  • Tags Tags
    2d Array Image
AI Thread Summary
The discussion revolves around extracting and manipulating pixel data from a DICOM image file obtained from a QC SPECT acquisition. The user successfully reads the file using dicom.read_file and retrieves pixel data in a NumPy array with a shape of [2, 1024, 1024], where the first dimension represents two images from different detector heads. The goal is to separate these two images for further analysis, such as removing artifacts and plotting histograms. The user discovers that accessing the individual images can be done simply by indexing the array: 1stArray = array[0] and 2ndArray = array[1]. While this method may not seem intuitive at first, it effectively allows for the manipulation of the pixel data. A suggestion is made to consider using tuples or structs in C++ for a more organized approach, but the current method remains valid in Python.
ProPatto16
Messages
323
Reaction score
0
Hi guys,

I have a dicom image from a QC spect acquisition.
reading the file in with dicom.read_file and pulling pixel data using numpy.pixel_array gives array of shape [2, 1024, 1024]

The 2 represents two images, one from each detector head on the spect scanner and the 1024x1024 are the arrays i want to separate and pull out individually, i.e. so i can manipulate the pixel data, remove buffering 0's, plot histograms of the pixel values etc etc. i have artifacts in one detector head so i need to be able to separate the two slices

looking at numpy package there are ways to "slice" my array but the orientations are confusing and it doesn't separate them into their own arrays.

This should be quite elementary i would of thought

Thanks
 
Technology news on Phys.org
so it looks like its this easy..

'array' is my array of shape [2,1024,1024]

to get the two 1024x1024 arrays out is simply

1stArray = array[0] and 2ndArray = array[1]
..
ill know for sure when i map them
 
ProPatto16 said:
so it looks like its this easy..

'array' is my array of shape [2,1024,1024]

to get the two 1024x1024 arrays out is simply

1stArray = array[0] and 2ndArray = array[1]
..
Yes, it is correct though it doesn't look intuitive. :smile:
In C++, I would probably use i.e a tuple then tie its values to declared variables. Other than that I might use a struct of e.g 3 elements to store the returned values. You can do the same to make more sense of your current approach.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top