DICOM field has more value than expected

I use the DCMTK library (3.6.0) to get the tag value (0020,0013), which is the image number, or slice number in the series.

I use the following in a package script

for /f "tokens=2 delims=[]" %%a in ('@echo. ^|c:\Libs\dcmtk-3.6.0\bin\dcmdump +P "0020,0013" %%i') do (set img_no=%%a) 

This is usually good, but sometimes this value is always set to “0” for the entire series.

I tried to reset using this command

 C:\Libs\dcmtk-3.6.0\bin>dcmdump +P "0020,0013" PathToInvalideDICOM\img.dcm (0020,0013) IS [0] # 2, 1 InstanceNumber (0020,0013) IS [4] # 2, 1 InstanceNumber (0020,0013) IS [0] # 2, 1 InstanceNumber C:\Libs\dcmtk-3.6.0\bin>dcmdump +P "0020,0013" PathToCorrectDICOM\img.dcm (0020,0013) IS [0] # 2, 1 InstanceNumber (0020,0013) IS [5] # 2, 1 InstanceNumber 

As we can see, sometimes the value of get (which is not "0") is the last. In this case, all is well. But in some special cases, the correct value is maintained between two "0".

I also tried using a different dump truck (DCM4CHE 2.0.23) and it gave me the same result.

I want to know why this is happening. And what's more, how to get the right value?

Is there a way in a batch file to eliminate 0 to the desired number?

By default, my last command line takes the last field ... I think.

+5
source share
2 answers

Most likely, the optional InstanceNumber tags are part of the dicom sequence and may not be the ones you need.

If you run dcmdump, follow these steps:

 dcmdump +p +P "0020,0013" PathToInvalideDICOM\img.dcm 

You should get full coverage of the output, for example:

 (0008,1111).(0020,0013) IS [0] # 2, 1 InstanceNumber (0020,0013) IS [1] # 2, 1 InstanceNumber (5200,9230).(2005,140f).(0020,0013) IS [1] # 2, 1 InstanceNumber 

Then you just need to check which instance of InstanceNumber you need (possibly global)

In a batch file, you probably want to make findstr to select a line. You can try:

 dcmdump +p +P "0020,0013" PathToInvalideDICOM\img.dcm | findstr /b (0020 

Pull out the "global" instance of InstanceNumber. Then you can analyze the tokens as they are.

+6
source
  • Add a comparison inside the loop:

     for /f "tokens=2 delims=[]" %%a in (' @echo. ^|c:\Libs\dcmtk-3.6.0\bin\dcmdump +P "0020,0013" %%i ') do ( if not "%%a"=="0" set img_no=%%a ) 
  • or filter [0] with find :

     for /f "tokens=2 delims=[]" %%a in (' @echo. ^|c:\Libs\dcmtk-3.6.0\bin\dcmdump +P "0020,0013" %%i ^|find /v "[0]" ') do set img_no=%%a 
+1
source

Source: https://habr.com/ru/post/1233625/


All Articles