Skip to content

Commit

Permalink
add SRAnonTool
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Dec 2, 2023
1 parent b695888 commit 82bae06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ Required arguments:
- `-a` / `--anon-script`: Path to a CTP DICOM anonymizer script file. Samples
can be found
[here](https://github.com/johnperry/CTP/tree/master/source/files/profiles/dicom)
- `-s` / `--sr-anon-tool`: Path to the
[SRAnonTool](https://github.com/SMI/SmiServices/tree/master/src/applications/SRAnonTool)

To anonymise a single file:

```console
$ java -jar <jar> -a <anon-script> <src-file> <anon-file>
$ java -jar <jar> -a <anon-script> -s <sr-anon-tool> <src-file> <anon-file>
```

To anonymise multiple files:

```console
$ java -jar <jar> -a <anon-script> (<src-file>:<anon-file>)...
$ java -jar <jar> -a <anon-script> -s <sr-anon-tool> (<src-file>:<anon-file>)...
```

## Development
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/uk/ac/ed/epcc/ctp_anon_cli/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ public static void main(String[] args) throws ParseException {
.build();
options.addOption(option);

option =
Option
.builder("s")
.argName("file")
.hasArg()
.longOpt("sr-anon-tool")
.desc("SR anonymisation tool")
.required()
.build();
options.addOption(option);

CommandLineParser parser = new DefaultParser();
CommandLine cli = null;
try {
Expand All @@ -42,7 +53,12 @@ public static void main(String[] args) throws ParseException {
);

if (!anonScriptFile.isFile()) throw new IllegalArgumentException(
"Cannot find anonymisation script file: " + anonScriptFile.getPath()
"Cannot find anonymisation script file"
);

File srAnonTool = new File(Paths.get(cli.getOptionValue("s")).toString());
if (!srAnonTool.isFile()) throw new IllegalArgumentException(
"Cannot find SRAnonTool"
);

List<String> files = cli.getArgList();
Expand All @@ -58,7 +74,6 @@ public static void main(String[] args) throws ParseException {
System.exit(1);
}

// TODO SRAnon
SmiCtpProcessor anonymizer = new SmiCtpProcessor(
anonScriptFile,
null,
Expand All @@ -67,7 +82,7 @@ public static void main(String[] args) throws ParseException {
false,
false,
null,
null
srAnonTool
);

int rc = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/uk/ac/ed/epcc/ctp_anon_cli/SmiCtpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SmiCtpProcessor {
private boolean _recompress;
private boolean _setBIRElement;
private boolean _testmode;
private String _SRAnonTool;
private File _srAnonTool;

private PixelScript _pixelScript;

Expand All @@ -41,13 +41,13 @@ public SmiCtpProcessor(
boolean setBIRElement,
boolean testmode,
String check,
String SRAnonTool
File srAnonTool
) {
_decompress = decompress;
_recompress = recompress;
_setBIRElement = setBIRElement;
_testmode = testmode;
_SRAnonTool = SRAnonTool;
_srAnonTool = srAnonTool;

if (pixelAnonScriptFile != null) {
_pixelScript = new PixelScript(pixelAnonScriptFile);
Expand Down Expand Up @@ -132,7 +132,7 @@ public void anonymizeImpl(File inFile, File outFile) throws Exception {
if (!isSR) return;

String commandArray[] = {
_SRAnonTool,
_srAnonTool.getAbsolutePath(),
"-i",
origFile.getAbsolutePath(),
"-o",
Expand Down

0 comments on commit 82bae06

Please sign in to comment.