Skip to content

Commit

Permalink
#1307 : dcm4che utilities : Fix issues and improve documentation for …
Browse files Browse the repository at this point in the history
…several dcm4che tools
  • Loading branch information
vrindanayak committed Apr 3, 2023
1 parent 27ee3ac commit a50891d
Show file tree
Hide file tree
Showing 30 changed files with 515 additions and 221 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Utilities
- [deidentify][]: De-identify one or several DICOM files
- [emf2sf][]: Convert DICOM Enhanced Multi-frame image to legacy DICOM Single-frame images
- [findscu][]: Invoke DICOM C-FIND Query Request
- [fixlo2un][]: Fixes length of private tags truncated to 2 bytes on conversion from implicit VR to explicit VR Transfer Syntax
- [getscu][]: Invoke DICOM C-GET Retrieve Request
- [hl72xml][]: Convert HL7 v2.x message in XML presentation
- [hl7pdq][]: Query HL7 v2.x Patient Demographics Supplier
Expand All @@ -101,6 +102,8 @@ Utilities
- [ianscp][]: DICOM Instance Availability Notification receiver
- [ianscu][]: Send DICOM Instance Availability Notification
- [jpg2dcm][]: Convert JPEG images or MPEG videos in DICOM files
- [json2dcm][]: Converts JSON file to DICOM file
- [json2index][]: Creates search index for UI configuration from JSON schema files
- [json2props][]: Convert Archive configuration schema JSON files to key/value properties files and vice versa
- [json2rst][]: Generate ReStructuredText files from Archive configuration schema JSON files
- [maskpxdata][]: Mask information burned into the Pixel Data
Expand All @@ -118,6 +121,7 @@ Utilities
- [swappxdata][]: Swaps bytes of uncompressed pixel data in DICOM files
- [syslog][]: Send Syslog messages via TCP/TLS or UDP to a Syslog Receiver
- [syslogd][]: Receives RFC 5424 Syslog messages via TCP/TLS or UDP
- [tpl2xml][]: Converts private dictionaries present in template file(s) to xml file(s).
- [upsscu][]: Invokes services of Unified Procedure Step Service Class
- [wadors][]: Wado RS Client Simulator
- [wadows][]: Wado WS Client Simulator
Expand All @@ -141,6 +145,7 @@ Utilities
[deidentify]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-deidentify/README.md
[emf2sf]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-emf2sf/README.md
[findscu]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-findscu/README.md
[fixlo2un]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-fixlo2un/README.md
[getscu]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-getscu/README.md
[hl72xml]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-hl72xml/README.md
[hl7pdq]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-hl7pdq/README.md
Expand All @@ -150,6 +155,8 @@ Utilities
[ianscp]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-ianscp/README.md
[ianscu]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-ianscu/README.md
[jpg2dcm]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-jpg2dcm/README.md
[json2dcm]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-json2dcm/README.md
[json2index]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-json2index/README.md
[json2props]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-json2props/README.md
[json2rst]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-json2rst/README.md
[maskpxdata]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-maskpxdata/README.md
Expand All @@ -167,6 +174,7 @@ Utilities
[swappxdata]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-swappxdata/README.md
[syslog]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-syslog/README.md
[syslogd]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-syslogd/README.md
[tpl2xml]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-tpl2xml/README.md
[upsscu]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-upsscu/README.md
[wadors]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-wadors/README.md
[wadows]: https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-wadows/README.md
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/fixlo2un
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ fi

# Setup the classpath
CP="$DCM4CHE_HOME/lib/$MAIN_JAR"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-tool-common-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/commons-cli-${commons-cli.version}.jar"

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/fixlo2un.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ set JAVA=%JAVA_HOME%\bin\java
:SKIP_SET_JAVA_HOME

set CP=%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-${commons-cli.version}.jar

"%JAVA%" %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% %ARGS%
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2index
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ fi

# Setup the classpath
CP="$DCM4CHE_HOME/lib/$MAIN_JAR"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-tool-common-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/commons-cli-${commons-cli.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/jakarta.json-${jakarta.json.version}.jar"

# For Cygwin, switch paths to Windows format before running java
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2index.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set JAVA=%JAVA_HOME%\bin\java
:SKIP_SET_JAVA_HOME

set CP=%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-${commons-cli.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\jakarta.json-${jakarta.json.version}.jar

"%JAVA%" %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% %ARGS%
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ fi

# Setup the classpath
CP="$DCM4CHE_HOME/lib/$MAIN_JAR"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-tool-common-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/commons-cli-${commons-cli.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/jakarta.json-${jakarta.json.version}.jar"

# For Cygwin, switch paths to Windows format before running java
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2props.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set JAVA=%JAVA_HOME%\bin\java
:SKIP_SET_JAVA_HOME

set CP=%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-${commons-cli.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\jakarta.json-${jakarta.json.version}.jar

"%JAVA%" %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% %ARGS%
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ fi

# Setup the classpath
CP="$DCM4CHE_HOME/lib/$MAIN_JAR"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-tool-common-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/commons-cli-${commons-cli.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/jakarta.json-${jakarta.json.version}.jar"

# For Cygwin, switch paths to Windows format before running java
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/json2rst.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set JAVA=%JAVA_HOME%\bin\java
:SKIP_SET_JAVA_HOME

set CP=%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-${commons-cli.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\jakarta.json-${jakarta.json.version}.jar

"%JAVA%" %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% %ARGS%
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/planarconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ fi
# Setup the classpath
CP="$DCM4CHE_HOME/etc/planarconfig/"
CP="$CP:$DCM4CHE_HOME/lib/$MAIN_JAR"
CP="$CP:$DCM4CHE_HOME/lib/commons-cli-${commons-cli.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-core-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-image-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/dcm4che-tool-common-${project.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/slf4j-api-${slf4j.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/logback-core-${logback.version}.jar"
CP="$CP:$DCM4CHE_HOME/lib/logback-classic-${logback.version}.jar"
Expand Down
2 changes: 2 additions & 0 deletions dcm4che-assembly/src/bin/planarconfig.bat
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ set JAVA=%JAVA_HOME%\bin\java

set CP=%DCM4CHE_HOME%\etc\planarconfig\
set CP=%CP%;%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-${commons-cli.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-core-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-image-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-${project.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\slf4j-api-${slf4j.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\logback-core-${logback.version}.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\logback-classic-${logback.version}.jar
Expand Down
51 changes: 29 additions & 22 deletions dcm4che-tool/dcm4che-tool-fixlo2un/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
```console
$ fixlo2un
Usage: fixlo2un SOURCE DEST
fixlo2un SOURCE... DIRECTORY
```
```console
$ fixlo2un corrupted.dcm fixed.dcm
````
usage: fixlo2un SOURCE DEST
or fixlo2un SOURCE... DIRECTORY
Utility to fix length of private (gggg,00ee) elements truncated to 2 bytes
on conversion from implicit VR to explicit VR Transfer Syntax
-
Options:
-h,--help display this help and exit
-V,--version output version information and exit
-
Example: fixlo2un corrupted.dcm fixed.dcm
corrupted.dcm -> fixed.dcm
2008: (0043,0042) LO #66 -> UN #4718658
4720674: (0045,0044) LO #68 -> UN #4390980
9111662: (0047,0047) LO #70 -> UN #4522054
24709496: (004D,004B) LO #76 -> UN #4849740
29559244: (004F,004F) LO #78 -> UN #5111886
34671138: (0053,0052) LO #82 -> UN #5242962
39914108: (0055,0054) LO #84 -> UN #5439572
45353688: (0057,0057) LO #86 -> UN #5570646
50924342: (0059,0059) LO #88 -> UN #5701720
68357220: (005D,005C) LO #92 -> UN #6029404
74386632: (005D,005D) LO #94 -> UN #6094942
80481582: (005F,005F) LO #96 -> UN #6226016
86707606: (0061,005F) LO #96 -> UN #6226016
92933630: (0065,006C) LO #126 -> UN #9371774
```
=> Results in
2008: (0043,0042) LO #66 -> UN #4718658
4720674: (0045,0044) LO #68 -> UN #4390980
9111662: (0047,0047) LO #70 -> UN #4522054
24709496: (004D,004B) LO #76 -> UN #4849740
29559244: (004F,004F) LO #78 -> UN #5111886
34671138: (0053,0052) LO #82 -> UN #5242962
39914108: (0055,0054) LO #84 -> UN #5439572
45353688: (0057,0057) LO #86 -> UN #5570646
50924342: (0059,0059) LO #88 -> UN #5701720
68357220: (005D,005C) LO #92 -> UN #6029404
74386632: (005D,005D) LO #94 -> UN #6094942
80481582: (005F,005F) LO #96 -> UN #6226016
86707606: (0061,005F) LO #96 -> UN #6226016
92933630: (0065,006C) LO #126 -> UN #9371774
-
````
7 changes: 7 additions & 0 deletions dcm4che-tool/dcm4che-tool-fixlo2un/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@

<artifactId>dcm4che-tool-fixlo2un</artifactId>

<dependencies>
<dependency>
<groupId>org.dcm4che.tool</groupId>
<artifactId>dcm4che-tool-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@

package org.dcm4che3.tool.fixlo2un;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.dcm4che3.tool.common.CLIUtils;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
Expand All @@ -49,13 +54,16 @@
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
import java.util.List;
import java.util.ResourceBundle;

/**
* @author Gunter Zeilinger <gunterze@gmail.com>
* @since May 2019
*/
public class FixLO2UN extends SimpleFileVisitor<Path> {

private static final ResourceBundle rb = ResourceBundle.getBundle("org.dcm4che3.tool.fixlo2un.messages");
private final ByteBuffer buffer = ByteBuffer.wrap(new byte[] { 0x55, 0x4e, 0, 0, 0, 0, 0, 0 })
.order(ByteOrder.LITTLE_ENDIAN);
private final Path srcPath;
Expand All @@ -68,21 +76,35 @@ private FixLO2UN(Path srcPath, Path destPath, Dest dest) {
this.dest = dest;
}

public static void main(String[] args) throws IOException {
if (args.length < 2) {
System.out.println("Usage: fixlo2un SOURCE DEST");
System.out.println(" fixlo2un SOURCE... DIRECTORY");
System.exit(-1);
}
Path destPath = Paths.get(args[args.length - 1]);
if (!Files.isDirectory(destPath) && (args.length > 2 || !Files.isRegularFile(Paths.get(args[0])))) {
System.out.printf("target '%s' is not a directory%n", destPath);
System.exit(-1);
}
Dest dest = Dest.of(destPath);
for (int i = 0; i < args.length - 1; i++) {
Path srcPath = Paths.get(args[i]);
Files.walkFileTree(srcPath, new FixLO2UN(srcPath, destPath, dest));
private static CommandLine parseCommandLine(String[] args)
throws ParseException {
Options opts = new Options();
CLIUtils.addCommonOptions(opts);
return CLIUtils.parseComandLine(args, opts, rb, FixLO2UN.class);
}

public static void main(String[] args) {
try {
CommandLine cl = parseCommandLine(args);
List<String> argList = cl.getArgList();
Path destPath = Paths.get(argList.get(argList.size() - 1));
if (!Files.isDirectory(destPath) && (argList.size() > 2 || !Files.isRegularFile(Paths.get(argList.get(0))))) {
System.out.printf("target '%s' is not a directory%n", destPath);
System.exit(-1);
}
Dest dest = Dest.of(destPath);
for (int i = 0; i < argList.size() - 1; i++) {
Path srcPath = Paths.get(argList.get(i));
Files.walkFileTree(srcPath, new FixLO2UN(srcPath, destPath, dest));
}
} catch (ParseException e) {
System.err.println("json2rst: " + e.getMessage());
System.err.println(rb.getString("try"));
System.exit(2);
} catch (Exception e) {
System.err.println("json2rst: " + e.getMessage());
e.printStackTrace();
System.exit(2);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
usage=fixlo2un SOURCE DEST\n\
or fixlo2un SOURCE... DIRECTORY
try=Try `fixlo2un --help' for more information.
description=\n\
Utility to fix length of private (gggg,00ee) elements truncated to 2 bytes on conversion from implicit VR to explicit VR \
Transfer Syntax \n\-\n\
Options:
example=-\n\
Example: fixlo2un corrupted.dcm fixed.dcm \n\
corrupted.dcm -> fixed.dcm \n\
=> Results in \n\
2008: (0043,0042) LO #66 -> UN #4718658 \n\
4720674: (0045,0044) LO #68 -> UN #4390980 \n\
9111662: (0047,0047) LO #70 -> UN #4522054 \n\
24709496: (004D,004B) LO #76 -> UN #4849740 \n\
29559244: (004F,004F) LO #78 -> UN #5111886 \n\
34671138: (0053,0052) LO #82 -> UN #5242962 \n\
39914108: (0055,0054) LO #84 -> UN #5439572 \n\
45353688: (0057,0057) LO #86 -> UN #5570646 \n\
50924342: (0059,0059) LO #88 -> UN #5701720 \n\
68357220: (005D,005C) LO #92 -> UN #6029404 \n\
74386632: (005D,005D) LO #94 -> UN #6094942 \n\
80481582: (005F,005F) LO #96 -> UN #6226016 \n\
86707606: (0061,005F) LO #96 -> UN #6226016 \n\
92933630: (0065,006C) LO #126 -> UN #9371774 \n\-\n\
16 changes: 16 additions & 0 deletions dcm4che-tool/dcm4che-tool-json2index/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
````
usage: json2index <schema-dir>
Utility to create search index for UI configuration from JSON schema files
-
Options:
-h,--help display this help and exit
-V,--version output version information and exit
-
Example: json2index /work/dcm4chee-arc-lang/src/main/webapp/assets/schema
=> Shows attribute names and their descriptions in schema json files
present in specified directory. Also shows the parent of each of the
schemas, if any.
-
````
5 changes: 5 additions & 0 deletions dcm4che-tool/dcm4che-tool-json2index/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
</dependency>
<dependency>
<groupId>org.dcm4che.tool</groupId>
<artifactId>dcm4che-tool-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit a50891d

Please sign in to comment.