No effect on command line with DCMTK.exe via java

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
solo1
Posts: 3
Joined: Fri, 2017-07-14, 15:05

No effect on command line with DCMTK.exe via java

#1 Post by solo1 »

I'm trying to test the functionality of DCMTK, and I like the idea of use it through command line in my java program. I tried to send some command in java but did not receive the expected effects.

What I did:

1) I downloaded the latest version of the executable file, I took dcmodify.exe from it and an image.dcm and put all in C:\Users\Public\Documents
2) I wrote a fast java code in order to modify a DICOM metadata, but despite trying to change the command line, I could not make any variations in the image metadata.

Main body:

Code: Select all

  try {
            System.out.println("Try to modify a.dcm ...");
            Process process = new ProcessBuilder("C:\\Users\\Public\\Documents\\dcmodify.exe",
                                  "dcmodify -i \"(0010,0010)= Mike\" a.dcm").start();
            System.out.println("done");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
I tried different command but none worked, I have no real idea of what created this problem, i think should be the command formatting. :? :?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: No effect on command line with DCMTK.exe via java

#2 Post by Michael Onken »

Hi,

does the second parameter of ProcessBuilder really take the executable again, i.e. maybe it's:

Code: Select all

 Process process = new ProcessBuilder("C:\\Users\\Public\\Documents\\dcmodify.exe",
                                  "-i \"(0010,0010)= Mike\" a.dcm").start();
Best,
Michael

solo1
Posts: 3
Joined: Fri, 2017-07-14, 15:05

Re: No effect on command line with DCMTK.exe via java

#3 Post by solo1 »

Michael Onken wrote:Hi,

does the second parameter of ProcessBuilder really take the executable again, i.e. maybe it's:

Code: Select all

 Process process = new ProcessBuilder("C:\\Users\\Public\\Documents\\dcmodify.exe",
                                  "-i \"(0010,0010)= Mike\" a.dcm").start();
Best,
Michael
I try it, It does not work.
(a.dcm is in the some folder of dcmodify.exe)

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: No effect on command line with DCMTK.exe via java

#4 Post by Michael Onken »

Then there should be an error, i.e exception. Note that a.dcm should be in the working directory, ie. normally the directory where you run the stuff.
I would try the following:
  • Verify that the command works on your file from the command line directly.
  • Try giving the full path to a.dcm in your ProcessBuilder() call.

solo1
Posts: 3
Joined: Fri, 2017-07-14, 15:05

Re: No effect on command line with DCMTK.exe via java

#5 Post by solo1 »

Michael Onken wrote:Then there should be an error, i.e exception. Note that a.dcm should be in the working directory, ie. normally the directory where you run the stuff.
I would try the following:
  • Verify that the command works on your file from the command line directly.
  • Try giving the full path to a.dcm in your ProcessBuilder() call.
via cmd and full path:

Code: Select all

C:\Users\Public\Documents\dcmodify.exe -i  "(0010,0010)= Mike" C:\Users\Public\Documents\a.dcm
the dcmodify creates a.dcm.bak file, But in my imagination I expected it change the patient name attribute in Mike, but is not so.

What am I wrong about approaching this program? :?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: No effect on command line with DCMTK.exe via java

#6 Post by Michael Onken »

Hi,

No, you're imagination should be right ;)
Did you use dcmdump to check the content after you ran dcmodify?
Did you try running your dcmodify command from the commandline instead to find out if something goes wrong in general?

Best,
Michael

Post Reply

Who is online

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