Skip to content

Commit

Permalink
✨ dcmdirtab: add -p/--dcmpat option
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Jan 3, 2024
1 parent 2b33b31 commit 2d5af83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dcmdirtab
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ sub firstdcm($p, $dcmpat){


sub get_config(){
my %opts=(subpat=>'\d+', sespat=>'', help=>0, list=>0);
my %opts=(subpat=>'\d+', sespat=>'',
'dcmpat'=>'.*MR.*\|.*dcm$\|.*IMA$',
help=>0, list=>0);
GetOptions(\%opts,
'dirs|d=s@',
'subpat|s=s', 'sespat|b=s',
'dcmpat|p=s',
'cols=s','add_cols|a=s',
'config|c=s', 'eval|e=s',
'no-header|H','short|x',
Expand All @@ -46,7 +49,7 @@ sub get_config(){
my %conf=();
$conf{subpat} = qr/$opts{subpat}/;
$conf{sespat} = qr/$opts{sespat}/;
$conf{dcmpat} = '.*MR.*\|.*dcm$\|.*IMA$';
$conf{dcmpat} = $opts{dcmpat};
# default file info things to grab

$conf{columns}={
Expand Down Expand Up @@ -197,6 +200,7 @@ dcmdirtab - get tab delm. dicom directory info
dcmdirtab -h # more info
dcmdirtab -l # list built in column options (enable with -a
dcmdirtab -s 'E\d+' -d 'E07_MR3/scans/*/'
dcmdirtab -p '.*dcm$' -d 'E07_MR3/scans/*/'
dcmdirtab -s 'E\d+' -d 'E07_MR3/scans/*/' --cols pname,ndcm,fullpath
dcmdirtab -s 'E\d+' -d 'E07_MR3/scans/*/' -x -a acqdir_alt # Short (no fullpath column), add acqdir_alt column
dcmdirtab -s 'E\d+' -d 'E07_MR3/scans/*/' -a acqdir_alt,sex -e '$conf{columns}->{sex}="0010,0040"' # add and use a sex column from dcm header
Expand All @@ -218,6 +222,11 @@ dir glob pattern to dicom folders. e.g. C</path/1*_2*/*/*/>
mulitple C<-d '/path/*/'> accepted.
IMPORTANT: quote the glob in shell
=item -p --dcmpat:
Pattern for dicom files. case-insenstive. used by C<find -iregexp>
defaults to anything with MR, ending in dcm, or ending in IMA.
C<'.*MR.*\|.*dcm$\|.*IMA$'>
=item -c --config:
path to config script. e.g. C<config.pl>.
Expand Down
9 changes: 9 additions & 0 deletions t/dcmdirtab.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ teardown() {
[ $status -ne 0 ]
[[ ! $output =~ "SETUP" ]]
}
@test dcmdirtab-with-custom-dcm-suffix {
cd $THISTESTDIR
mv 001.dcm 'Image (001)'
run dcmdirtab -s 'id-\d{5}' -p '.*Image.*' -d $(pwd)
[ $status -eq 0 ]
[[ $output =~ "id-12345 " ]]
[[ $output =~ " 2000.0 " ]]
}

0 comments on commit 2d5af83

Please sign in to comment.