modify storescp.cc or exec on reception ?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
jberrebi
Posts: 3
Joined: Mon, 2019-03-18, 18:18

modify storescp.cc or exec on reception ?

#1 Post by jberrebi »

Hi,
We are used to store dicoms in a certain way with a modified version of storescp.cc . When the operator is done with the scanning, the dicoms are sent to our server and the first thing that is done is the creation of a directory whose name follows the pattern:

StudyID_SudyDate_StudyTime, Let's say in our example 12345_20190319_081020

In that directory, we subdivise in many directories whose names are the SeriesNumber padded with zeroes so that the string 's length is 8. I.e.: 00000001 00000002 00000003 00000004 etc...

Then the dicoms are stored in each corresponding subdirectory with InstanceNumber padded with zeros up to 8. 00000001.dcm 00000002.dcm ..... 000012546.dcm

All that is done within storescp (version 3.6.1)

Now, although it was really fun to go and modify the C code and the dicom reception was very fast that way, I am not sure it is the best solution. So I had a closer look to exec on reception and I did a bash script that makes the equivalent of what the modified storescp did (with two arguments #p and #f) . However I find very heavy to run dcmdump on each and single dicom.


var=$(dcmdump $1/$2 | grep 'StudyDate\|StudyTime\|StudyID\|SeriesNu$
J=$(echo $var | cut -f1 -d' ')
H=$(echo $var | cut -f2 -d' ')
S=$(echo $var | cut -f3 -d' ')
D=$(echo $var | cut -f4 -d' ' | xargs printf "%08d")
F=$(echo $var | cut -f5 -d' ' | xargs printf "%08d.dcm")
MR=/images/dcmrecvtest
ST=$MR/$S"_"$J"_"$H
if [ ! -d "$ST" ]; then
mkdir $ST
fi
if [ ! -d "$ST/$D" ]; then
mkdir $ST/$D
fimv $1/$2 $ST/$D/$F


Have I missed any better way of doing that. Should I first run storescp without any options and then exec on end of reception a batch that does the job? That batch, unless it is storescp itself will have lost the information about the different tags used anyway. Before I do again the C modification, I want to be sure that there is no better solution already available in dcmtk.
Thank you,
Best,
Jonathan

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: modify storescp.cc or exec on reception ?

#2 Post by J. Riesmeier »

var=$(dcmdump $1/$2 | grep 'StudyDate\|StudyTime\|StudyID\|SeriesNu$
You should use dcmdump with option -M (--load-short) in order to improve the loading time and use option +P (--search) for printing only selected DICOM attributes, i.e. in your case "+P StudyDate +P StudyTime +P StudyID +P SeriesNumber".
Before I do again the C modification, I want to be sure that there is no better solution already available in dcmtk.
I personally would use dcmrecv (instead of storescp), which is written in C++ based on the DcmStorageSCP class, and implement new options for "subdirectory generation" and "filename generation":

Code: Select all

  subdirectory generation:
    -s    --no-subdir            do not generate any subdirectories (default)
    +ssd  --series-date-subdir   generate subdirectories from series date
  filename generation:
    +fd   --default-filenames    generate filename from instance UID (default)
    +fu   --unique-filenames     generate unique filename based on new UID
    +fsu  --short-unique-names   generate short pseudo-random unique filename
    +fst  --system-time-names    generate filename from current system time
    -fe   --filename-extension   [e]xtension: string (default: none)
                                 append e to all generated filenames
If you do it in a general way and want to contribute it to the Open Source toolkit DCMTK, you could send us a patch (and we will check and possibly add it to the official source code repository). Also see: https://blog.jriesmeier.com/2013/03/how ... the-dcmtk/ and https://forum.dcmtk.org/viewtopic.php?f=4&p=19168

jberrebi
Posts: 3
Joined: Mon, 2019-03-18, 18:18

Re: modify storescp.cc or exec on reception ?

#3 Post by jberrebi »

Thank you very much,
I already tried the -M and +P flags of dcmdump which makes the script a little shorter shorter and more efficient.
Also I had the time to have a look at the dcmrecv script which seems lighter than storescp for directory creation.
Best,
Jonathan

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest