I am using the DCMTK (3.6.0) library to get the value of the (0020,0013) tag which is the image number aka the slice number of the serie.
I use the following in a batch 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)
It usually goes well, but sometimes this value is always set to '0' to the whole serie.
I tried to dump that with 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 to get (which is not the '0') is the last. In this case, everything is good. But in some particular cases, the correct value is stored between two '0'.
I also tried with a different dumper (DCM4CHE 2.0.23) and it give me the same result.
I want to know why this is happening. And more than that, how to get the correct value?
Is there a way, in a batch file, to eliminate the 0 until the correct number?
By default, my command line cited above take the last field... I think.
('@echo. ^|c:\Libs\dcmtk-3.6.0\bin\dcmdump +p +P "0020,0013" %%i')
but still have the last value, the 0 ... How to proceed ? – Sidewinder