dcmj2pnm segfault with large multiframe US

All other questions regarding DCMTK

Moderator: Moderator Team

Message
Author
jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm segfault with large multiframe US

#16 Post by jberger »

To workaround the problem - I tried the just discovered new option '+Fn' to extract the pixel data in parts. The manpage writes: 'use absolute frame number for filenames'. If I want to extract only 2 or 800 frames, the option always adds 20 frames, e.g.:

Code: Select all

macbook:~ jb$ ./dcmj2pnm +Fr 21 22 +Fn +op -O --log-level info A0000 mf
I: reading DICOM file: A0000
I: preparing pixel data
I: writing frame 21 to mf.f21.ppm
I: writing frame 22 to mf.f22.ppm
I: writing frame 23 to mf.f23.ppm
I: writing frame 24 to mf.f24.ppm
I: writing frame 25 to mf.f25.ppm
I: writing frame 26 to mf.f26.ppm
I: writing frame 27 to mf.f27.ppm
I: writing frame 28 to mf.f28.ppm
I: writing frame 29 to mf.f29.ppm
I: writing frame 30 to mf.f30.ppm
I: writing frame 31 to mf.f31.ppm
I: writing frame 32 to mf.f32.ppm
I: writing frame 33 to mf.f33.ppm
I: writing frame 34 to mf.f34.ppm
I: writing frame 35 to mf.f35.ppm
I: writing frame 36 to mf.f36.ppm
I: writing frame 37 to mf.f37.ppm
I: writing frame 38 to mf.f38.ppm
I: writing frame 39 to mf.f39.ppm
I: writing frame 40 to mf.f40.ppm
I: writing frame 41 to mf.f41.ppm
I: writing frame 42 to mf.f42.ppm
I: cleaning up memory
Is this a feature?

Anyway - this option seems to be the solution for now ...


Jens

Jens

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

Re: dcmj2pnm segfault with large multiframe US

#17 Post by J. Riesmeier »

Maybe, you misinterpreted the second value after option +Fr?

Code: Select all

    +Fr   --frame-range         [n]umber [c]ount: integer
                                select c frames beginning with frame n

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm segfault with large multiframe US

#18 Post by jberger »

Sorry, shame on me.

Jens

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm segfault with large multiframe US

#19 Post by jberger »

J. Riesmeier wrote:
I would rather recommend to implement the following command line option from dcm2avi also for dcm[j]2pnm:

Code: Select all

memory handling:

  -fm   --frames-in-memory  [f]rame count: integer
          number of frames in memory (default: all)
I would highly appreciate this. Will this be a lot of work?

Jens

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

Re: dcmj2pnm segfault with large multiframe US

#20 Post by J. Riesmeier »

I would expect the required effort to be a couple of hours (plus testing). I've added this as a feature request to the issue tracker.

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm segfault with large multiframe US

#21 Post by jberger »

For now, I'm using this workaround in my shellscript to extract 500 frames per run. The +Fr option becomes very handy here ...

Code: Select all

	# How many frames per run should be extracted
	FRAMECOUNT=500
	# how man full runs with $FRAMECOUNT are needed 
	FULLRUNS=$(echo "${NumberOfFrames}/${FRAMECOUNT}" | bc)
	# how many frames have to be extracted during the last run 
	RESTFRAMES=$(echo "${NumberOfFrames}%${FRAMECOUNT}" | bc)
	# A while loop calls dcmj2pnm multiple times ($FULLRUNS) with an amount of $FRAMECOUNT frames
	FULLRUNCOUNT=1
	STARTCOUNT=1
	while [ ${FULLRUNCOUNT} -le ${FULLRUNS} ]; do
		${BINDIR}/dcmj2pnm --frame-range ${STARTCOUNT} ${FRAMECOUNT} ${dcmj2pnm_us_opts[@]} ${FILE} ${FRAMEDIR}/mf || error "'${FILE}' failed"
		STARTCOUNT=$[STARTCOUNT +${FRAMECOUNT}]
	    FULLRUNCOUNT=$[FULLRUNCOUNT +1]
	done
	# then the remainding frames will be processed ... if the $NumberOfFrames is lower than $FRAMECOUNT, this run of dcmj2pnm is executed only ...
	if [ ${RESTFRAMES} -gt 0 ]; then
		${BINDIR}/dcmj2pnm --frame-range ${STARTCOUNT} ${RESTFRAMES} ${dcmj2pnm_us_opts[@]} ${FILE} ${FRAMEDIR}/mf || error "'${FILE}' failed"
	fi
Many thanks for your awesome and very professional support!

Jens

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest