if a dcm file has property RescaleIntercept= 0, does that mean their will be no HU plot? your program works for me now and it has a RescaleIntercept= -1024. My own ct scan has a RescaleIntercept = 0, so it seems I will get no HU plot. Thanks for the help
@@lesliewubbel9157 my mistake I pasted wrong code from that programmer's kaggle site. Thanks it works, but I have my own ct scans and I get an error "AttributeError: 'FileDataset' object has no attribute 'ImagePositionPatient'. Have to look for that issue
I inserted slices = [dcmread(path + '/' + s) for s in os.listdir(path)] print("after slices") if slices[0].ImagePositionPatient[2] not in slices[0]: print("not in slices") return slices # list of DICOM and it worked
So I am little confuse by your questions I would not sum the values you would just get one big number. But I think you your asking be how to do compile all these "3D slices" into a single 3D image basically you going need to make a new numpy array and then append all the numpy arrays of every slices into that new numpy array. I have done this before but I don't know how this helps anyone for analysis. the code is github I have to find it. I could make a video for you sometime when I am not working
Good questions, each file is sequenced or index in the metadata so you could real all files and check the meta data into a array see if there is any missing fiiles
A Great Tutorial! I have a few doubts in the previous video (what is a DICOM file?) in slide DICOM Caveats Encoding slide at last. It is mentioned that the pixel_array contains HU values. But here in code why are you converting them to HU values?
The default values you extract are in binary and you have convert to HU. HU is just the way radiologist discuss the scale of grayness instead saying binary. Because they dont learn that in class they learn that CT images exist on HU scale.
Sorry I didn't answer the question, the reason you convert HU values is because it makes the data comparable from CT machine to the Next CT machine. Different brands of CT machines have different resolutions depending when they were manufacturing this is effected by many factors, material, voltage, equipment etc All you need the know the newer CT machines have higher resolution and older machines have lower resolution and this is why you need to convert to HU to even compare that data lets say in a machine learning model.
Thanks for perfect tutorial. I try the code and get this error :InvalidDicomError: File is missing DICOM File Meta Information header or the 'DICM' prefix is missing from the header. Use force=True to force reading. how it can be fixed?
Yup so the dicom file itself is missing data that the code is using. That means the dicom file you have if you just read it out to plain text is missing information. Its missing data which makes sense sometimes because medical data is scrubbed of personal information. So dicom data structure is composed of header and you will have to debug it yourself and make python try/except for the missing tag in dicom data
@@lesliewubbel9157 thanks for the reply. I added the function and it worked but now, I get another error that I have no idea about. I have the folder of my Dicom slices in my drive but it shows that [Errno 21] Is a directory: '/content/drive/MyDrive/Nazila cases 1-20/pt 1/.ipynb_checkpoints'
Hello. Thanks for the explanation. In the very beginning, when I try to activate the virtual environment, I face with this error :zsh: command not found: .test_envScriptsactivate I have python installed on my visual studio, so I cant understand what the problem might be. Could you please help?
@@sadafhajiha948 so when you use mac to enter a virtual environement you do source ./test_env/bin/activate macOS is built on top of UNIX so it refers to scripts as bin for binary
Hey Nimesh github.com/cornerstonejs/dicomParser try this github link also it be good to try googling some solutions? I don't know if you mean produce a video for that or not
@@lesliewubbel9157 if you can make a video then that would be great,I did looked at the link you have provided but i am not able to convert dcm to other image formats
not for while its kinda low on the too list. I will show how to anonymize soon but not large scale process that is in-depth technical development its time consuming not really worth making a tutorial
it depends you could write some SQL inserts in python code and you have to convert all dicom files to binary. I dont really know of more efficient way there's lot going on about file compression that can make uploading more efficient again it just complicate like reading documents and testing a project like that. its not impossible just difficult and time-consuming on your own. What your goal?
@@lesliewubbel9157 My goal is to take the metadata attributes(not the files themselves) from the python code you have shown (which is great) and store that data in sql.
@@ws3457 that wont be hard it's very doable if you ever interested learning more we working on open source community we are always happy to talk or work together
if a dcm file has property RescaleIntercept= 0, does that mean their will be no HU plot? your program works for me now and it has a RescaleIntercept= -1024. My own ct scan has a RescaleIntercept = 0, so it seems I will get no HU plot. Thanks for the help
Weird error. I extracted both PAL001 and PAL034 to the folder. The program only sees PAL001 - PAL005. Same with PAL034. Len(patient) = 5
What is your code? Can you share it? In paste bin
@@lesliewubbel9157 my mistake I pasted wrong code from that programmer's kaggle site. Thanks it works, but I have my own ct scans and I get an error "AttributeError: 'FileDataset' object has no attribute 'ImagePositionPatient'. Have to look for that issue
I inserted
slices = [dcmread(path + '/' + s) for s in os.listdir(path)]
print("after slices")
if slices[0].ImagePositionPatient[2] not in slices[0]:
print("not in slices")
return slices # list of DICOM
and it worked
Good explanation! Thank you!
Once those are read in as .dcm files, are they converted to .pny (numpy) files by converting them using np.array()?
yes because DICOM files are 3D images and their is information for (x,y,z) you can check the code here pastebin.com/MXkpnAmq or ask chatgpt for help
@@lesliewubbel9157 I will check that out. Thanks
Thanks!!!
how to sum pixel values in CT image example in coronal plane have 200 slice how to sum to get 1 slice(image).
So I am little confuse by your questions I would not sum the values you would just get one big number.
But I think you your asking be how to do compile all these "3D slices" into a single 3D image basically you going need to make a new numpy array and then append all the numpy arrays of every slices into that new numpy array.
I have done this before but I don't know how this helps anyone for analysis. the code is github I have to find it.
I could make a video for you sometime when I am not working
@@lesliewubbel9157 thanks you?
@@lesliewubbel9157 Could you please help me out with code.
How to check number of missing slices in dicom file
Good questions, each file is sequenced or index in the metadata so you could real all files and check the meta data into a array see if there is any missing fiiles
Can u flatten header ?
A Great Tutorial! I have a few doubts in the previous video (what is a DICOM file?) in slide DICOM Caveats Encoding slide at last. It is mentioned that the pixel_array contains HU values. But here in code why are you converting them to HU values?
The default values you extract are in binary and you have convert to HU. HU is just the way radiologist discuss the scale of grayness instead saying binary. Because they dont learn that in class they learn that CT images exist on HU scale.
Sorry I didn't answer the question, the reason you convert HU values is because it makes the data comparable from CT machine to the Next CT machine. Different brands of CT machines have different resolutions depending when they were manufacturing this is effected by many factors, material, voltage, equipment etc All you need the know the newer CT machines have higher resolution and older machines have lower resolution and this is why you need to convert to HU to even compare that data lets say in a machine learning model.
Thanks for perfect tutorial.
I try the code and get this error :InvalidDicomError: File is missing DICOM File Meta Information header or the 'DICM' prefix is missing from the header. Use force=True to force reading.
how it can be fixed?
Yup so the dicom file itself is missing data that the code is using. That means the dicom file you have if you just read it out to plain text is missing information. Its missing data which makes sense sometimes because medical data is scrubbed of personal information. So dicom data structure is composed of header and you will have to debug it yourself and make python try/except for the missing tag in dicom data
Simply solution is the function dcmread(force=True) it tells the function to read the file anyway since its missing the 'DICM' tag
@@lesliewubbel9157 thanks for the reply. I added the function and it worked but now, I get another error that I have no idea about. I have the folder of my Dicom slices in my drive but it shows that [Errno 21] Is a directory: '/content/drive/MyDrive/Nazila cases 1-20/pt 1/.ipynb_checkpoints'
what is the version of matplotlip,pyplot you are using ???
matplotlib==3.2.0
Thankyou
No problem
Thank you, bro ;)
No problem!!
Hello. Thanks for the explanation. In the very beginning, when I try to activate the virtual environment, I face with this error :zsh: command not found: .test_envScriptsactivate
I have python installed on my visual studio, so I cant understand what the problem might be. Could you please help?
what command are you using? and whats your operating system?
.test_envScriptsactivate did you not use .test_env\Script\activate
@@lesliewubbel9157 I am using mac. And yes, i used .\test_env\Script\activate
@@sadafhajiha948 so when you use mac to enter a virtual environement you do
source ./test_env/bin/activate
macOS is built on top of UNIX so it refers to scripts as bin for binary
Hi, i want to read dicom in nodeJS and convert it into Png. Can you please share resource or anything which can be helpful to me
Hey Nimesh github.com/cornerstonejs/dicomParser try this github link also it be good to try googling some solutions? I don't know if you mean produce a video for that or not
@@lesliewubbel9157 if you can make a video then that would be great,I did looked at the link you have provided but i am not able to convert dcm to other image formats
@@nimeshkumar3663 i cannot promise that i will get to it, it takes lot work and testing
Hello when will you make video of anonymize/ large scale process ; pyspark
not for while its kinda low on the too list. I will show how to anonymize soon but not large scale process that is in-depth technical development its time consuming not really worth making a tutorial
@@lesliewubbel9157 okay sir
How do we store this data in sqlite3 or another db?
it depends you could write some SQL inserts in python code and you have to convert all dicom files to binary. I dont really know of more efficient way there's lot going on about file compression that can make uploading more efficient again it just complicate like reading documents and testing a project like that. its not impossible just difficult and time-consuming on your own.
What your goal?
@@lesliewubbel9157 My goal is to take the metadata attributes(not the files themselves) from the python code you have shown (which is great) and store that data in sql.
@@ws3457 that wont be hard it's very doable if you ever interested learning more we working on open source community we are always happy to talk or work together
@@lesliewubbel9157 Yes, I would like that. Please let me know how to join.
@@ws3457 we use discord discord.gg/X9yKUDU5