Skip to content

Commit

Permalink
PetHRRT pipeline fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Feb 19, 2021
1 parent 154608e commit cebbf46
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This repo can be installed on the same VM as the main LORIS codebase, or on a di
* Python 3 with pip3 and virtualenv (step 2 below)
* MINC toolkit (step 3 below)
* DICOM toolkit (step 4 below)
* tpcclib (for hrrt only) (http://www.turkupetcentre.net/tpcclib-doc/md_install.html)

On <u>Ubuntu</u>, DICOM toolkit will be installed by the imaging install script (step 4 below). This script will _apt-get install dcmtk_.

Expand Down
4 changes: 1 addition & 3 deletions batch_uploads_imageuploader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,13 @@ =head2 Methods
my ($stdoutbase, $stderrbase) = ("$data_dir/batch_output/imuploadstdout.log",
"$data_dir/batch_output/imuploadstderr.log");


while($_ = $ARGV[0], /^-/) {
while($_ = $ARGV[0] // '', /^-/) {
shift;
last if /^--$/; ## -- ends argument processing
if (/^-D/) { $debug++ } ## debug level
if (/^-v/) { $verbose++ } ## verbosity
}


## read input from STDIN, store into array @inputs (`find ....... | this_script`)
my @patientnamearray = ();
my @fullpatharray = ();
Expand Down
1 change: 1 addition & 0 deletions imaging_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ echo "Creating the data directories"
sudo -S su $USER -c "mkdir -m 2770 -p /data/$PROJ/data/"
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/trashbin" #holds mincs that didn't match protocol
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/tarchive" #holds tared dicom-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/hrrtarchive" #holds tared hrrt-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/pic" #holds jpegs generated for the MRI-browser
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/logs" #holds logs from pipeline script
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/assembly" #holds the MINC files
Expand Down
1 change: 1 addition & 0 deletions imaging_install_MacOSX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ echo "Creating the data directories"
sudo -S su $USER -c "chmod g+s /data/$PROJ/data/"
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/trashbin" #holds mincs that didn't match protocol
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/tarchive" #holds tared dicom-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/hrrtarchive" #holds tared hrrt-folder
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/pic" #holds jpegs generated for the MRI-browser
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/logs" #holds logs from pipeline script
sudo -S su $USER -c "mkdir -m 770 -p /data/$PROJ/data/assembly" #holds the MINC files
Expand Down
2 changes: 1 addition & 1 deletion uploadNeuroDB/HRRT_PET_insertion.pl
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,4 @@ sub run_hrrt_archival {
$archive->{hrrt_archive_ID} = $newHrrtArchiveID;

return $archive;
}
}
17 changes: 9 additions & 8 deletions uploadNeuroDB/NeuroDB/ExitCodes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,14 @@ our $REGISTER_PROGRAM_FAILURE = 200; # if MNI::Spawn::RegisterPrograms failed


#### --- FROM uploadNeuroDB/HRRT_PET_insertion.pl
our $INVALID_UPLOAD_ID = 280; # invalid upload ID
our $INVALID_UPLOAD_LOCATION = 281; # invalid upload location
our $INVALID_DECOMP_LOCATION = 282; # invalid decompressed location
our $MINC_FILE_NOT_FOUND = 283; # if could not convert ECAT file into MINC
our $MINC_INSERTION_FAILURE = 284; # if MINC file insertion failure
our $HRRT_ALREADY_INSERTED = 285; # if HRRT archive already exists in DB
our $HEADER_INSERT_FAILURE = 286; # if could not insert matlab info into the
# MINC header
our $INVALID_UPLOAD_ID = 280; # invalid upload ID
our $INVALID_UPLOAD_LOCATION = 281; # invalid upload location
our $INVALID_DECOMP_LOCATION = 282; # invalid decompressed location
our $MINC_FILE_NOT_FOUND = 283; # if could not convert ECAT file into MINC
our $MINC_INSERTION_FAILURE = 284; # if MINC file insertion failure
our $HRRT_ALREADY_INSERTED = 285; # if HRRT archive already exists in DB
our $HEADER_INSERT_FAILURE = 286; # if could not insert matlab info into the
# MINC header
our $HRRT_ARCHIVE_INSERTION_FAILURE = 287; # if HRRT archive insertion into the
# database has failed
our $UNKNOW_PROTOCOL = 288; # if HRRT protocol is not found
25 changes: 13 additions & 12 deletions uploadNeuroDB/NeuroDB/HRRT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use Date::Parse;
use String::ShellQuote;
use File::Copy;


use NeuroDB::MincUtilities;
use NeuroDB::Utilities;

Expand Down Expand Up @@ -303,16 +302,18 @@ sub read_matlab_file {
my @matlab_files = grep ( /.m$/, @{ $self->{hrrt_files} } );
my $matlab_file = $matlab_files[0];

open my $fh, '<', $matlab_file;
chomp(my @info = <$fh>);
close $fh;

foreach my $line_nb ( @info ) {
next unless ( $line_nb =~ / = / );
my ($key, $val) = split( ' = ', $line_nb );
$val =~ s/;\cM$//;
# set header information
$self->{matlab_info}->{$key} = $val;
if (defined($matlab_file)) {
open my $fh, '<', $matlab_file;
chomp(my @info = <$fh>);
close $fh;

foreach my $line_nb ( @info ) {
next unless ( $line_nb =~ / = / );
my ($key, $val) = split( ' = ', $line_nb );
$val =~ s/;\cM$//;
# set header information
$self->{matlab_info}->{$key} = $val;
}
}

return $self->{matlab_info};
Expand Down Expand Up @@ -753,4 +754,4 @@ License: GPLv3
LORIS community <loris.info@mcin.ca> and McGill Centre for Integrative Neuroscience
=cut
=cut
7 changes: 4 additions & 3 deletions uploadNeuroDB/NeuroDB/ImagingUpload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ sub IsCandidateInfoValid {
}
}

# Issue a warning for the total number of files that are not
# DICOM images
# Issue a warning for the total number of files that are not
# DICOM images
my $files_not_dicom = scalar @non_image_files;
if ( (!$this->{'is_hrrt'}) && ($files_not_dicom > 0) ) {
$message = "\nWARNING: There are $files_not_dicom file(s) which"
Expand All @@ -295,6 +295,7 @@ sub IsCandidateInfoValid {
my $phantom_regex = "($lego_phantom_regex)|($living_phantom_regex)";
my $patient_name = $this->{'pname'};
if ($this->{'is_hrrt'}) {

# if modality is PET HRRT (i.e. there's at least one ECAT7 file), then check
# that all the files present in the PET directory have been named correctly
foreach my $file (@file_list) {
Expand All @@ -312,7 +313,7 @@ sub IsCandidateInfoValid {
}
}

# return 0 if found at least one DICOM file without the proper patient name
# return > 0 if found at least one DICOM file without the proper patient name
if ( $files_with_unmatched_patient_name > 0 ) {
$message =
"\nERROR: There are $files_with_unmatched_patient_name file(s)"
Expand Down
15 changes: 10 additions & 5 deletions uploadNeuroDB/NeuroDB/MRIProcessingUtility.pm
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ INPUTS:

sub writeErrorLog {
my $this = shift;
my ($message, $failStatus,$LogDir) = @_;
my ($message, $failStatus, $LogDir) = @_;
print STDERR $message;
$this->{LOG}->print($message);
$this->{LOG}->print(
"program exit status: $failStatus"
);

if (defined($failStatus)) {
$this->{LOG}->print(
"program exit status: $failStatus"
);
}
`cat $this->{logfile} >> $this->{LogDir}/error.log`;
close $this->{LOG};
`rm -f $this->{logfile} `;
Expand Down Expand Up @@ -463,7 +466,7 @@ sub createTarchiveArray {
if ($hrrt) {

my %tarchiveInfo;
my ($query = <<QUERY) =~ s/\n/ /gm;
(my $query = <<QUERY) =~ s/\n/ /gm;
SELECT
PatientName, CenterName, DateAcquired,
Blake2bArchive, ArchiveLocation, HrrtArchiveID
Expand All @@ -472,9 +475,11 @@ sub createTarchiveArray {
WHERE
ArchiveLocation LIKE ?
QUERY

if ($this->{debug}) {
print $query . "\n";
}

my $sth = ${$this->{'dbhr'}}->prepare($query);
$sth->execute("'%".basename($tarchive)."%'");

Expand Down
5 changes: 4 additions & 1 deletion uploadNeuroDB/NeuroDB/Utilities.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ sub blake2b_hash {
binmode(FILE);

return Digest::BLAKE2->new->addfile(*FILE)->hexdigest;
}
}

1;

0 comments on commit cebbf46

Please sign in to comment.