Skip to content

Commit

Permalink
[dicomSummary] Improve option behaviour and use sdiff instead of tkdi…
Browse files Browse the repository at this point in the history
…ff for differences (#1000)
  • Loading branch information
nicolasbrossard authored Jul 10, 2023
1 parent 8b12f5e commit 1064bc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
28 changes: 19 additions & 9 deletions dicom-archive/dicomSummary.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ =head1 NAME
=head1 SYNOPSIS
perl dicomSummary.pl </PATH/TO/DICOM/DIR> [ -compare </PATH/TO/DICOM/COMPARE/DIR> ] [ -tmp </PATH/TO/TMP/DIR> ] `[options]`
perl dicomSummary.pl </PATH/TO/DICOM/DIR> [ -comparedir </PATH/TO/DICOM/COMPARE/DIR> ] [ -tmp </PATH/TO/TMP/DIR> ] `[options]`
Available options are:
-comparedir: path to another DICOM directory to compare with
-comparedir: path to another DICOM directory to compare with (implies -xdiff)
-dbcompare : run a comparison with entries int he database
-dbcompare : run a comparison with entries in the database (implies -xdiff)
-database : use the database
Expand All @@ -31,7 +31,7 @@ =head1 SYNOPSIS
-tmp : to specify a temporary directory. It will contain the summaries if
used with -noscreen option
-xdiff : to see with tkdiff the result of the two folders comparison or the
-xdiff : to see with sdiff the result of the two folders comparison or the
comparison with the database content with
-batch : run in batch mode if set. Will log differences to a /tmp/diff.log file.
Expand Down Expand Up @@ -63,6 +63,7 @@ =head2 METHODS
use DICOM::DICOM;
use DICOM::DCMSUM;
use NeuroDB::DBI;
use NeuroDB::ExitCodes;

my $screen = 1;
my $verbose = 0;
Expand Down Expand Up @@ -97,7 +98,7 @@ =head2 METHODS
- a convenient way to compare two directories in terms of the dicom data they contain...
or the contents of a directory with a database repository
Usage:\n\t $0 </PATH/TO/DICOM/DIR> [ -compare </PATH/TO/DICOM/COMPARE/DIR> ] [ -tmp </PATH/TO/TMP/DIR> ] [options]
Usage:\n\t $0 </PATH/TO/DICOM/DIR> [ -comparedir </PATH/TO/DICOM/COMPARE/DIR> ] [ -tmp </PATH/TO/TMP/DIR> ] [options]
\n\n See $0 -help for more info\n\n";

my @arg_table =
Expand All @@ -115,7 +116,7 @@ =head2 METHODS
# fixme add more options based on the capabilities of the DCMSUM class
# ["-produce","string",1, \$produce, "Default is summary, other options are header, files, and acquisitions"],
["-tmp","string",1, \$temp, "You may specify a tmp dir. It will contain the summaries, if you use -noscreen"],
["-xdiff","boolean",1, \$xdiff, "You are comparing two folders or with the database and you want to see the result with tkdiff."],
["-xdiff","boolean",1, \$xdiff, "You are comparing two folders or with the database and you want to see the result with sdiff."],
["-batch","boolean",1, \$batch, "Run in batchmode. Will log differences to a /tmp/diff.log"],

["General options", "section"],
Expand All @@ -138,13 +139,22 @@ =head2 METHODS
# basic checking for compare dir
if ($compare && !-d $compare) { print $Usage; exit 1; } if ($compare) { $compare = abs_path($compare); }

if (($compare || $databasecomp) && !$profile) {
print "-profile must be used if either option -database or -dbcompare are used. Aborting.\n";
exit $NeuroDB::ExitCodes::INVALID_ARG;
}

# Some combinations are just not possible
if ($xdiff || $compare || $batch || $databasecomp || $dbase){ $screen = undef; } elsif (!$compare || !$databasecomp) { $xdiff = undef; }

# you can't compare with db and a dir at the same time
if (($compare || $databasecomp) && $dbase) { print $Usage;
print "\t Please consider that some option combinations do not make sense. \n\n"; exit 1;
}

# If -comparedir or -dbcompare was used, -xdiff is turned on automatically
$xdiff = 1 if $compare || $databasecomp;

# get rid of the trailing slash of all given input dirs
$dcm_folder =~ s/^(.*)\/$/$1/; $temp =~ s/^(.*)\/$/$1/ unless (!$temp); $compare =~ s/^(.*)\/$/$1/ unless (!$compare);

Expand Down Expand Up @@ -223,7 +233,7 @@ =head2 METHODS
if ($conflict) { print "\n\n\tWARNING: You are using Version: $versionInfo but archived with Version : $conflict\n\n"; }
$metaFiles[1] = &read_db_metadata($studyUnique);
if (!$metaFiles[1]) { print "\nYou never archived this study or you are looking in the wrong database.\n\n"; exit; }
if ($xdiff) { $diff = "tkdiff $metaFiles[0] $metaFiles[1]"; `$diff`; }
if ($xdiff) { $diff = "sdiff $metaFiles[0] $metaFiles[1]"; system($diff); }
else {
$diff = "diff -q $metaFiles[0] $metaFiles[1]";
my $Comp = `$diff`;
Expand All @@ -233,8 +243,8 @@ =head2 METHODS
}
# if comparing to another directory in non batch mode
if ($compare && !$batch) {
$diff = "tkdiff $metaFiles[0] $metaFiles[1]";
`$diff` if $xdiff;
$diff = "sdiff $metaFiles[0] $metaFiles[1]";
system($diff) if $xdiff;
}
# in batch mode you don't want any window to pop up. Just create a difference log in tmp
if ($batch && $metaFiles[1] && $returnVal == 99) {
Expand Down
8 changes: 4 additions & 4 deletions docs/scripts_md/dicomSummary.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ dicomSummary.pl -- prints out an informative summary for DICOMs in a given direc

# SYNOPSIS

perl dicomSummary.pl &lt;/PATH/TO/DICOM/DIR> \[ -compare &lt;/PATH/TO/DICOM/COMPARE/DIR> \] \[ -tmp &lt;/PATH/TO/TMP/DIR> \] \`\[options\]\`
perl dicomSummary.pl &lt;/PATH/TO/DICOM/DIR> \[ -comparedir &lt;/PATH/TO/DICOM/COMPARE/DIR> \] \[ -tmp &lt;/PATH/TO/TMP/DIR> \] \`\[options\]\`

Available options are:

\-comparedir: path to another DICOM directory to compare with
\-comparedir: path to another DICOM directory to compare with (implies -xdiff)

\-dbcompare : run a comparison with entries int he database
\-dbcompare : run a comparison with entries in the database (implies -xdiff)

\-database : use the database

Expand All @@ -23,7 +23,7 @@ Available options are:
\-tmp : to specify a temporary directory. It will contain the summaries if
used with -noscreen option

\-xdiff : to see with tkdiff the result of the two folders comparison or the
\-xdiff : to see with sdiff the result of the two folders comparison or the
comparison with the database content with

\-batch : run in batch mode if set. Will log differences to a /tmp/diff.log file.
Expand Down

0 comments on commit 1064bc6

Please sign in to comment.