Skip to content

Commit

Permalink
fixed a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmadjar committed Mar 4, 2020
1 parent d468d06 commit ebbf24b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion uploadNeuroDB/NeuroDB/HRRT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ sub updateHrrtUploadInfo {


sub getHrrtArchiveLocationFromHrrtArchiveID {
my ($dbh, $hrrt_archive_id, $dbh) = @_;
my ($hrrt_archive_id, $dbh) = @_;

my $query = "SELECT ArchiveLocation FROM hrrt_archive WHERE HrrtArchiveID=?";
my $sth = $dbh->prepare($query);
Expand Down
4 changes: 3 additions & 1 deletion uploadNeuroDB/NeuroDB/ImagingUpload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ sub CleanUpDataIncomingDir {
## Get config settings using ConfigOB
# ----------------------------------------------------------------
my $configOB = $this->{configOB};
my $tarchive_location = $configOB->getTarchiveLibraryDir();
my $tarchive_location = $this->{'is_hrrt'}
? $configOB->getDataDirPath() . "/hrrtarchive"
: $configOB->getTarchiveLibraryDir();


############################################################
Expand Down
52 changes: 52 additions & 0 deletions uploadNeuroDB/NeuroDB/MRI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,58 @@ sub isDicomImage {
}


=pod
=head3 isEcatImage(@files_list)
This method checks whether the files given as an argument are HRRT ECAT7 images or not.
It will return a hash with the file path as keys and true or false as values (the
value will be set to true if the file is an ECAT7 image, otherwise it will be set to
false).
INPUT: array with full path to the files
RETURNS:
- %isEcatImage: hash with file path as keys and true or false as values (true
if the file is a DICOM image file, false otherwise)
=cut

sub isEcatImage {
my (@files_list) = @_;

# For now, the files list need to be written in a temporary file so that the
# command does not fail on large amount of files. If doing directly
# `ls @files_list | xargs file` then the argument list is too long at it does
# not return one file per line but many files in one line. Writing in a
# temporary file on which we run the command `cat` seems to be the only option
# that works at the moment...
my $tmp_file = $ENV{'TMPDIR'} . "/tmp_list";
open(my $fh, '>', $tmp_file) or die "Could not open file '$tmp_file' $!";
foreach my $file (@files_list) {
printf $fh "%s\n", quotemeta($file);
}
close($fh);

my $cmd = "cat $tmp_file | xargs file";
my @file_types = `$cmd`;
unlink $tmp_file;

my %isEcatImage;
foreach my $line (@file_types) {
my ($file, $type) = split(':', $line);

if ($type =~ /data$/ && $file =~ /\.v$/) {
$isEcatImage{$file} = 1;
} else {
$isEcatImage{$file} = 0;
}
}

return \%isEcatImage;
}


=pod
=head3 get_trashbin_file_rel_path($file)
Expand Down

0 comments on commit ebbf24b

Please sign in to comment.