Re: DICOM pixel data with medcon
* Roland Marcus Rutschmann <Rutschmann@gmx.de> [031220 20:15]:
> > Unfortunately, the `-p' option of medcon invokes an
> > interactive routine, which requires some user input for image
> > number, pixel range, etc.
> I just had a look at the source in MdcAskPixels (file
> m-pixels.c). To bring all parameters into (and not break
> anything else) doesnt seem easy. But you could alter that code
> to read a file in which you put the pixels you're interested in
> (for a quick fix).
I don't think you need to modify the code for that.
You could simply connect stdin to that file such as:
medcon -p -f $dicomfile <$file | ...
where $file contains the required user input. Actually,
this is equivalent to piping in the user input with
echo ... | medcon -p -f $dicomfile | ...
For what it's worth, I've attached a patch against
medcon-0.8.13. This introduces a new option `--print-values-dontask',
to skip the interactive part and invokes the default behaviour,
which is to print out everything, i.e. as if the user just
presses <Enter> when asked for input.
This is clearly not a perfect solution, but it seems to suit
my own needs.
BTW: This patch also fixes a small flaw in MdcHandleNormList(),
which prevents the program from proceeding, when the user confirms
the default range of images by pressing <Enter>.
Best regards - Juergen
Common subdirectories: xmedcon-0.8.13-orig/source/.deps and xmedcon-0.8.13/source/.deps
diff -u xmedcon-0.8.13-orig/source/m-fancy.c xmedcon-0.8.13/source/m-fancy.c
--- xmedcon-0.8.13-orig/source/m-fancy.c Wed Jun 11 00:55:38 2003
+++ xmedcon-0.8.13/source/m-fancy.c Sat Dec 20 17:08:32 2003
@@ -465,7 +465,7 @@
length = strlen(list);
/* <enter> = default: all */
- if (length == 0) {
+ if (length == 1) {
(*inrs)[1] = 0; *it = 2; return(NULL);
}
diff -u xmedcon-0.8.13-orig/source/m-getopt.c xmedcon-0.8.13/source/m-getopt.c
--- xmedcon-0.8.13-orig/source/m-getopt.c Thu Apr 17 23:14:07 2003
+++ xmedcon-0.8.13/source/m-getopt.c Sat Dec 20 18:10:01 2003
@@ -479,6 +479,13 @@
MDC_NEGATIVE=MDC_YES; MDC_CALIBRATE=MDC_YES;
}
continue;
+ }else if ( strcasecmp(argv[a],"--print-values-dontask") == 0 ) {
+ if (XMDC_MEDCON == MDC_NO) {
+ MDC_PIXELS=MDC_YES; MDC_PIXELS_DONTASK=MDC_YES;
+ MDC_INFO=MDC_NO; MDC_NEGATIVE=MDC_YES;
+ MDC_CALIBRATE=MDC_YES;
+ }
+ continue;
}else if ( (strcasecmp(argv[a],"-r") == 0) ||
(strcasecmp(argv[a],"--rename-file") == 0) ) {
if (XMDC_MEDCON == MDC_NO) {
diff -u xmedcon-0.8.13-orig/source/m-global.c xmedcon-0.8.13/source/m-global.c
--- xmedcon-0.8.13-orig/source/m-global.c Mon Jun 9 00:28:11 2003
+++ xmedcon-0.8.13/source/m-global.c Sat Dec 20 18:06:05 2003
@@ -136,7 +136,8 @@
Int8 MDC_FORCE_CONTRAST= MDC_NO; /* apply user specified window center/width */
Int8 MDC_INFO=MDC_YES;
Int8 MDC_INTERACTIVE=MDC_NO, MDC_CONVERT=MDC_NO;
-Int8 MDC_EXTRACT=MDC_NO, MDC_PIXELS=MDC_NO, MDC_NEGATIVE=MDC_NO;
+Int8 MDC_EXTRACT=MDC_NO, MDC_NEGATIVE=MDC_NO;
+Int8 MDC_PIXELS=MDC_NO, MDC_PIXELS_DONTASK=MDC_NO;
Int8 MDC_QUANTIFY=MDC_NO, MDC_CALIBRATE=MDC_NO, MDC_DEBUG=MDC_NO;
Int8 MDC_GIF_OPTIONS=MDC_NO;
Int8 MDC_MAKE_GRAY=MDC_NO, MDC_DITHER_COLOR=MDC_NO;
diff -u xmedcon-0.8.13-orig/source/m-global.h xmedcon-0.8.13/source/m-global.h
--- xmedcon-0.8.13-orig/source/m-global.h Sun Jan 12 01:40:22 2003
+++ xmedcon-0.8.13/source/m-global.h Sat Dec 20 18:05:38 2003
@@ -78,7 +78,7 @@
extern Int8 MDC_BLOCK_MESSAGES;
extern Int8 MDC_INFO, MDC_INTERACTIVE, MDC_CONVERT;
-extern Int8 MDC_EXTRACT, MDC_PIXELS, MDC_NEGATIVE;
+extern Int8 MDC_EXTRACT, MDC_PIXELS, MDC_PIXELS_DONTASK, MDC_NEGATIVE;
extern Int8 MDC_QUANTIFY, MDC_CALIBRATE, MDC_DEBUG;
extern Int8 MDC_GIF_OPTIONS;
extern Int8 MDC_MAKE_GRAY, MDC_DITHER_COLOR;
diff -u xmedcon-0.8.13-orig/source/m-pixels.c xmedcon-0.8.13/source/m-pixels.c
--- xmedcon-0.8.13-orig/source/m-pixels.c Sun Jan 12 01:40:23 2003
+++ xmedcon-0.8.13/source/m-pixels.c Sun Dec 21 10:15:55 2003
@@ -77,12 +77,16 @@
Uint32 *itmp, *ctmp, *rtmp;
char *msg=NULL;
+ if ( MDC_PIXELS_DONTASK == MDC_YES ) { /* Don't ask. Take default. */
+ a1 = MDC_INPUT_NORM_STYLE;
+ } else {
a1 = MdcGetSelectionType();
MdcPrntScrn("\n");
MdcPrntScrn("\n\tInput notes: a) Any number must be one-based (0 = All)");
MdcPrntScrn("\n\t b) Syntax of range : X...Y or X-Y");
MdcPrntScrn("\n\t c) Syntax of interval: X:S:Y (S = step)\n");
+ }
if ( a1 == MDC_INPUT_ECAT_STYLE ) { /* ecat */
if ( (planes=(Uint32 *)malloc((fi->dim[3]+1)*sizeof(Uint32))) == NULL ){
@@ -194,18 +198,21 @@
itmp[0] = 0;
- MdcPrntScrn("\n\tGive a list of image numbers: ex. 1 7...31 84");
- MdcPrntScrn("\n\tYour input [1...%u]: ",fi->number);
- MdcGetStrInput(mdcbufr,MDC_2KB_OFFSET);
-
- it = 1; bt = 2;
-
- if ((msg=MdcHandleNormList(mdcbufr,&itmp,&it,&bt,fi->number)) != NULL){
- MdcPrntWarn(msg);
- if (itmp != NULL) MdcFree(itmp);
- return(MDC_NO);
- }
-
+ if ( MDC_PIXELS_DONTASK == MDC_YES ) { /* Don't ask. Take all images */
+ itmp[1] = 0;
+ } else {
+ MdcPrntScrn("\n\tGive a list of image numbers: ex. 1 7...31 84");
+ MdcPrntScrn("\n\tYour input [1...%u]: ",fi->number);
+ MdcGetStrInput(mdcbufr,MDC_2KB_OFFSET);
+
+ it = 1; bt = 2;
+
+ if ((msg=MdcHandleNormList(mdcbufr,&itmp,&it,&bt,fi->number)) != NULL){
+ MdcPrntWarn(msg);
+ if (itmp != NULL) MdcFree(itmp);
+ return(MDC_NO);
+ }
+ }
}
if (itmp[1] == 0) { /* all images selected, special case */
@@ -233,17 +240,22 @@
}
it=1; bt=2;
-
- MdcPrntScrn("\n\n\tGive a list of pixels x,y : ex. 1,1 12,0");
- MdcPrntScrn("\n\tYour input [%u,%u]: ",fi->mwidth,fi->mheight);
- MdcGetStrInput(mdcbufr,MDC_2KB_OFFSET);
-
- MdcPrntScrn("\n");
-
- if ((msg=MdcHandlePixelList(mdcbufr,&ctmp,&rtmp,&it,&bt)) != NULL) {
- MdcPrntWarn(msg);
- MdcFree(itmp); MdcFree(ctmp); MdcFree(rtmp);
- return(MDC_NO);
+
+ if ( MDC_PIXELS_DONTASK == MDC_YES ) { /* Don't ask. Take all pixels */
+ it = 2;
+ ctmp[1] = 0; rtmp[1] = 0;
+ } else {
+ MdcPrntScrn("\n\n\tGive a list of pixels x,y : ex. 1,1 12,0");
+ MdcPrntScrn("\n\tYour input [%u,%u]: ",fi->mwidth,fi->mheight);
+ MdcGetStrInput(mdcbufr,MDC_2KB_OFFSET);
+
+ MdcPrntScrn("\n");
+
+ if ((msg=MdcHandlePixelList(mdcbufr,&ctmp,&rtmp,&it,&bt)) != NULL) {
+ MdcPrntWarn(msg);
+ MdcFree(itmp); MdcFree(ctmp); MdcFree(rtmp);
+ return(MDC_NO);
+ }
}
ctmp[0] = it - 1; rtmp[0] = it - 1;
Reply to: